Start Linux rootfs partition at 1M, not sector 1

This improves partition alignment, and therefore performance
on SSDs and AF (4K-sectored) HDDs. Also, it leaves some space
before the partition to allow installing GRUB.
This commit is contained in:
Googulator 2023-11-13 10:20:04 +01:00
parent a3f30a163c
commit 5bd1bad62e

View file

@ -69,7 +69,8 @@ fi
# shellcheck disable=SC2012 # shellcheck disable=SC2012
if [ $(($(ls -l "/dev/${DISK}" | sed "s/.*, *//" | sed "s/ .*//") % 8)) -eq 0 ]; then if [ $(($(ls -l "/dev/${DISK}" | sed "s/.*, *//" | sed "s/ .*//") % 8)) -eq 0 ]; then
echo "Creating partition table..." echo "Creating partition table..."
echo ";" | sfdisk "/dev/${DISK}" # Convince our ancient sfdisk to align to megabytes, not cylinders
echo "2048;" | sfdisk -uS -S32 -H64 "/dev/${DISK}"
fdisk -l "/dev/${DISK}" fdisk -l "/dev/${DISK}"
echo "Creating ext4 partition..." echo "Creating ext4 partition..."
mkfs.ext4 "/dev/${DISK}1" mkfs.ext4 "/dev/${DISK}1"