After a long thread on -support today I did a test build on a USB drive today. These are some observations.

The USB drive was /dev/sdg. I only had one partition on the MSDOS style partition table.

From the host I installed GRUB with
  grub-install /dev/sdg

To boot, I needed a grub.cfg file:

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

insmod ext2
set root=(hd0,1)

menuentry "GNU/Linux, vmlinuz-5.0-lfs-SVN-20190305" {
linux /boot/vmlinuz-5.0-lfs-SVN-20190305 rootdelay=10 root=/dev/sdg1 ro
}

When booting, I had to tell the system firmware (BIOS) to boot from the USB drive.

In grub.cfg the line

   set root=(hd0,1)

refers to GRUB's view of the system where it thinks the boot drive is hd0. This allows GRUB to find the kernel, load it and then start it.

The kernel, on the other hand, searches the entire system for hard drives and identifies them as it finds them. In my case I have six hard drives in the system. sda, sdb, sdc, sdd, sde, and sdf. The USB drive is thus identified as sdg. The linux boot line then requires

    root=/dev/sdg1 rootdelay=10

The rootdelay is needed so the system has time to find the USB drive, but /dev/sdg1 is needed for the kernel to find the root partition. The fstab file also needs the same drive designations as the kernel command line.

If this USB drive is inserted into another system with a different disk configuration, then these values will need to be changed. The workaround is to use UUID or PARTUUID designations. PARTUUID is only available on GPT partition tables [sic], but plain UUID requires an initrd to be created and loaded by GRUB.

  -- Bruce
--
http://lists.linuxfromscratch.org/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to