]> gitweb.fluxo.info Git - hydra.git/commitdiff
Fix: provision: UEFI/BIOS cleanup
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 25 Jan 2022 13:17:08 +0000 (10:17 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 25 Jan 2022 13:17:08 +0000 (10:17 -0300)
share/hydractl/provision

index b5f23ceb7bc9ad3591a4c3a0a71969eb21bf829c..8a154627241968db99cc607de2e1766a6c81c8ef 100755 (executable)
@@ -258,14 +258,16 @@ else
   start="$((($optimal_size + $alignment_offset) / $block_size))"
   optimal_sector_size="$(($optimal_size / $block_size))"
 
-  # Sector size for a 1MB partition, BIOS mode
-  bios_grub_size="$(($mebibyte/$block_size))"
-  bios_grub_end="$(($start + $bios_grub_size - 1))"
-
-  # Sector size for a 300MB partition, UEFI mode
-  # See https://wiki.archlinux.org/title/Parted#UEFI/GPT_examples
-  uefi_grub_size="$(($mebibyte/$block_size*300))"
-  uefi_grub_end="$(($start + $uefi_grub_size - 1))"
+  if [ "$boot_mode" == "bios" ]; then
+    # Sector size for a 1MB partition, BIOS mode
+    grub_size="$(($mebibyte/$block_size))"
+    grub_end="$(($start + $grub_size - 1))"
+  else
+    # Sector size for a 300MB partition, UEFI mode
+    # See https://wiki.archlinux.org/title/Parted#UEFI/GPT_examples
+    grub_size="$(($mebibyte/$block_size*300))"
+    grub_end="$(($start + $grub_size - 1))"
+  fi
 
   # Regular disk partitioning.
   hydra_sudo_run parted -s -- $device mklabel gpt
@@ -276,15 +278,15 @@ else
     #     https://bugs.launchpad.net/ubuntu/+source/parted/+bug/1270203
     #     https://techtitbits.com/2018/12/using-parteds-resizepart-non-interactively-on-a-busy-partition/
     #     https://serverfault.com/questions/870594/resize-partition-to-maximum-using-parted-in-non-interactive-mode
-    #hydra_sudo_run parted -s ---pretend-input-tty -- $device mkpart non-fs ${start}s ${bios_grub_end}s Yes
-    #hydra_sudo_run parted $device mkpart non-fs ${start}s ${bios_grub_end}s Yes Ignore quit
+    #hydra_sudo_run parted -s ---pretend-input-tty -- $device mkpart non-fs ${start}s ${grub_end}s Yes
+    #hydra_sudo_run parted $device mkpart non-fs ${start}s ${grub_end}s Yes Ignore quit
     #hydra_sudo_run parted -s ---pretend-input-tty $device <<EOF
-#mkpart non-fs ${start}s ${bios_grub_end}s
+#mkpart non-fs ${start}s ${grub_end}s
 #Yes
 #Ignore
 #quit
 #EOF
-    hydra_sudo_run parted -s -- $device mkpart non-fs ${start}s ${bios_grub_end}s
+    hydra_sudo_run parted -s -- $device mkpart non-fs ${start}s ${grub_end}s
 
     # Se GRUB flag
     hydra_sudo_run parted -s -- $device set 1 bios_grub on
@@ -293,7 +295,7 @@ else
 
     hydra_install_package dosfstools
 
-    hydra_sudo_run parted -s -- $device mkpart fat32 ${start}s ${uefi_grub_end}s
+    hydra_sudo_run parted -s -- $device mkpart fat32 ${start}s ${grub_end}s
     hydra_sudo_run parted -s -- $device set  1 esp on
     hydra_sudo_run parted -s -- $device name 1 ESP
     hydra_sudo_run mkfs.vfat $esp_device
@@ -305,12 +307,8 @@ else
   if [ "$encrypt" == "y" ]; then
     # Second partition must also be aligned by a multiple of $optimal_sector_size
     # So we find the minimum optimal start sector which is after the grub partition
-    if [ "$boot_mode" == "bios" ]; then
-      #lvm_start="$(($bios_grub_end + 1))"
-      lvm_start="`partition_sector_start $start $bios_grub_end $optimal_sector_size`"
-    else
-      lvm_start="`partition_sector_start $start $uefi_grub_end $optimal_sector_size`"
-    fi
+    #lvm_start="$(($grub_end + 1))"
+    lvm_start="`partition_sector_start $start $grub_end $optimal_sector_size`"
 
     #hydra_sudo_run parted -s -- $device unit MB mkpart ext2 3 -1
     hydra_sudo_run parted -s -- $device mkpart ext2 ${lvm_start}s -1
@@ -323,15 +321,9 @@ else
     syst_device="${device}${partition_separator}2"
   else
     # Make a 1024MB boot partition
-    #boot_start="$(($bios_grub_end + 1))"
+    #boot_start="$(($grub_end + 1))"
     boot_size="1024"
-
-    if [ "$boot_mode" == "bios" ]; then
-      boot_start="`partition_sector_start $start $bios_grub_end $optimal_sector_size`"
-    else
-      boot_start="`partition_sector_start $start $uefi_grub_end $optimal_sector_size`"
-    fi
-
+    boot_start="`partition_sector_start $start $grub_end $optimal_sector_size`"
     boot_size="$(($boot_size * $mebibyte / $block_size))"
     boot_end="$(($boot_start + $boot_size -1))"
     #lvm_start="$($boot_end + 1))"