Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Moving Linux from Master (HD0) to Slave (HD1)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
penguinlnx
Tux's lil' helper
Tux's lil' helper


Joined: 17 Mar 2005
Posts: 124
Location: Ice Station Alert AFB

PostPosted: Sun May 01, 2005 10:59 am    Post subject: Moving Linux from Master (HD0) to Slave (HD1) Reply with quote

My Goal: To simply move my LInux drive on the IDE cable from Master to Slave.
Both Linux and Windows are most easily installed and set up on a Master Drive.
I did these separately, and now I wanted to move the Linux to the 'Slave' spot.
I wanted both drives hooked up physically, so I could switch OSs without physically messing around.
I did not want to use GRUB to boot WINDOWS, because I have found that GRUB can and does
trash Windows 2000 drives, especially the MBR (master boot record), and the time and effort
trying to repair or reinstall Windows just isn't worth it. I now only want to let Linux access DATA partitions.
The solution is simple: Use the BIOS to select which drive to boot up.

Okay I am still not sure how safe these modifications are, but I will tell you what I have found:

To move the Linux Drive from Master (HD0) to Slave (HD1) involves the following steps:

1) Edit the /mnt/gentoo/boot/grub/GRUB file in the BOOT partition.
(my BOOT partition was mounted as /mnt/gentoo/boot following the handbook)
Change the parameters passed to the kernel to reflect the new locations (a becomes b).

2) Edit the /etc/fstab file in your ROOT partition.
Change all the 'a' partitions to 'b' partitions (and vice versa, if you are swapping Slave to Master).

3) Log off and shut down completely (power off) and change the Master jumper to Slave on the Linux Drive.
(If Swapping another drive from Slave to Master make sure you change it too.)

4) Boot into your ROM BIOS and set it up so that you boot off the SLAVE first, CD ROM or Master 2nd.
Save your BIOS settings and complete the Boot into Linux, and test to see that partitions etc are mounted.

All this has to be done in one complete step, so make sure you check that everything is already correct.
Don't experiment, or you won't be able to REBOOT into a working system, and you may have to re-install.
Make backup copies of your original GRUB as GRUB.OLD and FSTAB as FSTAB.OLD,
in case something goes wrong and you have to reboot off the LiveCD and change things back.
Then you can just copy (overwrite) the files again to restore them with the CP command.
Remember to restore jumpers and ROM BIOS settings if you switch back again to recover.

(1) First I had to modify my GRUB file. Here's the new one:
Code:
# GRUB.CONF  -for gentoo stage 1
#
# default 0  default menu item
# timeout 30  default time to make selection countdown
default 0
timeout 10
splashimage=(hd0,0)/grub/splash.xpm.gz
title=Gentoo Linux 2.6.11-r6
#Partition where the kernel image (OS) is
root (hd0,0)
kernel /kernel-2.6.11-gentoo-r6 root=/dev/hdb4

(a) First notice on line 7: splashimage=(hd0,0)/grub/splash.xpm.gz
I have not altered the 'hd0' part, because apparently, you don't need to.
When you switch your jumpers and make the drive into a Slave (=hd1), it still thinks it is hd0 when booting.
When I altered this, I in fact got errors, at least in one experiment, so I put it back.

(b) Now look at line 11: kernel /kernel-2.6.11-gentoo-r6 root=/dev/hdb4
Here however, since this is a parameter that is used later by the kernel to find the /ROOT partition,
It has to be changed to reflect the real hardware situation, which is that the partition has moved along with the drive.
That is, the partition was on Master(=hd0=hda4) but is now on Slave(=hd1=hdb4)
Your /ROOT partition might be hda3, in which case you would change the 'a' to a 'b' making it hdb3.

(2) Next, I had to change the /etc/fstab file, which tells the OS where and what the other partitions are.

My /ETC/FSTAB file looks like this now:
Code:

# <fs> --------------<mountpoint> ------<type>---------<opts> --------------<dump/pass>
# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.

/dev/hdb1   /mnt/gentoo/boot   ext2      noatime         1 2
/dev/hdb2   none         swap      sw         0 0

#========================================================== BEGIN Extended Partition ===
#------------ Windows extended partition: not directly used -holds hda4 & hda5 ---------
#/dev/hdb3              /mnt/idedisk2   auto            noatime             0 1
#------------ Linux current install root partition  ------------------------------------
/dev/hdb4      /      reiserfs   noatime,notail      0 1
#------------ Linux partition from previous install with data files --------------------
/dev/hdb5               /mnt/idedisk1   ext3            noatime                   0 1
#------------------------------------------------------------ END Extended Partition ===

#=========================================================== BEGIN Win2K BOOT DRIVE ====
#...........Assume Linux Drive has been switched to hdb (HD1) so Win2K is hda (HD0).....
#/dev/hda2      /mnt/secure1   auto      noatime         0 1
#/dev/hda3      /mnt/secure2   auto      noatime         0 1
#-------------------------------------------------------------------- END Win2K --------

(a) Everywhere you see hdb1, hdb2, hdb3 etc., used to be hda1, hda2 etc.
Although I haven't activated the lines, (they're still commented out) I can mount the Win2K drive partitions too.
They are on the new Master (Win2K) Hard drive, as hda2, hda3, etc. ( I don't want Linux to touch hda1.)

(b) I was previously able to access the data partitions on the Windows drive as hdb2, hdb3 etc. (as Slave=hd1).
In summary, making sure the info for each partition is correct, you simply swap b for a and vice versa.
I did this by installing and testing everything with Linux as the Master (HD0) first.

Let me know if this works for you. If anyone sees any errors or has suggestions please post them here! Thanks!

GRUB boot Repair
Easy Firewall with IPtables
Hardware Fixes
CUPS Printer Install
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 32104
Location: 56N 3W

PostPosted: Sun May 01, 2005 11:22 am    Post subject: Reply with quote

penguinlnx,

You should also fix /boot/grub/device.map, which contains grubs mappings of grub devices to /dev entries.
As alternatives to installing grub on the MBR of /dev/hda and risk trashing windows, you can leave the Windows bootlater there and install grub on the MBR of /dev/hdb It can still be used to boot windows, without touching the windows drive.
No messing in the BIOS for dual boot.

Nervous users can use NTLDR (Windows boot loader) to start linux regardless of where grub is installed but the details are beyond the scope of this post.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
penguinlnx
Tux's lil' helper
Tux's lil' helper


Joined: 17 Mar 2005
Posts: 124
Location: Ice Station Alert AFB

PostPosted: Sun May 01, 2005 11:45 am    Post subject: Reply with quote

Thank you for noticing this: Here is my /boot/grub/device.map:
Code:
(fd0)   /dev/fd0
(hd0)   /dev/hda
I have no idea what should be added or changed however, or what not doing it in a timely manner might do...?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 32104
Location: 56N 3W

PostPosted: Sun May 01, 2005 11:56 am    Post subject: Reply with quote

penguinlnx,

If you have two drives and a floppy (CD-ROM, DVD-ROM don't count)you probably want
Code:
(fd0)   /dev/fd0
(hd0)   /dev/hda
(hd1)   /dev/hdb
although I have
Code:
(fd0)   /dev/floppy/0
(hd0)   /dev/ide/host0/bus0/target0/lun0/disc
(hd1)   /dev/scsi/host0/bus0/target0/lun0/disc
(hd2)   /dev/scsi/host1/bus0/target0/lun0/disc
it uses the real device files not symbolic links.

The effect of not updating it?
For most users, none at all.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
penguinlnx
Tux's lil' helper
Tux's lil' helper


Joined: 17 Mar 2005
Posts: 124
Location: Ice Station Alert AFB

PostPosted: Sat May 07, 2005 9:53 am    Post subject: Reply with quote

aaa123 wrote:
PostPosted: Thu May 05, 2005 5:13 am penguinlnx, Nice attempt at sumarizing switch from master to slave. However a few questions come to mind:
look at /boot/grub/device.map:
Code:
 (fd0)   /dev/fd0
(hd0)   /dev/hda
(hd1)   /dev/hdb
Then think about that (hd0) now is slave when booting from slave MBR.
But (hd0) is defined as master in /boot/grub/device.map (/dev/hda) There is a conflict.
Also, Is it the /boot/grub/grub.conf or the /boot/grub/menu.lst or just the "GRUB file" as you stated? Which is needed with the lasest gentoo?

Yes, the descrepancy also bothers me, but I found my method worked experimentally. The other question, I always edit the grub.conf file, and I think the menu.lst is updated automatically. But someone else might know more about that.
aaa123 wrote:
I just successfully installed Gentoo Linux on a primary slave, haveing windows XP as primary master. AND I have two MBR, one for windows (defualt windows XP, which I never touched) on primary master, and one for Linux on primary slave. I configure BIOS to do the right booting. Only thing I wonder about is that I specified (hd0,0) as the Linux boot; yet in device.map (hd0,0) is defined as /dev/hda (which is the primary master where windows resides).But it worked with (hd0,0) so I am not complaining...:wink:
That's what I found too. I have yet to see a clear tech explanation of this: I found it out the hard way by experiments. I was told that the device.map is not needed by most users, but I didn't get an explanation why that is either. If anyone can explain either of these issues, I'd be grateful.
fangorn wrote:
IMO it is the most stable way to let Windows in MBR of primary master and install grub elsewhere. Just make a copy of the bootsector grub is installed in and save it to a file you can start with the Windows boot manager. Otherwise Windows will Destroy your Grub installation now and then :evil:
This I also found. I am glad everyone is confirming what I have gone through repeatedly, but again, no good explanation, except maybe there's a trojan built into MSwindows or one of the 'updates' to punish/discourage Linux users who want their cake and eat it too.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum