LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 02-22-2016, 08:41 PM   #1
skender1234
LQ Newbie
 
Registered: Feb 2016
Posts: 3

Rep: Reputation: Disabled
LFS 7.8 Setting up grub to boot from flash drive


Hallo guys,

I built LFS 7.8 completely on a flash drive without any problems. Those only occur as I get to the booting part. I'm not quite sure what to write to the grub.cfg as my drive (sda, sdb...) changes whenever I plug the flash drive into another hardware configuration.

Code:
set root=(hd0,2) // what should I set here?

menuentry "GNU/Linux, Linux 4.2-lfs-7.8" {
        linux   /boot/vmlinuz-4.2-lfs-7.8 root=/dev/sda2 ro //and here for sda2
}
When I try to boot from usb I only get the grub commandline. I managed to boot the system by issuing:

Code:
set root=(hd0,1)
linux /boot/vmlinuz... root=/dev/sdb1 ??
boot
if the root (/dev/sdb1 here) is nonexistent boot fails. If it exists some boot messages appear but after about two seconds there is some kernel panic and the only thing I can see is the end of a stack trace.

I would be very grateful if someone could help me here. Even telling where to find the boot log would be very helpful. I looked in /var/log but all the files are empty :/

Thanks in advance.
 
Old 02-23-2016, 04:02 PM   #2
stoat
Member
 
Registered: May 2007
Distribution: LFS
Posts: 615

Rep: Reputation: 180Reputation: 180
Here are the things that I do in order to boot my BLFS system from an external USB drive...

1. Compile a kernel to build in USB support (for core, port, and storage drivers) and initial RAM filesystem support (for booting with UUID or LABEL).
a. USB support...
Code:
...[*] USB support ---> (CONFIG_USB_SUPPORT=y)
        |
        |...<*> Support for Host-side USB (CONFIG_USB=y)
        |...<*> EHCI HCD (USB 2.0) support (CONFIG_USB_EHCI_HCD=y)
	|...<*> Generic EHCI driver for a platform device (CONFIG_USB_EHCI_HCD_PLATFORM=y)
        |...<*> OHCI HCD (USB 1.1) support (CONFIG_USB_OHCI_HCD=y)
        |...<*>   OHCI support for PCI-bus USB controllers (CONFIG_USB_OHCI_HCD_PCI=y)
        |...<*>   Generic OHCI driver for a platform device (CONFIG_USB_OHCI_HCD_PLATFORM=y)
        |...<*> UHCI HCD (most Intel and VIA) support (CONFIG_USB_UHCI_HCD=y)
        |...<*> USB Mass Storage support (CONFIG_USB_STORAGE=y)
NOTE: The HCD port drivers usually are EHCI for high-speed USB plus either OHCI or UHCI for a fallback to legacy USB.
b. SCSI device support (CONFIG_SCSI) also should be built in (required by USB support)...
Code:
...    SCSI device support --->
        |
        |...-*- SCSI device support (CONFIG_SCSI=y)
        |...<*> SCSI disk support (CONFIG_BLK_DEV_SD=y)
        |...<*> SCSI CDROM support (CONFIG_BLK_DEV_SR=y)
        |...<*> SCSI generic support (CONFIG_CHR_DEV_SG=y)
c. Initial RAM filesystem and RAM disk support...
Code:
....General setup --->
     |
     |...[*]Initial RAM filesystem and RAM disk (initramfs/initrd) support (CONFIG_BLK_DEV_INITRD=y)

...Device Drivers --->
     |
     |...[*] Block devices ---> (CONFIG_BLK_DEV=y)
              |
              |...<*> RAM block device support (CONFIG_BLK_DEV_RAM=y)
              |...(16)   Default number of RAM disks (CONFIG_BLK_DEV_RAM_COUNT=<integer>) 
              |...(4096) Default RAM disk size (kbytes) (CONFIG_BLK_DEV_RAM_SIZE=<integer>)
2. Use UUIDs or LABELs for partitions instead of device names which may not be consistent (as you found out).
NOTE: See the swaplabel command for finding or changing a swap partition’s UUID. If swaplabel or Gparted fail work for setting a label or UUID for the swap partition, then use mkswap to recreate the swap area with the -L option to set a label which also will assign a UUID to the new swap partition.
3. Boot the system in the usual way with GRUB 2 but add the kernel parameter rootdelay=5 to avoid a kernel panic caused by the slower response of the USB drive.

4. To boot the USB system directly from the BIOS splashscreen menu (instead of from another system's GRUB), install GRUB in the master boot record of the USB drive in the usual way with grub-install. Edit the USB system’s grub.cfg file for the root filesystem and to add the rootdelay kernel parameter. To boot with UUID or LABEL (a good idea with a hot-plugable USB drive), see the BLFS book chapter on initial RAM filesystems, creating the initrd image file, and editing grub.cfg for the initrd command line. Also replace the typical set root command line with a search command line that uses UUID. My current example...
Code:
# Begin /boot/grub/grub.cfg

set default=0
set timeout=5

menuentry “Linux From Scratch” {
insmod search_fs_uuid
search --no-floppy --fs-uuid --set=root 98790171-5ab5-45c6-9764-096c056918cf
linux /boot/vmlinuz root=UUID=98790171-5ab5-45c6-9764-096c056918cf ro rootfstype=ext4 rootdelay=5
initrd /boot/initrd.img
}

# End /boot/grub/grub.cfg
This stuff is from my notes. The actual locations and/or wording of the kernel config stuff may have changed some, but the idea is still valid.
 
Old 02-23-2016, 04:59 PM   #3
skender1234
LQ Newbie
 
Registered: Feb 2016
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks for the fast reply, I will try that.
 
Old 02-23-2016, 06:01 PM   #4
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
set root=(hd0,2) // what should I set here?
I have gotten better results with "set root=(hd0,msdos2)"

Quote:
menuentry "GNU/Linux, Linux 4.2-lfs-7.8" {
linux /boot/vmlinuz-4.2-lfs-7.8 root=/dev/sda2 ro //and here for sda2
Here you can change "root=/dev/sda2" to "root=UUID=a2cd308e-2307-4bb4-8382-b54b792b8a79"
(edit for the correct UUID number.)

Last edited by TxLonghorn; 02-23-2016 at 06:05 PM.
 
Old 02-23-2016, 09:53 PM   #5
skender1234
LQ Newbie
 
Registered: Feb 2016
Posts: 3

Original Poster
Rep: Reputation: Disabled
I have not looked into BLFS so far but the "rootfstype=ext4 rootdelay=5" seems to resolve my issue right now. I am still stuck with /dev paths at the moment but it is finally booting. Thanks all. This can be closed/marked solved.
 
Old 02-24-2016, 05:50 PM   #6
stoat
Member
 
Registered: May 2007
Distribution: LFS
Posts: 615

Rep: Reputation: 180Reputation: 180
Quote:
Originally Posted by skender1234

I have not looked into BLFS so far but the "rootfstype=ext4 rootdelay=5" seems to resolve my issue right now.
Well, okay. But those two don't do anything about the original issue of unpredictable USB drive enumeration. Your system would boot normally without rootfstype=ext4, but having it shaves a second off of booting by the kernel not having to figure out the filesystem. The rootdelay=5 parameter really is important to boot a system on a USB drive. Different values for it can be used or may be necessary. I started with 10 and settled on 5 without trying to push it farther.

Anyway, if you ever want to boot the USB system with UUIDs or LABELs to avoid the drive enumeration issue, just read the BLFS section "About initramfs". It's easy to create an initial ram filesystem following those instructions. You have to install cpio (easy, no dependencies). Then install the two scripts found there and run the mkinitramfs command as described. I have a BLFS system on a USB drive that boots directly from BIOS, often with other USB drives also running. So I need this UUID business to boot it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] LFS 7.1 First Boot, grub error engineer Linux From Scratch 33 01-14-2013 08:27 PM
Setting up the boot process problem using GRUB on an LFS system! linuxpicaxe Linux From Scratch 1 03-07-2011 05:12 AM
Booting LFS from a USB flash drive LinuxNewman Linux - Newbie 3 08-04-2009 07:04 AM
Setting password on grub, wha to do after changing default values in /boot/grub/menu. sarajevo Linux - Security 1 08-17-2005 09:01 PM
Boot LFS with Grub darkmage Linux From Scratch 2 08-20-2002 01:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 05:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration