File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
ansible/files/admin_api_scripts Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -9,15 +9,32 @@ if pgrep resizefs; then
99 exit 1
1010fi
1111
12+ # Parses the output of lsblk to get the root partition number
13+ # Example output:
14+ # NAME MOUNTPOINT
15+ # nvme0n1
16+ # ├─nvme0n1p1 /boot
17+ # └─nvme0n1p3 /
18+ # nvme1n1 /data
19+ #
20+ # Resulting in:
21+ # └─nvme0n1p3 / -> nvme0n1p3 -> 3
22+ ROOT_PARTITION_NUMBER=$( lsblk -no NAME,MOUNTPOINT | grep ' /$' | awk ' {print $1;}' | sed ' s/.*nvme[0-9]n[0-9]p//g' )
23+
24+ if ! [[ " $ROOT_PARTITION_NUMBER " =~ ^[0-9]+$ ]]; then
25+ echo " Error: ROOT_PARTITION_NUMBER is not a valid number: $ROOT_PARTITION_NUMBER "
26+ exit 1
27+ fi
28+
1229if [ -b /dev/nvme1n1 ] ; then
1330 if [[ " ${VOLUME_TYPE} " == " data" ]]; then
1431 resize2fs /dev/nvme1n1
1532
1633 elif [[ " ${VOLUME_TYPE} " == " root" ]] ; then
1734 PLACEHOLDER_FL=/home/ubuntu/50M_PLACEHOLDER
1835 rm -f " ${PLACEHOLDER_FL} " || true
19- growpart /dev/nvme0n1 2
20- resize2fs /dev/nvme0n1p2
36+ growpart /dev/nvme0n1 " ${ROOT_PARTITION_NUMBER} "
37+ resize2fs " /dev/nvme0n1p ${ROOT_PARTITION_NUMBER} "
2138 if [[ ! -f " ${PLACEHOLDER_FL} " ]] ; then
2239 fallocate -l50M " ${PLACEHOLDER_FL} "
2340 fi
@@ -26,7 +43,7 @@ if [ -b /dev/nvme1n1 ] ; then
2643 exit 1
2744 fi
2845else
29- growpart /dev/nvme0n1 2
30- resize2fs /dev/nvme0n1p2
46+ growpart /dev/nvme0n1 " ${ROOT_PARTITION_NUMBER} "
47+ resize2fs " /dev/nvme0n1p ${ROOT_PARTITION_NUMBER} "
3148fi
3249echo " Done resizing disk"
You can’t perform that action at this time.
0 commit comments