]> gitweb.fluxo.info Git - hydra.git/commitdiff
Fix: hydractl: provision: set partition naming scheme
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 9 Jan 2022 13:57:40 +0000 (10:57 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 9 Jan 2022 13:57:40 +0000 (10:57 -0300)
share/hydractl/provision

index c3f46206f3611dd2e6e63537a5f0bbc728fe89a8..3176f218a1c6318cc2d77e9066a4df467e141895 100755 (executable)
@@ -189,6 +189,23 @@ fi
 # Check number of devices
 num_devices="`echo $device | wc -w`"
 
+# Set partition naming scheme
+#
+#   "Partition device names are a combination of the drive's device name and the
+#   partition number assigned to them in the partition table, i.e.
+#   /dev/drivepartition. For drives whose device name ends with a number, the
+#   drive name and partition number is separated with the letter "p", i.e.
+#   /dev/driveppartition."
+#
+#   -- https://wiki.archlinux.org/title/Device_file
+#
+#if echo $device | grep -q -E 'nvme|mmcblk'; then
+if echo $device | grep -q -E '[0-9]$'; then
+  partition_separator="p"
+else
+  partition_separator=""
+fi
+
 # RAID: do this instead of regular partitioning.
 if [ "$num_devices" != "1" ]; then
   # Force encryption and fix device name.
@@ -262,8 +279,8 @@ else
     hydra_sudo_run parted -s -- $device mkpart ext2 ${lvm_start}s -1
     hydra_sudo_run parted -s -- $device set    2    lvm on
 
-    boot_device="$device"2
-    syst_device="$device"2
+    boot_device="${device}${partition_separator}2"
+    syst_device="${device}${partition_separator}2"
   else
     # Make a 1024MB boot partition
     #boot_start="$(($bios_grub_end + 1))"
@@ -279,8 +296,8 @@ else
     hydra_sudo_run parted -s -- $device mkpart ext2 ${lvm_start}s -1
     hydra_sudo_run parted -s -- $device set    3    lvm on
 
-    boot_device="$device"2
-    syst_device="$device"3
+    boot_device="${device}${partition_separator}2"
+    syst_device="${device}${partition_separator}3"
   fi
 fi