rootn=1
swapn=2
bootn=3
+efin=4
# ext partition so grub can write persistent variables,
# so it can do a one time boot. grub can't write to
# btrfs or any cow fs because it's more
# more complicated to do and they don't want to.
-grub_extn=4
+grub_extn=5
# bios boot partition,
# https://wiki.archlinux.org/index.php/GRUB
-bios_grubn=5
+bios_grubn=6
lastn=$bios_grubn
bootdev() { add-part $@ $bootn; }
rootdev() { add-part $@ $rootn; }
swapdev() { add-part $@ $swapn; }
+efidev() { add-part $@ $efin; }
grub_extdev() { add-part $@ $grub_extn; }
bios_grubdev() { add-part $@ $bios_grubn; }
hdds=()
ssds=()
-cd /sys/block
-for disk in [sv]d[a-z]; do
+# this excludes usb. note: i may encounter some other type in the future.
+for disk in $(lsblk -do name,tran -n | awk '$2 ~ "^(sata|nvme)$" { print $1 }'); do
if [[ ${disk_excludes[$disk]} ]]; then
continue
fi
- case $(cat $disk/queue/rotational) in
+ case $(cat /sys/block/$disk/queue/rotational) in
0) ssds+=(/dev/$disk) ;;
1) hdds+=(/dev/$disk) ;;
*) echo "$0: error: unknown /sys/block/$disk/queue/rotational: \
boot_devs+=($(bootdev))
fi
if [[ $boot_devs && $first ]]; then
+ first_efi=$(efidev)
first_grub_extdev=$(grub_extdev)
first=false
fi
parted -s $dev mklabel gpt
# MiB because parted complains about alignment otherwise.
pcmd="parted -a optimal -s -- $dev"
- $pcmd mkpart primary ext3 12MiB ${root_end}MiB
+ $pcmd mkpart primary ext3 524MiB ${root_end}MiB
# without naming, systemd gives us misc errors like:
# dev-disk-by\x2dpartlabel-primary.device: Dev dev-disk-by\x2dpartlabel-primary.device appeared twice
$pcmd name $rootn root
$pcmd name $swapn swap
$pcmd mkpart primary "" ${swap_end}MiB ${disk_mib}MiB
$pcmd name $bootn boot
+ # eufi = bloated, half a gig gimme a break.
+ $pcmd mkpart primary "fat32" 12MiB 524MiB
+ $pcmd name $efin efi
+ $pcmd set $efin esp on
+ # note, this is shown here: https://support.system76.com/articles/bootloader/
+ # but not mentioned https://wiki.archlinux.org/index.php/EFI_system_partition
+ # probably not needed
+ $pcmd set $bootn boot on
# i only need a few k, but googling min size,
# I found someone saying that gparted required
# required at least 8 because of their hard drive cylinder size.
sleep 1
secs=$((secs +1))
done
+
+ mkfs.fat -F32 $(efidev)
+
# Holds just a single file, rarely written, so
# use ext2, like was often used for the /boot partition.
# This exists because grub can only persist data to a non-cow fs.
$first_root_crypt / btrfs noatime,subvol=root_$DISTRO$mopts 0 0
$first_root_crypt /mnt/root btrfs nofail,noatime,subvolid=0$mopts 0 0
$first_boot_dev /boot btrfs nofail,noatime,subvol=$boot_vol 0 0
+$first_efi /boot/efi vfat nofail 0 0
$first_boot_dev /mnt/boot btrfs nofail,noatime,subvolid=0 0 0
EOF
swaps=()