Booting Lfs-Version udev_update-20060301 from usb drive.
alessandro.alocci1 at tin.it
Fri Mar 17 18:30:57 PST 2006
Alle 00:15, sabato 18 marzo 2006, Alessandro Alocci ha scritto:
> Alle 20:56, giovedì 16 marzo 2006, randhir phagura ha scritto:
> > I intend booting the new lfs system from the host system. The host system
> > has hda (the main hard drive), hdc (the dvd-rom) and the IBM Microdrive
> > mounted on SanDisk adapter connected to USB port of the host. This drive
> > is configured as usb-storage in the kernel and host system recognises it
> > as'sda'. There is only one partition on this drive i.e. sda1. Grub is
> > installed on Microdrive but not setup on the MBR because I intend to boot
> > it from the host.
> > Is there a way to boot the new lfs from my host system grub?
> Well, if your BIOS is not able to recognize your usbdisk you can use an
> initrd (Initial RAM disk) to load the usb modules before you mount the real
> partition (sda1) and use the initrd option of grub.
> I have done this to boot a Fedora Core 3 on my laptop from an external
> usbdisk but I used a specific howto and mkinitrd for that distro, but I
> think it's possible to find a similar solution also for LFS.
> Try to document yourself about initrd
> (man initrd or less /usr/src/linux-`uname -r`/Documentation/initrd.txt)
> and search the net about how to boot linux from an usb storage.
> I'll try myself to solve this on weekend and if I can find a working
> solution I'll post here.
> HTH, Alessandro Alocci
Well, this worked for me:
First of all I have recompiled my kernel with:
Device Drivers -> USB Support ->
Support for Host-side USB
EHCI HCD (USB 2.0) support
OHCI HCD support
UHCI HCD (most Intel and VIA) support
USB Mass Storage support
statically compiled into the kernel.
I needed also this:
Device Drivers -> Block devices ->
Loopback device support
RAM disk support
Initial RAM disk (initrd) support
statically compiled into the kernel.
Then I recompiled and installed the kernel
(mine is 220.127.116.11) and rebooted.
Now we have to build an initrd-tree, we can
build it from "scratch" (possibly, a more appropriate
solution on this site) but we can also use an already
A good candidate seems to be the mkinitrd script from
the last slackware distro, so I downloaded this:
from a slack mirror. Then:
cp /home/alex/scaricati/mkinitrd-1.0.1-i486-3.tgz .
tar xvzf mkinitrd-1.0.1-i486-3.tgz
install -v -m 755 usr/sbin/mkinitrd /usr/sbin/
install -v -d -m 755 /usr/share/mkinitrd
cp usr/share/mkinitrd/initrd-tree.tar.gz /usr/share/mkinitrd/
# you can also read and install the docs and man page
# about busybox and mkinitrd. Be sure to read
# the script itself to understand how it works.
Now the mkinitrd script is installed and we can
build the initrd-tree, so:
# Add your disk-device in initrd-tree/rootdev
# (mine is /dev/sda6, correct this with yours)
cat > initrd-tree/rootdev << "EOF"
# Add the name of the used file-system for the
# previous partition (mine is ext3)
cat > initrd-tree/rootfs << "EOF"
Now, the problem with this solution is that we
have to give time enough to the kernel to discover
the usb-storage before that the initial ram disk
try to mount the real root partition (in my case
/dev/sda6). To solve this I added the line
in initrd-tree/linuxrc, just before this comment:
# Switch to real root partition:
(Yes, I know it's a bit naive, but I have not
a better solution ATM, perhaps someone can suggest
something more appropriate here)
One can tune the previous sleep in case is not
enough; in my case wait for 12 seconds is sufficient.
If someone needs to load also some modules from the
initrd, they have to be copied in
and edit load_kernel_modules, then
chmod 755 load_kernel_modules
Now we have to run the mkinitrd script
again from the /boot directory:
This time the script should create the real
initrd.gz. We need also to copy the kernel
from the usb-disk partition in the hard-disk.
Now we can instruct grub to boot from sdaX.
I added this to /boot/grub/menu.lst:
(With grub installed in the MBR of /dev/hda)
kernel (hd0,10)/boot/usblfskernel-18.104.22.168 root=/dev/sda6
Again, be sure to correct the previous line with
your correct data.
As you see, this solution requires to have both
the kernel and the initrd image in a disk where grub
can find them, but after that grub should menage to boot
the system installed in the usb-disk.
This let me to reboot from an usb-disk partition.
Well, it seems to be all (hope I haven't forgot
anything or made too much confusion)
Regards, Alessandro Alocci
More information about the blfs-support