Saturday, 27 February 2010

converting wubi to dedicated linux partition

Over last weekend, I decided that I wanted to ditch Windows 7 in favour of linux. But, I didn't really want to re-install from scratch and I had previously installed Ubuntu in the windows partition using wubi.
Although it did get a bit hairy for a while (at one point I was unable to boot into the Wubi or the dedicated partition). So, I decided I should share the experience I had and hopefully help others avoid the problems I had.

Firstly, I needed to create some partitioned space, I was going to resize the partitions using gparted, but I didn't like the way that the current Windows Partitions were defined so, I rebooted and booted Windows 7 and before making changes to the partitions I copied the Ubuntu directory from D:\ to C:\ then I deleted the partitions I didn't want (leaving C:\ intact).   I recreated a new smaller partition for drive D:\ and then copied the everything c:\ubuntu to d:\ubuntu. 

I rebooted and then tried to boot into my linux wubi install.  The Grub menu loaded and I selected the default option at which point Grub reported that the kernel wasn't loaded......WHAT - NOOOO!! I rebooted again and at the grub menu, I selected edit line option to see what the configuration was.....the boot options were configured to boot from /dev/sda5 whereas after re-partitioning the buntu image was on /dev/sda3.  After changing the options to reflect /dev/sda3 ubuntu booted fine.

Not wanting to loose everything, I decided to backed up the entire wubi install to a USB HDD using tar.

After linux had booted I used Gparted to create 3 new partitions:

A 10 GB (ext3 format) partition to use as root (/),
A ~3 GB (equal to RAM size) (swap format) partition to use as swap, and the rest a (ext3 format) partition to use as /home.

After creating the partitions I mounted the home partition to /media/home and used rsync to copy the /home to the new partition.

rsync -avx /home/ /media/home

To avoid the hassle of manually reinstalling all the packages again I used the command:

dpkg --get-selections > selections.dpkg

I popped in my ubuntu install CD and rebooted...The ubuntu install started and at the partitioning stage I selected the "manual" option (making sure to specify the appropriate correct partition for each of the mountpoints for root (/) home (/home) and swap.  I also made sure that the format partition option was un-ticked.

I also made sure that I ensured that the account name was the same as the one I configured for my wubi install.

After the installation was complete and I booted into the dedicated linux partition, configured my Internet connection and then loaded the Synaptic package manager & selected "read markings" from file menu;  I loaded the selections.dpkg file that I created earlier and began to download the packages/updates.

The packages started to install but something went wrong and the process stopped.   I rebooted & the new dedicated linux partition wouldn't load (it seemed to freeze on boot up).

I rebooted and tried to boot the original wubi install, but that seemed to fail too...So I used the install CD selecting the option to try Linux without installing.

I mounted the root partition from my new install to a temporary mountpoint and then connected the USB HDD that had the tar backup on it.   I then used the tar command to restore the backup.tar file but excluded restoring the /home, /boot & /proc directories.

tar xvf /media/disk1/backup.tar --exclude /boot --exclude /home --exclude /proc

after the restore I shutdown, removed the CD and booted grub to the new dedicated partition.   everything appeared to boot fine, so I opened a terminal session and type df

the output from df showed that the home directory was loop0 device???? i had forgot the exclude /etc when restoring the tar, meaning the /etc/fstab file from my original wubi install was loaded....   

I modified the /etc/fstab file to reflect the device partitions and mount-points for my install:

/dev/sda5       /               ext3    loop,errors=remount-ro 0       1
/dev/sda6       none            swap    loop,sw         0       0
/dev/sda7       /home ext3 nodev,nosuid 0 2

I rebooted & everything was fine.........

I re-ran the package manager and everything was up to date.  After checking that the system was stable, I rebooted into Windows 7 and remove the wubi install.  (I think I will leave Windows 7 in place for another week just in-case!)

1 comment: