Ubuntu – How to preserve/export the current Ubuntu installation after changing to a new SSD & installing Windows7

backuppackage-managementssdwindows 7

Ok, currently got set up:

  • Puny little old 40GB hard drive
  • AMD Athlon II X2 245
  • 4GB DDR3 RAM

Planning to upgrade to:

  • 120GB SSD hard drive (40GB is getting a little tight for me, but 120GB
    is plenty for my purposes and the speed boost would be nice)
  • AMD Athlon II X2 245
  • 4GB DDR3 RAM
  • Radeon HD7770 1GB DDR5 (going to start doing a bit of light gaming,
    is the only reason I use Windows at all!)

My question is how can I install Windows7 then Ubuntu on my new SSD and still preserve my settings/data I've currently got in Ubuntu? Such as the applications I've got installed already, files, passwords & bookmarks saved in various browsers, settings, etc
(I don't care in the slightest however about what is currently on my Windows XP installation!)

I forgot to mention an important point that I would have to reinstalled Ubuntu as originally I just installed it using a random Ubuntu Live CD 10.04 32-bit that I had at hand (and since upgraded to 12.04 32-bit via the automatic update), but I would like to change to 12.04 64-bit instead (just downloaded it last night, and I'll burn it to a DVD this evening).

Best Answer

Are you able to physically connect both hard drives in the same machine? If so, great, the steps are easy. I'll outline each one, and you may ask for details for each if you are unsure about them.

1 - Connect the new drive, disconnect the old one. Install Windows from DVD as you would in a clean, fresh machine.

2 - Once Windows is installed and working fine, power off and connect the old hard drive.

3 - Boot using Ubuntu Live CD

4 - Start gparted, shrink the Windows partition to make room for Ubuntu. I suggest shrinking to the minimum size plus approx 15/20GB. Create an extended partition to take up the all the remaining space

5 - Copy the Ubuntu partition from the old to the new drive, inside the extended partition. Copy the swap partition too, if you have one. Yes, gparted can copy and paste partitions from one drive to the other ;)

6 - You may resize the Ubuntu partition a few gigs, but I suggest leaving room for a brand new NTFS "data" partition, which in the future can be used by both systems to store your music, videos, documents, downloads, etc.

6.5 - Also, if you don't have a swap partition yet, create or leave room for one. Size should be at least equal to your RAM, to enable hibernation.

7 - You now should have these partitions: 2 primary ones created by Windows (a 100MB one and the shrank one, ~30GB), an extended partition taking the rest of the disk, the Ubuntu logical partition inside it (~30GB too), the swap, and a lot of free space (or your newly-created NTFS "data" partition). Label those partitions accordingly, so it's easy to tell them apart.

8 - Power off, disconnect the old hard drive, boot again using the Ubuntu Live CD

9 - Follow these instructions to reinstall grub and make Ubuntu boot again

10 - Done! :-)

A few remarks, taken from comments so they don't look like a chat window:

If instead of keeping the same install you want to change from 32 to 64 bits, within the same Ubuntu release, you may simply install the 64 Ubuntu on top of the 32 (just select the same partition), and the install will keep your /home, settings and packages. And you don't even need to backup: you already have your old drive as one ;)

If upgrading version, I would consider formatting the partition and forget about restoring settings and apps. Because settings from an older app may not apply to a newer version of the same app. Even software selection is fuzzy: some packages are deprecated / renamed / not necessary in newer releases, so not worth the trouble. Just open Software Center and manually install the apps you want.

In this case, it really pays off to keep your "OS-independent" data files (Music, Videos, Documents, etc) in a separate partition, so "your stuff" is always available regardless of Windows or Ubuntu version installed.

Related Question