Sunday, May 9, 2010

Install Windows after Ubuntu Lucid Lynx

Sh*t happens. There is no more applications to manage my 6th generation iPod Classic 160 GB under Linux/Ubuntu. I have to install Windows as the second operating system along with newly installed Ubuntu Lucid Lynx (it rocks but this is for another post) to run iTunes.

For rather long time I’ve been using gtkpod, amarok, banshee, exaile or rhythmbox to sync my ipod under Linux/Ubuntu and load my music collection there. As we all know The Elder Brother Apple fights with interoperability and makes ipod/iphone users to use iTunes only. Any other applications that can read/write to ipod data format are prohibited by Apple. This also concerns Rockbox and ipod4linux alternative firmwares — once Apple encrypted ipod firmware it became impossible to use them. It definitely sucks. At least due to the fact there are millions of Linux users who are real or potential customers of Apple products. Anyways these facts have been discussed in various forums, blogs like this and similar but this post about how to install Windows as the second operating system along with Ubuntu or any other Linux.

gparted exampleThe first that we need to do is to create new partition for Windows and format it to NTFS. Exact steps to accomplish this depend on your HDD partition table e.g. there is one large ext3/ext4 partition for Ubuntu or there are several partitions for various distributions or mount points. Anyway you should use partition manager to create and/or format NTFS partition. I use gparted. It is graphical and it just works (use ‘sudo apt-get install gparted‘ if you run Ubuntu/Debian).

Second you should backup your MBR record and restore it after Windows installation that silently erases existing bootloader and installs windows one, use “dd if=/dev/sda of=/mbr.bin bs=446 count=1” to save MRB into mbr.bin file and “dd if=/media/sda/mbr.bin of=/dev/sda bs=446 count=1” to restore it from file to HDD.

To sum everything up here is the algorithm:

0. BACKUP ALL YOUR DATA!
1. Create NTFS partition using gparted.
2. Backup MBR using dd command e.g. “dd if=/dev/sda of=/mbr.bin bs=446 count=1″ (/dev/sda means your HDD).
3. Boot Windows installation CD and install it onto newly created NTFS partition.
4. Boot into Linux live CD e.g. Ubuntu Live CD.
5. Restore MBR using dd e.g. “dd if=/media/sda/mbr.bin of=/dev/sda bs=446 count=1″.
6. Reboot.
7. Select Ubuntu in grub menu and boot it.
8. Setup grup for Windows booting.

In order to accomplish the last 8th item you should add the following text block to the end of grub config (read this article for detailed information):

title Microsoft Windows XP
root (hd0,1)
savedefault
makeactive
chainloader +1

Good luck!

P.S. If something goes wrong or you need more details you can take a look at the following article at ubuntu.com: Recovering Ubuntu After Installing Windows. It’s written in rather tangled manner but still informative.