A couple of days ago, I discovered that the single 2,5" IDE disk containing the root file system of my home server had an error. I don't like errors on a device which is not duplicated. So I went out and bought a new (SSD) drive.

Instead of reinstalling Ubuntu, and thus remove all the config and tweaks I've made during the last couple of years, I decided to simply move the file system to the new disk.

I turned out to be even easier than expected. Apart from my being unable to find anything usb that the motherboard is able to boot, and having to temporarily attach a IDE cdrom drive, everything went smoothly.

The partition scheme for the old drive is:
* root partition (primary)
* extended
* swap (logical)

I have no idea why I originally created the extended partition, but my goal is to avoid that on the new disk, and just have two primary partitions:

* root partition
* swap

These were the steps I took:
1: Attach the new drive (SATA)
2: Boot an Ubuntu 9.10 Beta live cd (probably works with older versions, but this on was at hand.
3: Open GParted (System -> Administration -> GParted)
4: Choose the old drive (In my case /dev/sda)
5: Right-click on the root partition; select Copy
6: Choose the new drive (In my case /dev/sdb)
7: Right-click on the empty space; select Paste
8: Confirm the creation of a Partition table
9: Resize the new partition, leaving just enough room for the swap space
10: Create swap partition in the remaining free space
11: Commit the changes and wait, or go do the dishes, as I did.
12: Mount the new root int /mnt: sudo mount /dev/sdb1 /mnt
13: Chroot to the new drive to use grub in the correct version.
14: run grub sudo grub
15: Following the steps outlined in this howto: http://ubuntuforums.org/showthread.php?t=224351, I issued the following in the grub shell:
15.1: find /boot/grub/stage1 (hd1 is the new drive)
15.2: root (hd1,0)
15.3: setup (hd0)
15.4: quit
16: Shutdown. Remove old drive and start again..
17. Use blkid to get the UUID of the new swap partition
18. Replace the swap partition UUID in /etc/fstab with the one we just obtained.
19. Use sudo mount -a to mount the swap space.

And we're back in business..

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.