LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 06-17-2009, 10:03 PM   #1
Freeway
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Rep: Reputation: 0
Question Grub problem booting from USB drive


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
 
Old 06-18-2009, 07:47 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,184

Rep: Reputation: 1017Reputation: 1017Reputation: 1017Reputation: 1017Reputation: 1017Reputation: 1017Reputation: 1017Reputation: 1017
This I wrote in the past on various boot problems.

http://www.linuxquestions.org/questi...-drive-701968/
http://www.linuxquestions.org/questi...ch-4.0-685215/
http://www.linuxquestions.org/questi...138/page2.html

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.
 
Old 06-19-2009, 02:31 PM   #3
Freeway
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Question

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.

Last edited by Freeway; 06-20-2009 at 10:08 AM.
 
Old 06-20-2009, 03:11 PM   #4
Freeway
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Smile Problem solved

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.
 
Old 06-22-2009, 01:13 AM   #5
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 17.3+18.3, MX-17
Posts: 4,177

Rep: Reputation: Disabled
Thanks for this concise set of instructions as your solution. This is what makes LQ so likeable.
 
  


Reply

Tags
grub, usb


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
Is there any problem booting through grub if the window is not installed in c drive? sreejithsidharthan Linux - Newbie 2 02-19-2009 12:38 AM
problem booting linux from usb drive Danielite Linux - Laptop and Netbook 3 10-13-2007 10:47 AM
Problem booting from USB drive - kubuntu mrloy Linux - Hardware 0 01-04-2007 10:43 AM
Grub problem: Booting Linux from USB Disk Noelle Milton Vega Linux - General 1 08-23-2006 06:46 PM
Booting with GRUB to external USB drive Mirag3 Linux - Hardware 3 05-18-2006 07:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:37 PM.

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