LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 04-13-2005, 05:00 AM   #1
penguinlnx
Member
 
Registered: Mar 2005
Location: Ice Station Alert AFB
Distribution: Gentoo
Posts: 166

Rep: Reputation: 30
HOW TO -Swapping HD-0 to HD-1 ?


Okay I have a standard Desktop with VidaLinux (Gentoo) on Hard Drive 0,
that is, the MASTER drive on the IDE cable.

I also have another hard drive with Win2K on it which was also installed as Drive 0 (Master). If I simply change the Windows Drive to a SLAVE, Win2K messes up the drive assignments and installed software doesn't run.

If I make the Linux drive the SLAVE, (Drive1) then LInux won't boot.

I would like to physically install both drives rather than swapping them in and out when I want to switch OS.

My BIOS allows me to boot off either drive 0 (Master) or drive 1 (Slave),
but the software OSs don't automatically adjust for where they are.

Is there an easy way to convert the Linux drive to run as drive 1 (Slave),
because If I try to install Linux on the drive while it is a (Slave), Linux won't install properly.

I'd rather keep the OSs that I have installed anyway, rather than reinstall either of them for hours / days. I know there is a way to manually tweak the Windows system, but it is complicated. Is there a similar procedure for the Linux OS?
 
Old 04-13-2005, 10:09 AM   #2
laaapin
LQ Newbie
 
Registered: Apr 2005
Posts: 7

Rep: Reputation: 0
Hi,

If it's just about making Windows work as slave you can try :
- boot with Win2K cdrom
- find your way to te repair console
- type fixboot (it should do the trick)

Then :
- switch back to linux
- modify your menu.lst or lilo.conf so that the windows section points to /dev/hdb1

And try to reboot on the windows partition... it should work.

If you don't have the repair tool on the win2k cdrom, you can find them on the winxp one.

Good luck! gave me headaches for a while!
 
Old 04-13-2005, 03:21 PM   #3
penguinlnx
Member
 
Registered: Mar 2005
Location: Ice Station Alert AFB
Distribution: Gentoo
Posts: 166

Original Poster
Rep: Reputation: 30
oops

Well that didn't work.

I'd post my grub.conf file, but now I can't access drive at all.
I only have two disks that can boot Linux:
(1) Gentoo
(2) Vidalinux

Only Gentoo drops me into a command line.
But I have no idea how to access the drive and find the damn grub file. I made a backup in case it didn't work, but I need some way of mounting the drive and finding the files, switching them back and rebooting.

I am used to DOS, where you can look at a drive and know what you are looking at. Never mind all this 'mounting' crap.

Help if you can...thanks in advance.
 
Old 04-14-2005, 03:18 AM   #4
laaapin
LQ Newbie
 
Registered: Apr 2005
Posts: 7

Rep: Reputation: 0
First, you need to know where your harddrive is connected (IDE1 or IDE2), then you need to know on which partition your Linux OS is installed

Let's the drive is master on IDE1, then try
#fdisk /dev/hda
and type "p" for print, it should give you the partition number that hosts the linux os.

then, move to /mnt and type
#mkdir whatever_you_want (gentoo or drive, whatever)
(note, booting with a gentoo install cdrom create a /mnt/gentoo directory where you can mount your partition).

So let's say you use this gentoo cdrom and you linux is installed on partition 1

#mount -t auto /dev/hda1 /mnt/gentoo
#cd /mnt/gentoo
#ls

you should now see your filesystem again.

#cd /boot/grub
#cat menu.lst

Question :
Be more precise about how your drives are installed.
you have two drives, both connected and the one that contains windows is set up as slave but has been installed as master, and the one that contains linux has been installed as master and is master?

And you want both systems to work. The simplest is to switch drives, put back windows as master. Then boot on a gentoo install cd, mount you linux filesystem and manually edit grub.conf and /etc/fstab
Then reinstall grub on the master drive by chrooting to the linux system...

Simple :

#mount -t auto /dev/hdb1 /mnt/gentoo (note that your linux drive is now hdb)
#mount -t proc proc /mnt/gentoo/proc
#chroot /mnt/gentoo
#source /etc/profile
#grub
>root (hd1,0)
>setup (hd0)

Hope this helps.. .


The more precise you are the more i can help
 
Old 04-14-2005, 12:13 PM   #5
penguinlnx
Member
 
Registered: Mar 2005
Location: Ice Station Alert AFB
Distribution: Gentoo
Posts: 166

Original Poster
Rep: Reputation: 30
Started again. My goal was to move the Linux drive from hd0 (master) to hd1 (slave) on the IDE cable, and still have it boot. I can choose to boot from either in the BIOS. The point is to have a different OS on each drive, and choose between them through the BIOS, without having to physically swap them in and out. The Windows OS is a huge pain to fix so that it can boot as a slave, when it was installed as a master.

Heres the working info: fdisk -l gives this:
Code:
Disk /dev/hda: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System           (explanation)

/dev/hda1   *           1          13      104391   83  Linux                   (current BOOT)
/dev/hda2              14         268     2048287+  82  Linux swap       (current SWAP)
/dev/hda3            2622        7476    38997787+   5  Extended      (Extended Part starts)
/dev/hda4             269        2621    18900472+  83  Linux             (current ROOT)
/dev/hda5            2622        2634      104391   83  Linux               (old boot)
/dev/hda6            2635        7222    36853078+  83  Linux            (old root)
/dev/hda7            7223        7476     2040223+  82  Linux swap     (old swap)
The working GRUB.CONF :
Code:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/hda4
#          initrd /initrd-version.img
#          boot=/dev/hda

default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Linux002 (2.6.9-vidalinux_r1)
   root (hd0,0)
   kernel /vmlinuz-2.6.9-vidalinux_r1 gentoo=nodevfs udev root=/dev/ram0 init=/linuxrc real_root=/dev/hda4 vga=0x317 video=vesa:ywrap,mtrr splash=silent
   initrd /initrd-2.6.9-vidalinux_r1.img
Here is the fstab file:
Code:
LABEL=/1                /                       ext3    defaults        1 1
LABEL=/boot1            /boot                   ext2    defaults        1 2
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
/dev/hda2               swap                    swap    defaults        0 0
/dev/hda7               swap                    swap    defaults        0 0

/dev/hdc                /media/cdrw_dvdr        auto    noauto,user,exec,ro 0 0
/dev/hda6               /media/idedisk          ext3    noauto,user,exec 0 0
/dev/hda5               /media/idedisk1         ext3    noauto,user,exec 0 0

/dev/floppy/0           /media/floppy           auto    noauto,user,exec 0 0
/dev/hdd                /media/cdrom            auto    noauto,user,exec,ro 0 0
Here's what I changed in each file to try to make it work as DRIVE 1(SLAVE) instead of DRIVE 0 (MASTER):
for GRUB.CONF: I changed hd0 to hd1 and real_root=hda4 to hdb4
Code:
default=0
timeout=10
splashimage=(hd1,0)/grub/splash.xpm.gz
title Linux002 (2.6.9-vidalinux_r1)
   root (hd1,0)
   kernel /vmlinuz-2.6.9-vidalinux_r1 gentoo=nodevfs udev root=/dev/ram0 init=/linuxrc real_root=/dev/hdb4 vga=0x317 video=vesa:ywrap,mtrr splash=silent
   initrd /initrd-2.6.9-vidalinux_r1.img
for FSTAB: hdax becomes hdbx in 4 places
Code:
LABEL=/1                /                       ext3    defaults        1 1
LABEL=/boot1            /boot                   ext2    defaults        1 2
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
/dev/hdb2               swap                    swap    defaults        0 0
/dev/hdb7               swap                    swap    defaults        0 0

/dev/hdc                /media/cdrw_dvdr        auto    noauto,user,exec,ro 0 0
/dev/hdb6               /media/idedisk          ext3    noauto,user,exec 0 0
/dev/hdb5               /media/idedisk1         ext3    noauto,user,exec 0 0

/dev/floppy/0           /media/floppy           auto    noauto,user,exec 0 0
/dev/hdd                /media/cdrom            auto    noauto,user,exec,ro 0 0

Shouldn't this work, and if not, why not? How should 'GRUB' be run again? What does this comment mean in the GRUB.CONF file?
 
Old 04-14-2005, 12:19 PM   #6
laaapin
LQ Newbie
 
Registered: Apr 2005
Posts: 7

Rep: Reputation: 0
Once you've made the switch you have ton install grub on hda to make it work, and add a windows section to grub so that you can choose between windows and linux at startup without using the BIOS.
 
Old 04-14-2005, 01:26 PM   #7
penguinlnx
Member
 
Registered: Mar 2005
Location: Ice Station Alert AFB
Distribution: Gentoo
Posts: 166

Original Poster
Rep: Reputation: 30
You're getting ahead of me here.
I don't know if I ever want to do that,
because everytime I let a 3rd party OS tamper with Windows,
it stops working entirely, and its a big pain in the ass to reinstall.

Right now, I'd just like to see Linux booting from the Slave Drive.
 
Old 04-14-2005, 01:58 PM   #8
laaapin
LQ Newbie
 
Registered: Apr 2005
Posts: 7

Rep: Reputation: 0
Well, that should work.
Anyway i'm not fond of disk labelling, i find it much easier without.

What do you get when you boot? do you get the grub chooser?
 
Old 04-14-2005, 03:24 PM   #9
penguinlnx
Member
 
Registered: Mar 2005
Location: Ice Station Alert AFB
Distribution: Gentoo
Posts: 166

Original Poster
Rep: Reputation: 30
Interesting Experiment!

Okay I just tried switching the jumper on the Linux drive (making it a SLAVE = hd1).
Then I booted off it from the BIOS.
It actually worked to a point without any changes whatever to either of the boot files, GRUB.CONF or FSTAB.
But it hangs on a commandline because it can't find /dev/hda4 (the root).
I type that in manually, (as /dev/hdb4) and lo and behold the system goes up and I get the GUI.
I am using it now. Obviously I have to make some change so that this becomes automated.
But this appears to be a lot less than the file modifications I thought I had to make.
Not sure if this will break or lead to other problems, but I think I am going to try to modify the grub file and see if thats all it takes.

POSTSCRIPT: changing the one kernel parameter (the root /dev/hdb4) allows the system to go all the way to the GUI. I hope this helps others. Thanks to everyone for your time and effort!

Last edited by penguinlnx; 04-14-2005 at 05:49 PM.
 
Old 05-01-2005, 05:36 AM   #10
penguinlnx
Member
 
Registered: Mar 2005
Location: Ice Station Alert AFB
Distribution: Gentoo
Posts: 166

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

Here's my GRUB file:
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
(1) 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.

(2) 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.

(3) 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 --------
(1) 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.)

(2) 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.

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.

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


Reply


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
Swapping from FC3 gibbylinks Ubuntu 6 05-18-2005 11:39 AM
swapping HD ZaphyR Linux - Hardware 2 01-16-2005 10:11 AM
Swapping Drives Little Dump Linux - Newbie 0 10-13-2004 07:46 PM
Swapping Drives Little Dump Linux - Hardware 0 10-13-2004 02:28 PM
swapping hardware blitzen Linux - Hardware 4 08-01-2004 04:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 08:24 AM.

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