galeb

Једноставна статичка дистрибуција заснована на musl-у
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 29d33809fabdc61e9050a92cb33bd7ac4b7fee4b
родитељ b87980bb31d303e1e339ebbf8335ed6f2a5a6888
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Thu, 20 Apr 2023 16:57:20 +0200

BOOTING: Update to reflect switch to initramfs

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
MBOOTING | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
измењених датотека: 1, додавања: 64(+), брисања: 21(-)

diff --git a/BOOTING b/BOOTING @@ -15,7 +15,8 @@ two is used depends on your system. If you can run $ efibootmgr -v and it doesn't give an error message but a list of boot entries, then you have -UEFI. +UEFI. With Linux as kernel, a mounted efivarfs, usually at +/sys/firmware/efi/efivars, is also needed for the above command to work. Partition table type @@ -51,25 +52,41 @@ on the system root partition. This can be done in two ways: * By creating an initial root partition (initramfs) having a temporary init program, which if needed handles loading the necessary kernel modules - (drivers) to access the root partition. This method supports advanced - partition selection, for example by their UUIDs or PARTUUIDs, and doesn't + (drivers) to access the root partition. This method also supports advanced + partition selection, for example by their UUIDs or LABELs, and doesn't require the support for filesystem type of the root partition to be compiled - in the kernel. + into the kernel. initramfs is passed to EFISTUB through the kernel command + line: `initrd=\initramfs.img`, where the "root" directory is ESP. -* By specifying the root partition on the kernel command line (through a kernel - parameter), for example `root=/dev/sda2`. This is more minimal, as it doesn't - require initramfs, but prone to being unable to boot a system if the disk - configuration is changed, for example by plugging in a USB flash drive or - otherwise changing the order of the hard disks. Alternatively, partition can - be specified by PARTUUID, which uniquely identifies a partition on GPT - systems: `root=PARTUUID=...`. This is the recommended approach in Galeb. + Note that UEFI uses DOS filesystem path separator, backslash (\), + instead of a slash (/) used on Unix-like systems. + +* By compiling the necessary filesystem modules and storage device drivers into + the kernel and specifying the root partition on the kernel command line. This + is more minimal, as it doesn't require initramfs. However, advanced partition + selection by UUIDs and LABELs is not supported (but see below), and licenses + for "binary blobs" (drivers/modules) usually clash with the requirements of + GPL (which is the license of the kernel), preventing them from being compiled + in the kernel in such a way. That's why initramfs is the most used option, and + recommended in Galeb. In Galeb, there is a script mkinitramfs(8), which can be + used to generate initramfs. Refer to [5]. + +Partition can always be specified by a device pathname, such as +`root=/dev/sda2`, which can lead to boot failure if the storage device driver +(kernel module) is inaccessible or the disk configuration is changed. For +example, this can happen when plugging in a USB flash drive or physically +connecting hard drives to different cables, and rebooting, or otherwise changing +the order of hard disks. + +Partition on GPT systems can also be specified by PARTUUID, which uniquely +identifies a partition: `root=PARTUUID=...`. This is the recommended approach. Recommended setup in Galeb -------------------------- -The following is the basic recommended partition configuration in Galeb. It -assumes an UEFI/GPT system. +The following is the basic recommended partition configuration in Galeb on the +traditional SCSI drives. It assumes an UEFI/GPT system. Partition Mountpoint Filesystem Type Size -------------------------------------------------------------- @@ -81,10 +98,27 @@ include root=/dev/sda2 +or + + root=PARTUUID=[PARTUUID of /dev/sda2] + and that the ESP is in /dev/sda1, mounted later during the boot process to /boot. This is where the kernel stub should go into, and will later be accessible from the booted system at /boot/vmlinuz. +When the partition /dev/sda2 exists, its PARTUUID can be obtained with the +command + + $ lsblk -no PARTUUID /dev/sda2 + +NVME SSDs require the nvme and nvme_core kernel modules, and the partition +device pathnames usually become /dev/nvme0n1p1 and /dev/nvme0n1p2, respectively: + + Partition Mountpoint Filesystem Type Size + -------------------------------------------------------------- + /dev/nvme0n1p1 /boot vfat (32-bit) ~500MB + /dev/nvme0n1p2 / ext4 Rest + Creating a boot entry in efibootmgr ----------------------------------- @@ -92,8 +126,17 @@ Creating a boot entry in efibootmgr The necessary command line parameters will be briefly explained here. For more information, see `man 8 efibootmgr` and `efibootmgr -h`. + partuuid=$(lsblk -no PARTUUID /dev/sda2) efibootmgr -c -d /dev/sda -l '\vmlinuz' -L 'Galeb EFISTUB' -p1 \ - -u 'root=/dev/sda2 ro' + -u 'initrd=\initramfs.img root=PARTUUID='${partuuid}' ro' + + +Explanation +----------- + +partuuid=$(lsblk -no PARTUUID /dev/sda2) + Obtain the PARTUUID of /dev/sda2 and store it in the shell variable + `partuuid`. -c Create a new boot entry. @@ -101,9 +144,7 @@ information, see `man 8 efibootmgr` and `efibootmgr -h`. Disk on which the root partition is (boot disk). -l '\vmlinuz' - Boot loader (our EFISTUB) is in the file vmlinuz on ESP. UEFI uses DOS - filesystem path separator, backslash (\), instead of a slash (/) used on - Unix-like systems. + Boot loader (our EFISTUB) is in the file vmlinuz on ESP. -L 'Galeb EFISTUB' Label for the boot entry. @@ -112,8 +153,9 @@ information, see `man 8 efibootmgr` and `efibootmgr -h`. -u Treat the kernel command line as UCS-2. -'root=/dev/sda2 ro' - Kernel command line, quoted to prevent parsing by the shell. +'initrd=\initramfs.img root=PARTUUID='${partuuid}' ro' + Kernel command line, quoted to prevent parsing by the shell. Value of + the shell variable `partuuid` is inserted where needed. Boot image @@ -123,11 +165,11 @@ After the boot scripts have finished, you will be presented with a choice to create a boot image. The boot image will be compressed with xz and needs to be sent to a USB flash medium, for example: - # xz -dc galeb-2.2-x86_64-20220913.raw.xz > /dev/sdb + # xz -dc galeb-2.2-x86_64-20230417.raw.xz > /dev/sdb or, if you have pv[4]: - # xz -dc galeb-2.2-x86_64-20220913.raw.xz | pv > /dev/sdb + # xz -dc galeb-2.2-x86_64-20230417.raw.xz | pv > /dev/sdb _Be careful when specifying the device you send the output to, in order to not overwrite any existing partitions (your hard disk, etc)!_ You can find out the @@ -160,3 +202,4 @@ See also 2. https://wiki.archlinux.org/title/EFI_system_partition 3. https://wiki.archlinux.org/title/EFISTUB 4. http://www.ivarch.com/programs/pv.shtml +5. https://git.sr.ht/~strahinja/galeb-mkinitramfs/