changing disk type check

update code with case statement...
This commit is contained in:
Albercoin 2023-01-10 07:15:51 +01:00 committed by GitHub
parent a032f5c9c9
commit e03f33c4c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,12 +64,23 @@ if [ ! -f /var/lib/mynode/.expanded_rootfs ]; then
X86_ROOT_PARTITION="$(mount | grep ' / ' | cut -d ' ' -f1)"
X86_DEVICE="$(lsblk -no pkname $X86_ROOT_PARTITION)"
X86_DEVICE_PATH="/dev/$X86_DEVICE"
case "$X86_DEVICE" in
sd* | hd* | vd*)
# SATA
X86_PARTITION_NUMBER=$(cat /proc/partitions | grep -c "${X86_DEVICE}[0-9]")
;;
nvme*)
# NVMe
X86_PARTITION_NUMBER=$(cat /proc/partitions | grep -c "${X86_DEVICE}p[0-9]")
;;
esac
if [ $X86_DEVICE = "sda" ]; then
# SATA
X86_PARTITION_NUMBER=$(cat /proc/partitions | grep -c "${X86_DEVICE}[0-9]")
else
# NVMe
X86_PARTITION_NUMBER=$(cat /proc/partitions | grep -c "${X86_DEVICE}p[0-9]")
fi
X86_FDISK_TYPE=$(fdisk -l "$X86_DEVICE_PATH" | grep "Disklabel")
echo "Root Partition: $X86_ROOT_PARTITION"