Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I installed Mandriva Linux 2008.1 on the secondary device in my desktop PC with 3 partitions: root, swap and home (hdb1, hdb5, and hdb6). Everything was working properly under this configuration.
The drive is now installed in a portable USB/ATA case connected to my laptop system. The laptop BIOS allows me to boot from it, and Grub starts to run but cannot find the root filesystem so the bootup fails.
I booted the laptop from the Mandriva CD-ROM in rescue mode, and after manually loading the module "usb-storage", I was able to mount the partitions from the USB drive (/dev/sdb) using the option "Mount your partitions under /mnt".
I don't know whether the device will appear as /dev/sda or /dev/sdb when booting from the USB drive instead of the CD-ROM, but I tried editing the config files (/boot/grub/device.map, /boot/grub/menu.lst, /etc/fstab) both ways without success. Using UUIDs in fstab made no difference.
How can I get Grub to mount the root filesystem from the USB drive successfully? [See solution below]
Last edited by Freeway; 06-21-2009 at 02:40 PM.
Reason: Simplify
The last link is about dropping into the busybox kernel, whose logfile provides a lot of information. I hope your distro provides this feature as well.
After further reading, I think the answer to the problem would be to rebuild the boot image file using:
mkinitrd --with-usb <imagefile> <version>
This option would cause the module usb-storage to be loaded with the initrd image, which is required to detect the USB devices and mount the partitions (including root) during the boot stages.
Unfortunately, this cannot be done when booting from the Mandriva CD in "rescue mode", since mkinitrd and several other functions it needs are not available in the subset.
After booting from the CD, and loading module usb-storage manually, is it possible to unmount the root filesystem and then mount the root filesystem (/dev/sdb1) from the USB drive instead?
I will try chroot /mnt mkinitrd... first to see it will run properly that way. If not, next step is to try pivot_root to mount the USB root filesystem, and then run mkinitrd.
The boot problem was solved by rebuilding the initrd.img boot image file to include the usb-storage module, and correcting the grub configuration files. A summary of the solution is below:
Connect USB hard drive to computer
Load bootable Linux disk into CD drive (eg: Mandriva distribution disk 1)
Power up system, enter BIOS menu, set boot device order: CD, USB, HD
Select CD as boot device
At boot option menu, select option "Rescue Mode"
On rescue mode menu, select option "Go to console":
# drvinst (to install device drivers)
# modprobe usb-storage (to load USB mass storage support)
# rescue-gui (to return to menu)
Select option "Mount your partitions under /mnt"
Select option "Go to console":
Rebuild the boot image file initrd.img with USB mass storage support:
# cd /mnt/boot
# ls -l init* (find your boot image file initrd-n.n.n.n-desktop-xxx.img)
# cp -r /sys/* /mnt/sys (copy entire /sys directory to /mnt/sys, ignoring errors)
# cp <imagefile> <imagebackup> (make a backup copy of your image file)
# chroot /mnt mkinitrd --help (verify that mkinitrd is found)
# chroot /mnt mkinitrd --with-usb <newimagefile> <version> (where version is n.n.n.n-desktop-xxx)
Modify the configuration files using text editor (vi):
# cd /mnt/boot/grub
# cp device.map device.map.backup
# vi device.map
(hd0) /dev/sda
(hd1) /dev/sdb
# cp menu.lst menu.lst.backup
# vi menu.lst
...
default 0
title NewBoot
root (hd0,0)
debug rootdelay=5 (for testing)
kernel (hd0,0)/boot/vmlinuz BOOT_IMAGE=NewBoot root=/dev/sdb1 splash=verbose
initrd (hd0,0)/boot/initrd-n.n.n.n-desktop-xxx.img (using name of newimagefile created above)
...
# cd /mnt/etc
# cp fstab fstab.backup
# vi fstab
Change all occurances of /dev/xxx for the partitions on your USB device to the correct device specifier, in this case /dev/sdb.
# rescue-gui (to return to menu)
Eject CD
Select option "Reboot"
The system should now try to boot from the USB drive, with usb-storage support. The grub messages should show the detection and mounting of SCSI devices and USB devices before starting the kernel. If root partition is still not found, try editing menu.lst and fstab to specify sda instead of sdb.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.