File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
ansible/files/admin_api_scripts Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change 21
21
# We currently mount 3 possible disks
22
22
# - /dev/xvda (root disk)
23
23
# - /dev/xvdh (data disk)
24
- # - /dev/xvdp (upgrade data disk)
24
+ # - /dev/xvdp (upgrade data disk), not used here
25
25
# Initialize variables at 20.04 levels
26
26
XVDA_DEVICE=" /dev/nvme0n1"
27
27
XVDH_DEVICE=" /dev/nvme1n1"
40
40
41
41
echo " Using devices - Root: $XVDA_DEVICE , Data: $XVDH_DEVICE "
42
42
43
- # Parses the output of lsblk to get the root partition number
44
- # Example output:
45
- # NAME MOUNTPOINT
46
- # nvme0n1
47
- # ├─nvme0n1p1 /boot
48
- # └─nvme0n1p3 /
49
- # nvme1n1 /data
50
- #
51
- # Resulting in:
52
- # └─nvme0n1p3 / -> nvme0n1p3 -> 3
53
- ROOT_PARTITION_NUMBER=$( lsblk -no NAME,MOUNTPOINT | grep ' /$' | awk ' {print $1;}' | sed ' s/.*nvme[0-9]n[0-9]p//g' )
43
+ # Get root partition using findmnt
44
+ ROOT_DEVICE_FULL=$( findmnt -no SOURCE /)
45
+ ROOT_DEVICE=$( lsblk -no PKNAME " $ROOT_DEVICE_FULL " )
46
+ ROOT_PARTITION_NUMBER=$( echo " $ROOT_DEVICE_FULL " | sed " s|.*${ROOT_DEVICE} p||" )
54
47
55
48
if ! [[ " $ROOT_PARTITION_NUMBER " =~ ^[0-9]+$ ]]; then
56
49
echo " Error: ROOT_PARTITION_NUMBER is not a valid number: $ROOT_PARTITION_NUMBER "
You can’t perform that action at this time.
0 commit comments