Leatherboard1

Changing the MBR to Windows or Linux boot with a Linux rescue or live CD

Now a lot of people use Linux and Windows and dual boot them (like me), sometimes after we install one system, we want another's boot back etc. Here are a few different situations and how you change the MBR.



* You installed Windows which ruined dual boot with Linux and you want the dual boot back.


o With some Linux CDs (I've used Fedora rescue CD and Ubuntu live CDs to do this and it should work with a

lot of other Linux live / rescue CDs)



Go to Linux rescue mode (usually by pressig F5)



Then after a while you get to a system prompt: sh#



grub then enter



root (hdX,Y) then enter



(hdX,Y) is the (Y-1)th partition on your (X-1)th hard drive. If you have done a dual-boot install, you should

usually know. If your /boot is on /dev/sda7 and you only have one hard disk, it translates to hd0,6. (If you don't

know the disk/partition, the method below would be nice because you can search for it.)



setup (hd0)



quit



and reboot




* With a Ubuntu Live CD (or some other sort of Live CD)




Boot from a Ubuntu live CD (or some other Linux live CD)



Open a terminal, run the following as a superuser (or you can do sudo grub in Ubuntu).



grub



(find /boot/grub/stage1 when you don't know where your boot files are. (Or sudo fdisk -l also gives you some

information, your Linux partition is most likely the one with Ext3))



root (hdX,Y) (Again, (hdX,Y) is the (Y-1)th partition on your (X-1)th hard drive. If you have done a dual-boot

install, you should usually know. If your /boot is on /dev/sda7 and you only have one hard disk, it translates to

hd0,6)



setup (hd0) (to write to MBR. If you want to write the boot information to your Linux partition, then setup (hdX,Y))



quit



and reboot.




* You want your Windows MBR back with Ubuntu Live CD (I guess some other distributions have ms-sys functionality

too. I think I've heard of Knoppix being able to fix Windows MBR. If you know, please comment.)





Boot into your Ubuntu LiveCD



Go to System -> Administration -> Software Sources and enable (by checking it off) the Universal repository.



Open a terminal session (Applications -> Accessories -> Terminal) and type the following:




sudo apt-get install ms-sys






Use



sudo fdisk -l



to figure out which partition your Windows is on. (Most likely the ones with NTFS or FAT32)



We want to fix the MBR, on /dev/sda1. To do so, type:




sudo ms-sys -mbr /dev/sda1






(if your Windows is not on /dev/sda1, change that part.)



reboot.



Sources:



http://ubuntuforums.org/showpost.php?p=117829&postcount=2
http://ubuntuforums.org/showpost.php?p=121355&postcount=5
http://www.arsgeek.com.nyud.net:8080/?p=3340

No comments: