Home > Back-end >  Linux From Scratch (LFS) Cannot configure Grub correctly
Linux From Scratch (LFS) Cannot configure Grub correctly

Time:02-19

I am trying to build my first LFS (8.4 SystemD), but I'm not able to write a correct grub.cfg file.

Context

  • My Host OS is a Debian 10 (64bits) running on Virtualbox, its mounted on /dev/sda. Main vdi virtual drive, plugged into SATA0
  • My LFS system has been built on /dev/sdb, another VDI virtual drive plugged into SATA1.

LFS partitions

name mount location (host) LFS mount location type size
/dev/sdb1 /mnt/lfs/boot /boot ext2 200M
/dev/sdb2 /mnt/lfs/ / ext4 20G
/dev/sdb3 Swap partition Swap partition swap 200M

Output of lsblk in my host system

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   15G  0 disk 
|-sda1   8:1    0    7G  0 part 
|-sda2   8:2    0    1K  0 part 
`-sda5   8:5    0    8G  0 part [SWAP]
sdb      8:16   0   25G  0 disk 
|-sdb1   8:17   0  200M  0 part /boot
|-sdb2   8:18   0   20G  0 part /
`-sdb3   8:19   0    2G  0 part [SWAP]
sr0     11:0    1 1024M  0 rom  
sr1     11:1    1  349M  0 rom 

output of fdisk -l /dev/sdb

Disk /dev/sdb: 25 GiB, 26843545600 bytes, 52428800 sectors
Disk model: VBOX HARDDISK   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 096D0D9B-FF26-3B41-8A1D-78D81EAD4D4C

Device        Start      End  Sectors  Size Type
/dev/sdb1      2048   411647   409600  200M Linux filesystem
/dev/sdb2    411648 42354687 41943040   20G Linux filesystem
/dev/sdb3  42354688 46548991  4194304    2G Linux filesystem

the partition label is GPT, while my VM is booting with BIOS

Current grub.cfg file.

# Begin /boot/grub/grub.cfg
set default=0
set timeout=5

insmod ext2
set root=(hd0,1)


menuentry "GNU/Linux, Linux 4.20.12-lfs-8.4-systemd-fherbine" {
        linux   /vmlinuz-4.20.12-lfs-8.4-systemd-fherbine root=/dev/sda1 ro
}

Note that after configuring this file, I'm supposed to reboot the VM and get rid of the VDI that contains my host debian, that's why it's hd0 (not hd1) & /dev/sda1 (not sdb1). But I might be wrong here.

Unfortunately, this configuration isn't working at all, when I arrived in the GRUB menu, and I press ENTER, I'm not able to boot: error: no such partition.

Do you have any idea what's going on ? :)

CodePudding user response:

https://wiki.archlinux.org/title/GRUB

And check hd*/sd* ids via lsblk

CodePudding user response:

I think I have an idea of what's going on:

  • My VitualBox VM boots with BIOS while my partition table is GPT.
  • Related