LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-25-2009, 08:48 AM   #1
simonb
LQ Newbie
 
Registered: Dec 2002
Posts: 11

Rep: Reputation: 0
Install grub for a filesystem on sdb from a rescue system on sda


I boot a CentOS 5 image running on /dev/sda and I have a dormant CentOS 5 image on /dev/sdb that I need to install grub on.

I do the following sequence of commands to mount the other installation (I copied these mounts from the rescue CD).

Code:
mkdir -p /mnt/target
mount /dev/VolGroup00/LogVol00 /mnt/target
mount /dev/sdb1 /mnt/target/boot
mount /tmp/sysfs /mnt/target/sys -t sysfs
mount /tmp/proc /mnt/target/proc -t proc
mount /dev /mnt/target/dev -o bind
mount /dev/pts /mnt/target/dev/pts -t devpts
mount /selinux /mnt/target/selinux -t selinuxfs
I then chroot and install grub...

Code:
chroot /mnt/target
grub
>root (hd1,0)
 Filesystem type is ext2fs, partition type 0x83
>setup (hd1)
setup (hd1)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd1)"...  17 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd1) (hd1)1+17 p (hd1,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded
Done.
>quit
exit
I then unmount all the target directories...

Code:
umount /mnt/target/selinux
umount /mnt/target/dev/pts
umount /mnt/target/proc
umount /mnt/target/sys
umount /mnt/target/dev
umount /mnt/target/boot
umount /mnt/target
I then reboot with the target system now as sda. It just drops to a grub shell. I have no idea why. I can re-install grub from this shell, it reports success and then it still does the same thing next time I boot. If I install grub from a rescue CD then it works fine. However I don't what to do this from a rescue CD since I have to script the process (for a VM backup and disaster recovery system) and the CD requires manual intervention.

The grub.conf file is correct for a system booting off sda, after all, the install CD is able to get grub working.

Last edited by simonb; 08-25-2009 at 08:50 AM.
 
Old 08-25-2009, 11:07 AM   #2
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by simonb View Post
I then reboot with the target system now as sda. It just drops to a grub shell. I have no idea why.
Have you tried
Code:
# grub-install --root-directory=/mnt/target /dev/sdb
Also, is the "bootable" flag set on "/dev/sdb"? You can check this by running "fdisk -l /dev/sdb".
 
Old 08-26-2009, 05:35 AM   #3
simonb
LQ Newbie
 
Registered: Dec 2002
Posts: 11

Original Poster
Rep: Reputation: 0
Fixed!

I tried what you suggested but still got the same result. However I have now found a way to install grub on the other drive so that it boots. I don't even have to mount the other drive.

Code:
grub << EOF
device (hd0) /dev/sdb
install (hd0,0)/grub/stage1 d (hd0) (hd0,0)/grub/stage2 p (hd0,0)/grub/grub.conf
EOF
The next hurdle I had was that it couldn't find VolGroup00. This turned out to be because the previous Xen kernel needed "alias scsi_hostadapter xenblk" in /etc/modprobe.conf which cause the rpm install of the non-Xen kernel to mess up the initrd file with the error message, "No module xenblk found for kernel ..... aborting". The solution was to comment out the line in /etc/modprobe.conf, chroot to the target filesystem and re-run initrd.

Now it boots :-)

Last edited by simonb; 08-26-2009 at 07:48 AM.
 
Old 08-27-2009, 12:03 PM   #4
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by simonb View Post
Fixed!
Don't forget to use the "Thread Tools" drop down to mark this thread as "solved".
 
Old 08-27-2009, 11:39 PM   #5
simonb
LQ Newbie
 
Registered: Dec 2002
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by David1357 View Post
Don't forget to use the "Thread Tools" drop down to mark this thread as "solved".
Thanks for the reminder. Done!
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I keep sda from changing its name to sdb? kinetic Linux - Hardware 3 06-22-2008 08:01 PM
Changing sda to sdb mickeyboa Fedora 4 04-21-2008 12:22 AM
New disk presentation allows sdb but not sda to be partitioned sbf132 Linux - Hardware 0 02-12-2008 07:21 PM
sda or sdb? stevest SUSE / openSUSE 7 12-18-2007 11:57 AM
RHEL4U5 install changes /dev/sda to /dev/sdb bhoch Red Hat 8 12-05-2007 06:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:09 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
Open Source Consulting | Domain Registration