Wednesday, March 11, 2009

Moving Ubuntu to another partition

So, I bought a new hard disc drive and I just wanted to split my windows installation to that of ubuntu. But I didn't want anything to change. I wanted my ubuntu installation to be exactly as it is. No reinstalling, no tweaking from the start. While moving Windows was a pain, ubuntu was very easy to move.

First of all I used this command line
sudo lshw -businfo -C disk

just to see how linux names my partitions. Using also the "df" command I double-checked that my linux partition was indeed located at sda1 and that I wanted to move it to sdb1. After that, I decided to move my partition with this line
dd if=/dev/sda1 of=/dev/sdb1

Watch that I wanted to move my partition from sda1 (the if parameter) to sdb1 (the of parameter). I must say the partitions were not identical, but we'll get to that in a while. Once finished I shut down the PC. Then I disconnected the sda hard disc drive. Here comes the tricky part. Now I don't recall whether or not I used my live cd... But once I got to the terminal (see ubuntu can't find grub), I typed these lines:
sudo grub
>find /boot/grub/stage1

That will answer a thing something like hd(z,0). Note the z number, you will need it. Then type (and replace the z number to that of your own),
>root hd(z,0)
>setup (hdz)
>quit

And that's it. Linux should now load.

In case that the two partitions were not identical, download and burn to rewritable CD the gparted program, then boot from it. Then just resize the linux partition to whatever size you want, and the sizes will fix.

No comments:

Post a Comment