I'm building the LFS systemd development version, and having some
difficulty deciding how to configure some UEFI things.
I'm using GPT partitions and LVM (Logical Volume Management).
I know I'm a glutton for punishment with what I'm doing, but I want to
learn by doing.
At this point I'm trying to figure out how to install Linux-5.4.8 in the
boot partition, along with the boot manager rEFInd from RodsBooks. I'm
following the instructions in the hint
http://linuxfromscratch.org/hints/downloads/files/lfs-uefi.txt by Dan
McGhee, which has been most helpful. I think I understand everything up
until the section EFIBOOTMGR-16. This says:
#########
Compile the package:
make EFIDIR=LFS EFI_LOADER=grubx64.efi
The meaning of the make parameters:
* `EFIDIR=LFS`: This is the distro's subdirectory name under
`/boot/efi/EFI`. `Make.default` file of `efibootmgr` need this variable
to be set.
#########
After running efibootmgr, these directories appeared:
/boot/efi/EFI/LFS
/boot/efi/EFI/LFS/grubx64.efi
I've installed the following packages, which all seem to work ok:
efivar-37
efibootmgr-16
unifont-12.1.03
grub-2.04
gnu-efi-3.0.11
refind-0.11.4
Next the hint says:
#########
MODIFICATION OF /etc/fstab
When constructing `/etc/fstab` in LFS chapter 8, add a line to
mount EFI partition:
/dev/<name of EFI partition> /boot/efi vfat defaults
0 1
Systemd would mount `efivarfs` automatically. If using sysvinit,
add another line to mount `efivarfs`:
efivarfs /sys/firmware/efi/efivars efivarfs defaults 0 1
Notes:
a) If you are going to be booting your UEFI-aware LFS system using a
non-LFS GRUB from your host AND if that GRUB is one (eg Fedora)
that allows for the kernel to be specified using that GRUB's
`linuxefi` attribute, so
linuxefi /path/to/kernel root=/path/to/root ro
then you don't appear to need the `/etc/fstab` line, and indeed,
you'll get told during the boot that the mounter knows nothing
about the efivars filesystem type. However, LFS's efibootmgr will
still be capable of interrogating your UEFI environment.
b) If the LFS system is booted from the LFS+Hint's grub, which doesn't
appear to know about the "linuxefi" attribute so using
linux /path/to/kernel root=/path/to/root ro
then, unless you have the efivars filesystem mounted, and you are
able to, then LFS's efibootmgr will be **not** capable of interrogating
your UEFI environment, and you'll be told that there is no `efivars`
filesystem.
#########
I've had trouble with the "efivarfs" stuff in builds years ago. In
particular, is the line in /etc/fstab necessary or not? I think it is
necessary in my system, partly because efibootmgr (running in the chroot
environment) gives an error complaining about "efivars not defined"
without it. But when I mount an efi directory like so (the stuff below
is all run from the host system, not in the chroot environment):
mkdir -pv /sys/firmware/efi/efivars
mount -t efivars efivars /sys/firmware/efi/efivars
efibootmgr runs ok and seems to give reasonable output.
At this point, this is my proposed (as yet incomplete) /etc/fstab for LFS:
(lfs chroot) root:/sources# cat /etc/fstab
# Begin /etc/fstab
# file system mount-point type options dump fsck order
# Per hint
http://www.linuxfromscratch.org/hints/downloads/files/lfs-uefi.txt
/dev/sdb1 /boot/efi vfat defaults 0 1
/dev/mapper/lfslvm-root / ext4 defaults 1 1
PARTLABEL="EFI System" /boot efivarfs defaults 1 2
efivarfs /sys/firmware/efi/efivars efivarfs defaults 0 1
/dev/mapper/lfslvm-home /home ext4 defaults 1 2
/dev/mapper/lfslvm-opt /opt ext4 defaults 1 2
/dev/sdb2 none swap pri=1 0 0
# End /etc/fstab
At the moment I have three hard drives:
/dev/sda and /dev/sdc have Fedora 31 installed.
/dev/sdb has LFS partially installed.
Here is what fdisk -l partially reports, with my partition names added:
[root@localhost alan]# fdisk -l
Disk /dev/sda: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: WDC WD10EARX-00N
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: C12FAAB7-2CE2-4B31-A0DA-E3D56F4447B0
Device Start End Sectors Size Type
/dev/sda1 2048 1230847 1228800 600M EFI System
/dev/sda2 1230848 3327999 2097152 1G Linux filesystem
/dev/sda3 3328000 1953523711 1950195712 929.9G Linux LVM
Disk /dev/sdb: 3.65 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: Hitachi HUS72404
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F3A011B5-1584-48BE-A0A8-3111D4A0A27A
Device Start End Sectors Size Type
/dev/sdb1 2048 2099199 2097152 1G EFI System /boot/efi
/dev/sdb2 2099200 69208063 67108864 32G Linux swap swap
/dev/sdb3 69208064 71305215 2097152 1G Linux LVM /boot
/dev/sdb4 71305216 490735615 419430400 200G Linux LVM /root
/dev/sdb5 490735616 2638219263 2147483648 1T Linux LVM /opt
/dev/sdb6 2638219264 7814037134 5175817871 2.4T Linux LVM /home
I appear to have the LVM stuff set up properly. I see this report from
lvscan:
[root@localhost alan]# lvscan
ACTIVE '/dev/fedora_localhost-live/swap' [<15.68 GiB] inherit
ACTIVE '/dev/fedora_localhost-live/home' [1.73 TiB] inherit
ACTIVE '/dev/fedora_localhost-live/root' [70.00 GiB] inherit
ACTIVE '/dev/lfslvm/boot' [1020.00 MiB] inherit
ACTIVE '/dev/lfslvm/root' [<200.00 GiB] inherit
ACTIVE '/dev/lfslvm/opt' [<1024.00 GiB] inherit
ACTIVE '/dev/lfslvm/home' [2.41 TiB] inherit
ACTIVE '/dev/fedora_localhost-live00/swap' [<15.68 GiB]
inherit
ACTIVE '/dev/fedora_localhost-live00/home' [844.24 GiB]
inherit
ACTIVE '/dev/fedora_localhost-live00/root' [70.00 GiB] inherit
Partial lsblk report:
[root@localhost alan]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 929.9G 0 part
├─fedora_localhost--live00-root 253:0 0 70G 0 lvm /
├─fedora_localhost--live00-swap 253:1 0 15.7G 0 lvm [SWAP]
└─fedora_localhost--live00-home 253:9 0 844.2G 0 lvm /home
sdb 8:16 0 3.7T 0 disk
├─sdb1 8:17 0 1G 0 part
/mnt/lfs/boot/efi
├─sdb2 8:18 0 32G 0 part [SWAP]
├─sdb3 8:19 0 1G 0 part
│ └─lfslvm-boot 253:2 0 1020M 0
lvm /mnt/lfs/boot
├─sdb4 8:20 0 200G 0 part
│ └─lfslvm-root 253:5 0 200G 0 lvm /mnt/lfs
├─sdb5 8:21 0 1T 0 part
│ └─lfslvm-opt 253:7 0 1024G 0
lvm /mnt/lfs/opt
└─sdb6 8:22 0 2.4T 0 part
└─lfslvm-home 253:8 0 2.4T 0
lvm /mnt/lfs/home
Partial blkid report:
[root@localhost alan]# blkid
/dev/sda1: UUID="8E60-74C2" TYPE="vfat" PARTLABEL="EFI System Partition"
PARTUUID="fbbbce2d-3897-4bd3-adac-f783ed37b7c6"
. . .
/dev/sdb1: LABEL_FATBOOT="efi-boot" LABEL="efi-boot" UUID="000A-CAC9"
TYPE="vfat"
PARTLABEL="EFI System" PARTUUID="3ae2214c-3cf6-4324-80cf-a01741ccbccc"
/dev/sdb2: UUID="b8f31948-4901-4bb1-8767-88ce85e85901" TYPE="swap"
PARTLABEL="Linux swap" PARTUUID="95243fac-02a5-428a-9439-ff87c21aef94"
/dev/sdb3: UUID="VzWWbo-7FXe-LfrH-vMkK-ewze-y0kQ-vFV395" TYPE="LVM2_member"
PARTLABEL="Linux LVM" PARTUUID="b0ce9087-639c-4487-97dc-5c947aec3603"
/dev/sdb4: UUID="u3BU8P-G1GU-FqWS-sm2q-5xpe-tvUb-68s3zX" TYPE="LVM2_member"
PARTLABEL="Linux LVM" PARTUUID="35e97922-0128-453a-afbf-3f0dd75d98b2"
/dev/sdb5: UUID="DCkgSf-U1qX-BW40-F0PU-e242-PPEX-pBeltJ" TYPE="LVM2_member"
PARTLABEL="Linux LVM" PARTUUID="81d5edc5-bb8e-4988-9712-fee2dcf6277a"
/dev/sdb6: UUID="cIMB9D-7hMS-D83c-iaQ7-30J6-ljwQ-9mUs6y" TYPE="LVM2_member"
PARTLABEL="Linux LVM" PARTUUID="9a778bca-1ff6-4102-9b0e-b7bb7d8efd5b"
/dev/mapper/lfslvm-boot: UUID="08122b74-5c84-4aa5-947e-0d2952db1ecd"
TYPE="ext4"
/dev/mapper/lfslvm-root: UUID="f7309704-012d-4115-884d-403c6e06a989"
TYPE="ext4"
/dev/mapper/lfslvm-opt: UUID="50721ec6-829c-479d-87a4-8137d55d48b9"
TYPE="ext4"
/dev/mapper/lfslvm-home: UUID="082522d2-8c0d-4485-84a9-7226f174753c"
TYPE="ext4"
/dev/mapper/fedora_localhost--live00-root:
UUID="fe32922f-33b4-405d-9c30-d50708d92965" TYPE="ext4"
/dev/mapper/fedora_localhost--live00-swap:
UUID="1541243b-0c58-4200-b315-36f45a7dab98" TYPE="swap"
/dev/mapper/fedora_localhost--live00-home:
UUID="9ec87640-aba4-4e28-afb5-13042d4d644b" TYPE="ext4"
Here is what is in the various /boot directories:
(lfs chroot) root:/boot# ll
total 17012
-rw-r--r-- 1 root root 5293922 Jan 12 10:52 System.map-5.4.8
-rw-r--r-- 1 root root 131991 Jan 12 10:53 config-5.4.8
drwxr-xr-x 3 root root 4096 Dec 31 1969 efi
drwxr-xr-x 4 root root 4096 Jan 13 11:35 grub
drwx------ 2 root root 16384 Jan 2 14:26 lost+found
-rw-r--r-- 1 root root 511 Jan 10 20:38 refind_linux.conf
-rw-r--r-- 1 root root 11957120 Jan 12 10:51
vmlinuz-5.4.8-lfs-20200109-systemd
(lfs chroot) root:/boot/grub# ll
total 24
drwxr-xr-x 2 root root 4096 Jan 10 14:04 fonts
-rw-r--r-- 1 root root 808 Jan 13 11:35 grub.cfg
-rw-r--r-- 1 root root 1024 Jan 10 14:04 grubenv
drwxr-xr-x 2 root root 12288 Jan 10 14:04 x86_64-efi
(lfs chroot) root:/boot/grub# cat grub.cfg
# Begin /boot/grub/grub.cfg
set default=0
set timeout=5
insmod gzio
insmod part_gpt
insmod ext2
# set root=(hd1, gpt1)
set root=3ae2214c-3cf6-4324-80cf-a01741ccbccc
# set root=(lvm/lfslvm-boot)
insmod efi_gop
insmod efi_uga
insmod font
if loadfont /boot/grub/fonts/unicode.pf2; then
loadfont /boot/grub/fonts/unicode.pf2
set gfxmode=auto
insmod gfxterm
set gfxpayload=keep
terminal_output gfxterm
fi
menuentry "GNU/Linux, Linux vmlinuz-5.4.8-lfs-20200109-systemd" {
# linux /vmlinuz-5.4.8-lfs-20200109-systemd root=/dev/sdb4 ro
linux /vmlinuz-5.4.8-lfs-20200109-systemd
root=35e97922-0128-453a-afbf-3f0dd75d98b2 ro
}
EOF
I've been playing around with the "set root=..." and "linux ...
root=..." lines.
(lfs chroot) root:/boot/efi# ll
total 17508
drwxr-xr-x 5 root root 4096 Jan 10 20:38 EFI
-rwxr-xr-x 1 root root 5293922 Jan 12 10:40 System.map-5.4.8
-rwxr-xr-x 1 root root 131991 Jan 12 10:40 config-5.4.8
-rwxr-xr-x 1 root root 530336 Jan 10 14:04 grub.log
-rwxr-xr-x 1 root root 11957120 Jan 12 10:40
vmlinuz-5.4.8-lfs-20200109-systemd
(lfs chroot) root:/boot/efi/EFI# ll
total 12
drwxr-xr-x 2 root root 4096 Jan 10 14:04 LFS
drwxr-xr-x 5 root root 4096 Jan 13 11:37 refind
drwxr-xr-x 2 root root 4096 Jan 10 20:38 tools
(lfs chroot) root:/boot/efi/EFI#
(lfs chroot) root:/boot/efi/EFI/LFS# ll
total 148
-rwxr-xr-x 1 root root 151552 Jan 10 14:04 grubx64.efi
(lfs chroot) root:/boot/efi/EFI/refind# ll
total 316
-rwxr-xr-x 1 root root 140 Jan 10 20:38 BOOT.CSV
drwxr-xr-x 2 root root 4096 Jan 10 20:38 drivers_x64
drwxr-xr-x 4 root root 8192 Jan 10 20:38 icons
drwxr-xr-x 2 root root 4096 Jan 10 20:38 keys
-rwxr-xr-x 1 root root 31856 Jan 13 11:19 refind.conf
-rwxr-xr-x 1 root root 268787 Jan 10 20:38 refind_x64.efi
Configuration for rEFInd:
(lfs chroot) root:/boot/efi/EFI/refind# cat refind.conf
#
# refind.conf
# Configuration file for the rEFInd boot menu
#
. . .
# Alan's first try:
menuentry Linux-LFS-foooo {
icon EFI/refind/icons/os_linux.png
volume efi-boot
loader /vmlinuz-5.4.8-lfs-20200109-systemd
# options "ro root=(hd1,gpt4)"
# options "ro root=/dev/sdb4"
options "ro root=35e97922-0128-453a-afbf-3f0dd75d98b2
}
With rEFInd installed and running ok, upon bootup it gives me a number
of boot choices in its menu. There are three relevant to booting LFS:
Boot vmlinuz-5.4.8-lfs-20200109-systemd from efi-boot
Boot Linux-LFS-foooo from efi-boot
Boot EFI\LFS\grubx64.efi from efi-boot
The last Boot entry eventually puts out an error message:
error: disk '3ae2214c-3cf6-4324-80cf-a01741ccbccc' not found
which clearly refers to the line:
set root=3ae2214c-3cf6-4324-80cf-a01741ccbccc
in the above grub.cfg file.
After a short delay it gets to a GRUB command line program, which allows
you to boot to:
"*GNU/Linux, Linux vmlinuz-5.4.8-lfs-20200109-systemd"
and which has options to enter "'e' to edit the commands before booting
or 'c' for a command-line. Hitting 'e' gets you to another window that
displays:
######
setparams 'GNU/Linux, Linux vmlinuz-5.4.8-lfs-20200109-systemd'
linux /vmlinuz-5.4.8-lfs-20200109-systemd
root=35e97922-0128-453a-afbf-3f0dd75d98b2 ro
######
The line "/vmlinuz ... root=35e..." clearly refers to the line in the
grub.cfg file.
So grub is definitely reading the above grub.cfg file.
The first Boot line above results in a partial bootup, with this error
message:
######
VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
Please append a correct "root=" boot option; here are the available
partitions:
. . .
/dev/sdb1 3ae2214c-3cf6-4324-80cf-a01741ccbccc
/dev/sdb2 95243fac-02a5-428a-9439-ff87c21aef94
/dev/sdb3 b0ce9007-639c-4487-97dc-5c947aec3603
/dev/sdb4 35e97922-0128-453a-afbf-3f0dd75d98b2
. . .
Kernel panic - not syncing: VFS: Unable to mount root fs on
unknown-block(0,0)
. . .
######
The device ID's correspond to the above blkid listing.
The second Boot line above results in a partial bootup, with a similar
error message:
######
VFS: Cannot open root device "35e97922-0128-453a-afbf-3f0dd75d98b2" or
unknown-block(0,0): error -6
. . .
######
This appears to be from the above-listed refind.conf file.
At this point I don't know what to do. I've tried a variety of changes
to the various configuration files. I've read a lot of material in the
LFS material, and on the Net, without success.
Help!
Alan
--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page
Do not top post on this list.
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
http://en.wikipedia.org/wiki/Posting_style