I had almost finished Linux From Scratch ; However, when I tried to started the new LFS system. GRUB couldn't launch the system:
error: disk `(hd0,)' not found.
Then I used grub> ls
Output: (hd0) (hd0, gpt4) (hd0, gpt3) (hd0, gpt2) (hd0, gpt1)
I followed the instructions without anything too special, except for that I used GRUB with UEFI because my host system had been using UEFI and GPT.
Here's the partition table:
- /dev/sda GPT
- /dev/sda1: 512MB in size. EFI system partition. FAT32
- /dev/sda2: 16GB in size. Linux swap. [SWAP]
- /dev/sda3: 64GB in size. Linux x86_64 root. ext4. Host system.
- /dev/sda4: 32GB in size. Linux x86_64 root. ext4. LFS system. I install grub in sda1. The file tree in sda1 is like:
.
├── config-5.16.9
├── EFI
│ └── LFS
│ └── grubx64.efi
├── grub
│ ├── fonts
│ ├── grub.cfg
│ ├── grubenv
│ ├── i386-pc
│ ├── locale
│ │ ├── ast.mo
│ │ ├── ca.mo
│ │ ├── ...
│ │ └── zh_TW.mo
│ └── x86_64-efi
│ ├── acpi.mod
│ ├── ...
│ └── zstd.mod
├── System.map-5.16.9
└── vmlinuz-5.16.9-lfs-11.1-systemd
And the content of grub.cfg
:
set default=0
set timeout=5
insmod part_gpt
insmod vfat # I've tried fat here.
set root=(hd0) #I've tried (hd0,gpt1), (hd0,gpt4), (hd0,1) .etc here.
if loadfont /boot/grub/fonts/unicode.pf2; then
set gfxmode=auto
insmod all_video
terminal_output gfxterm
fi
menuentry "GNU/Linux, Linux 5.16.9-lfs-11.1"{
linux /boot/vmlinuz-5.16.9-lfs-11.1 root=/dev/sda4 ro
}
menuentry "Firmware Setup"{
fwsetup
}
I mainly followed these references:
Also, I had set to use UEFI without CSM support or legacy.
More details:
- GRUB version 2.06
- LFS version 11.1-systemd
- Linux kernel version 5.16.9
- Secure boot disabled