Advertisement

How do I change the my hd (with linux) from slave to master and have grub boot?

Started by February 19, 2005 12:20 AM
3 comments, last by HTML 19 years, 9 months ago
How do I change the my hd (with linux) from slave to master and have grub boot? I get error 17 if I try to change my hd from slave to master. Thanks
You need to change grub's configuration so that it knows to look for the boot partition from the master disk. This might involve re-running grub-install. It is probably easiest and least risky to do this from a live-cd. I recommend Knoppix so you can use a graphical browser while you're at it. Alternatively you might use a distro's rescue CD (you didn't mention your distro).

You should be familiar with command line to pull this off the hard way (which should work for any distro).
Assuming you don't have a separate /boot partition you basically need to
1. Set your disk to master.
2. Boot from the live-cd.
3. Open a root console (knoppix lets you do su without a password)
4. Mount your Linux partition (probably /dev/hda*)
5. Mount --bind the /dev directory to your linux partition's dev directory (not always needed AFAIK)
6. Mount the proc file system to your linux partition's proc directory.
7. Chroot to the linux partition (as root) and do source /etc/profile. This gives you a console that looks like it would be from your linux installation.

8. Modify /boot/grub/grub.conf and/or /boot/grub/menu.lst so that the hard-drive references are correct. If you switched from primary slave to primary master, you will most likely have entries like hd(1,?) that you need to change to hd(0,?)
9. Modify /etc/fstab. Here again assuming you switched from primary slave to primary master, you need to change all instances of /dev/hdb to /dev/hda.
10. Run grub-install /dev/hda (assuming primary master). If there are errors, check the files you edited and be sure you have mounted proc.

11. Unmount the things you mounted (proc, the --binded dev and the linux partition itself)
12. Reboot and pray. If it doesn't work, go back and try again or ask here for more info.

If you switched your HD to be the secondary master instead, then your new hd should be /dev/hdc instead of hda and the grub name (AFAIK) hd(2,?). As always it is good to back up your configuration files before making changes.
Advertisement
Do I have to mount all that, or can I just change it to hd (1,0) and reinstall grub?

Here is my menu.lst
See, what if I were to just switch the 1,0 with the 0,0. Would that work too?
because my windows is my master and my linux is slave. I just want to switch them easily.

title Debian GNU/Linux, kernel 2.6.8-1-k7 (recovery mode)
root (hd0,0)
kernel /vmlinuz-2.6.8-1-k7 root=/dev/hda3 ro single
initrd /initrd.img-2.6.8-1-k7
savedefault
boot

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title Other operating systems:
root


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/hdb1
title Windows 98
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
#savedefault
makeactive
chainloader +1



Thanks
Try it. It might work but in case it doesn't and you can't boot at all, the live cd technique may be useful.

Grub requires access to the device files and preferably /proc to find information about the partition layout and install itself, so they ought to be mounted.


Quote:
my windows is my master

heh :P
It works not, but...how do I install win2k on a slave drive? When I try to format it, it says it needs to put files on the other hd which has linux but I don't want it too. And besides that it can't anyway because it does not recognize the file system.


btw:
oops, I already had linux as master, I just got confused about the hds. hehe. Thanks though for good future reference.


This topic is closed to new replies.

Advertisement