LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 01-14-2009, 02:14 AM   #1
rajivb
Member
 
Registered: Sep 2004
Location: Bangalore, India
Distribution: Fedora, Ubuntu, WinXP
Posts: 39

Rep: Reputation: 15
Transferring Boot loader from one HDD to another


Hi All,
I have a question about bootloaders.

I have 2 HDDs (160 GB and 250 GB)
I have a dual boot with Fedora 7 and Win XP.
The GRUB loads from 160 GB drive.
WinXP is in 160 GB HDD 's primary partition.
Fedora is in a logical partition in 250GB HDD.
I want to format the 160GB HDD and the 250 GB HDD cannot boot the linux by itself(as the bootloader is in 160 GB one).
I want to know if I could install GRUB on the 250 GB HDD without disturbing the partition or Fedora installation and be able to boot into Fedora if 250 GB HDD is alone connected ???

Note: Please move to appropriate section if not appropriate here.

Thank you
rajiv
 
Old 01-14-2009, 03:45 AM   #2
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
Yes you can.

As long as your system only used the boot loader on the 160G disk.

If you are using grub, it's pretty simple to do:

Check before use but here is an example:

Code:
# grub --no-floppy
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
 Filesystem type is ext2fs, partition type 0xfd
grub> 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 (hd0)"...  15 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
Done.

grub> quit

Note that this is for 'sdb1'. You will probably need to adapt it.

Be very careful you don;'t do this on sda!

Best of luck
 
Old 01-14-2009, 08:49 AM   #3
rajivb
Member
 
Registered: Sep 2004
Location: Bangalore, India
Distribution: Fedora, Ubuntu, WinXP
Posts: 39

Original Poster
Rep: Reputation: 15
Thank you eco.
But can you please explain that line by line?
in my case, grub.conf is as below.

#grub.conf
Code:
default=2
timeout=5
splashimage=(hd1,12)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.20-2925.9.fc7xen)
        root (hd1,12)
        kernel /xen.gz-2.6.20-2925.9.fc7
        module /vmlinuz-2.6.20-2925.9.fc7xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        module /initrd-2.6.20-2925.9.fc7xen.img
title Fedora-base (2.6.21-1.3194.fc7)
        root (hd1,12)
        kernel /vmlinuz-2.6.21-1.3194.fc7 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.21-1.3194.fc7.img
title Other
        rootnoverify (hd0,0)
        chainloader +1
#partition info (from fdisk output, edited)
Code:
Disk /dev/sda: 160.0 GB

/dev/sda1   *      FAT32 #Win98
/dev/sda2          Extended Partition
/dev/sda5          NTFS  #WinXP
/dev/sda6          FAT32
/dev/sda7          NTFS
/dev/sda8          NTFS
/dev/sda9          NTFS
/dev/sda10         NTFS
/dev/sda11         NTFS
/dev/sda12         Linux #Ext3 just storage

Disk /dev/sdb: 250.0 GB

/dev/sdb1       FAT32
/dev/sdb2       Extended Partition
/dev/sdb5       NTFS
/dev/sdb6       NTFS
/dev/sdb7       NTFS
/dev/sdb8       NTFS
/dev/sdb9       NTFS
/dev/sdb10      NTFS
/dev/sdb11      NTFS
/dev/sdb12      NTFS
/dev/sdb13  *   Linux #ext 3 /boot (Fedora 7)
/dev/sdb14      Linux LVM  #ext 3 (all other linux partions under this)
I think there is nothing to change in your code for my situation.
Can I run as it is?
Is there a possibility of loosing the data in other (NTFS / FAT32) partitions in the drives?

Last edited by rajivb; 01-14-2009 at 09:21 AM. Reason: added partition info
 
Old 01-14-2009, 08:59 AM   #4
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
Quote:
Originally Posted by rajivb View Post
title Fedora-base (2.6.21-1.3194.fc7)
root (hd1,12)
kernel /vmlinuz-2.6.21-1.3194.fc7 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.21-1.3194.fc7.img
Hi again,

Your root seems to be on sdb12 (hd1,12)

So you need to install the bootloader on the sdb MBR and tell it here the root is

Try this:
Code:
# grub --no-floppy
grub> device (hd0) /dev/sdb
grub> root (hd0,12)
grub> setup (hd0)
grub> quit
This should work as long as you keep the 160GB disk (sda) in the box.

You might also have noted that I set sdb to hd0 and not hd1. That's normal. The first grub line says hd0 is /dev/sdb. If you wanted to set an MBR on both disks, to boot your system, it would have to change but that's another story.

Hope this helps.
 
Old 01-14-2009, 09:23 AM   #5
rajivb
Member
 
Registered: Sep 2004
Location: Bangalore, India
Distribution: Fedora, Ubuntu, WinXP
Posts: 39

Original Poster
Rep: Reputation: 15
Question

Quote:
Originally Posted by eco View Post
Your root seems to be on sdb12 (hd1,12)
It is actually sdb13 if you can check the fdisk info I gave. I think grub starts counting from 0.

I have some doubts
1) Will I loose my present data?
2) I don't want the 250 GB HDD to depend on 160GB HDD to boot into linux. Can I directly boot into Fedora after this without attaching 160 GB HDD?
3) Can I do this from inside Fedora through Terminal?
 
Old 01-14-2009, 09:49 AM   #6
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
Quote:
Originally Posted by rajivb View Post
It is actually sdb13 if you can check the fdisk info I gave. I think grub starts counting from 0.
I completely missed the partition info.

You can run the command from inside Fedora through a terminal.

OK, here is a practical example of what I did:

/boot - hd{a,b}1
/ - hd{a,b}2

* device.map

Code:
/boot/grub/device.map
(hd0)   /dev/hda
(hd1)   /dev/hdb

* grub

Install boot record on hda and hdb


Code:
livecd linux # grub --no-floppy --device-map=/boot/grub/device.map

grub> device (hd0) /dev/hda
grub> root (hd0,0)
grub> setup (hd0)

grub> device (hd0) /dev/hdb
grub> root (hd0,0)
grub> setup (hd0)

grub> quit

This way I install the boot loader on the MBR of both disks. (hd0,0) point to the partition that contains /boot.

The above would allow my software RAID to have say hda fail and still boot of hdb with a simple grub manipulation.

so for you:

Code:
# grub --no-floppy --device-map=/boot/grub/device.map

grub> device (hd0) /dev/hdb
grub> root (hd0,12)
grub> setup (hd0)
grub> quit
This should do the job.

grub> root (hd0,12) would throw an error if it's not in any case.

Hope this helps.

Last edited by eco; 01-14-2009 at 09:51 AM.
 
Old 01-14-2009, 09:56 AM   #7
rajivb
Member
 
Registered: Sep 2004
Location: Bangalore, India
Distribution: Fedora, Ubuntu, WinXP
Posts: 39

Original Poster
Rep: Reputation: 15
Thanks eco.
I tried it as it is. (The last code block).
Will reboot with only 250 GB and let u know what happen.
 
Old 01-14-2009, 10:04 AM   #8
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
Quote:
Originally Posted by rajivb View Post
Will reboot with only 250 GB and let u know what happen.
In case it doesn't boot, edit your grub file at boot using 'e'

and change
Code:
title Fedora-base (2.6.21-1.3194.fc7)
        root (hd1,12)
        kernel /vmlinuz-2.6.21-1.3194.fc7 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.21-1.3194.fc7.img
to
Code:
title Fedora-base (2.6.21-1.3194.fc7)
        root (hd0,12)
        kernel /vmlinuz-2.6.21-1.3194.fc7 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.21-1.3194.fc7.img
Note also that your default boot is 2 (default=2) so make sure you edit the right one
 
Old 01-15-2009, 11:36 AM   #9
rajivb
Member
 
Registered: Sep 2004
Location: Bangalore, India
Distribution: Fedora, Ubuntu, WinXP
Posts: 39

Original Poster
Rep: Reputation: 15
Smile

Sorry, was busy with office today.

I tried using the 250 GB HDD after executing the steps you mentioned before.
The 250 GB HDD now has the same grub menu as 160GB HDD but when I try to boot into linux or windows, it says
Code:
Error 18 : Selected cylinder exceeds maximum support by BIOS
and comes back to grub menu after pressing any of the keys.

So I tried to edit the first line in the first two options seperately changing it to hd0 from hd1, but still got the same message.

Then I got into GRUB command line and tried to execute the commands in the grub menu one by one. And it worked!!!
But I can't directly boot into the HDD by selecting one of the options.

Probably I should try changing grub.conf to have it boot from hd0.
Thanks a eco.
I am busy with other work. So I'll let you know as soon as I try this one.

The default=2 is the last option (Windows boot loader which of course is not present on 250 GB HDD).
 
Old 01-15-2009, 05:33 PM   #10
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
Hey rajivb,

This looks like a problem that I though had been resolved where your /boot partition had to be at the 'begining' of the disk.

The fact that it's on sda13 might be a problem. Still, I doubt that's the problem but it might be worth checking.

The problem does seem to be the location of your boot partition.

The following is an old post but it will point you in the right direction: link

Last edited by eco; 01-15-2009 at 05:39 PM. Reason: Added info
 
  


Reply

Tags
grub, mbr, raid


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
Installing a new HDD & transferring data d00bid00b Linux - Hardware 4 08-16-2006 02:40 AM
Advice needed on transferring data from HDD to HDD denimglen Linux - Newbie 3 03-04-2006 08:33 PM
2 HDD, XP & Suse(for now), boot loader on each HDD? mozetti Linux - Newbie 3 03-15-2005 09:25 AM
Transferring to new HDD slackmagic Linux - General 6 08-07-2003 09:42 PM


All times are GMT -5. The time now is 07:44 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration