Ubuntu – How to migrate Ubuntu/Windows 7 dualboot from HDD to HDD+SSD without reinstall


I have a working dual-boot setup (Ubuntu 12.10 and Win7) on my laptop.
I got a 320GB HDD with partitions for /, /home, swap, winsys and a big windata partition. There's more than 250GB space occupied overall.

Now I bought a 250GB SSD which I will put in my Ultrabay, and I want to migrate all the partitions except the big data partition onto the SSD, enlarge them in a controlled manner according to SSD space, leave windata on the HDD, and expand it to the whole size. I want to avoid a fresh installation of both Ubuntu and Windows.

I read quite much already, but I'm unsure what the best way to accomplish this is?

  • Clonezilla disk-to-disk clone is out, because the target disk is smaller.
  • Clonezilla partitions-to-partitions (omitting the data partition) seems to be a way, but I can only enlarge the partitions proportionally (even if I can), and I don't know if this will create proper SSD partition alignment. Also, what about the boot sector/boot loader, especially w.r.t. dualboot?
  • The sanest way seems to be to use GParted from a live cd, create the partitions on the SSD as desired, then copy the HDD partitions into the new ones, and expand the data partition on the HDD. This seems to me the most uncomplicated way – GParted can do proper alignment, but I don't know if the boot loader can be copied, too? Also, if this works, why does everybody seem to recommend Clonezilla?
  • my boot partition is the first partition (sda1), where the windows system resides on.

Will doing this purely in GParted work? Can I safely drop the extended partitions setup (which I don't need anymore because now I only got 4 partitions per disk)? Or should I keep that around anyway if I want to further subdivide in the future (for a scratch disk etc)

Bonus question: my /home is still ext2 – can I make the new /home ext4, and copy the ext2 partition over, and it won't break?

I'm aware that I'll have to rewrite the /etc/fstab to adjust the UUIDs, and that I'll probably need a Windows rescue disk to "repair" the confused windows boot system. Any further pitfalls?

fdisk -l output:

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x80d2f3ee

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63   104856254    52428096    7  HPFS/NTFS/exFAT
/dev/sda2       184538655   625137344   220299345    7  HPFS/NTFS/exFAT
/dev/sda3       104856255   136311524    15727635   83  Linux
/dev/sda4       136311649   184538654    24113503    5  Extended
/dev/sda5       148890420   184538654    17824117+  83  Linux
/dev/sda6       136311651   148874354     6281352   82  Linux swap / Solaris

Partition table entries are not in disk order

Best Answer

I would use GParted to copy the / and winsys partitions.

Grub/linux will boot after the copy as long as you run Boot Repair. And according to this article, windows should be able to be moved with GParted as long as you have a windows repair disk to repair the installation after moving it.

Although you can safely drop the extended partition on the new drive as long as you only have 4 primary partitions, I wouldn't recommend it. Probably you will want to make the ssd into one extended partition and put all of the other partitions inside that one extended one.

Of course doing operations like this can always fail, even if the cause is something arbitrary like the power going out of the live cd failing, so definitely take a backup of your data before copying it. And I would also recommend that you don't make any changes to the HHD until you have successfully booted into the SSD with both windows and linux.

Probably the steps you would want to take are:

Boot into live CD and run GParted.

Make an extended partition on the SSD covering the whole drive.

Copy linux / partition and winsys partition to SSD, leaving the original still unchanged on the HHD.

If you wanted /home on the SSD, then make a new ext4 partition inside the extended partition, and use rsync to copy all data from the original to the copy. An example rsync command could be like this:

sudo rsync -rhtvlpEog --progress /media/PATH_TO_HOME_PARTITION_ON_HHD/ /media/PATH_TO_HOME_PARTITION_ON_SSD/

explaination of that command: -r copies recursivly, -h gives human readable output, -t preserves modification times, -v gives more output, -l copies symlinks as symlinks, -p keeps file permissions, -E keeps executablility, -o keeps owner, and -g keeps group.

Mark winsys and / as bootable on the SSD.

Unmount and possibly disconnect your HHD from the computer, then run boot-repair, install grub to the SSD and making the / bootable.

still from the live CD, edit the fstab on the SSD / partition to have the new /home partition UUID.

Test that grub/linux works by booting your computer with only SSD mounted. (Also test that you have all the data in your /home partition)

Then if it does, use a windows repair disk to get the windows partition on the SSD bootable.

After using windows repair disk on the SSD, try booting into both windows and linux, without connecting the HHD.

Note: Be sure to not delete or move anything on the HHD, until you have confirmed that both windows and linux work on the SSD.

If all works on the SSD, then erase the /, /home, and winsys partitions from the HHD, and expand the windata partition to use the whole thing.

I have outlined the steps that I would take. I can't vouch for the windows repair disk working, but according to that article it should. I can vouch for Boot Repair working when moving the / partition though. I know that that works because I have moved my partitions around quite a lot using GParted.

Also if any of these steps fail and the SSD isn't bootable, you still have all of your data and everything still working on the HHD.

Additional experiences from the OP:

  • It's good to have 3 live CDs/USB sticks - GParted Live, boot-repair, windows system repair, I needed all three of them
  • I ended up not converting the home partition, so I didn't use the rsync step
  • Be aware that on partition copying, the UUIDs (unique partition identifiers) stay the same. This is great because you don't have to edit the Ubuntu fstab, and Windows won't want to be activated again, but after the initial copying stage, for testing you should remove/unplug the HDD from the system, otherwise there exist multiple partitions with the same UUID. This would have unexpected results.
  • Useful tools for making bootable USB sticks (if you don't have a CD drive anymore) from live CD images are tuxboot, unetbootin, TotalMounter. Especially for the Windows system repair disk, this can be tricky - use TotalMounter to create it directly into an .iso, and e.g. this guide.
Related Question