Skip to content

Drive upgrade: Ubuntu and Windows 7 dual boot main drive

Replacing the hard drive and keeping the installed systems working is both trivial and tricky, especially if you are not doing an exact clone of the entire drive. In my case, I wanted to simplify the drive layout by not including the Windows recovery partitions and by changing the size of the data partition.

First get a USB drive adapter so you can plug in your target drive and have at it. — Always have a good backup, too. Make sure it is a usable backup and completely separate from the hardware you are working on.

Grab your multiboot USB (multiple boot from ISO on USB pen drive) stick and boot up a current live CD edition of Ubuntu.

Then partition the target drive as you want it. Gparted does well for this and is on the live CD. Make the target partitions for the systems the same size as the existing partitions. Data partitions (the home directory in my case) can be sized to fit what remains as they will be copied via rsync rather than image copy,

Gparted will also do a partition image copy and paste from the existing system partitions to your new ones. That worked for me for both systems.

Mount the existing and target data drives and use rsync to copy the home directories with all the configuration files, email store, bookmarks, and whatnot.

At this point you (should) only have to worry about being able to boot your new drive.

For Ubuntu, mount the target root partition to, say, /mnt/newroot. Check etc/fstab there. The cloned system drive will probably have the same UUID as the existing one so the definition of the root mount should be OK. The home partition, if you do as I did and not clone, will have a different UUID. In Gparted, check the information for the target partition, select the UUID, copy, and paste as a replacement in your target fstab home mount entry. Do check the UUID for the root partition just to be sure.

To make the target drive bootable, run (with appropriate substitutions for your configuration, sdx is the target drive in this example)
grub-install --root-directory=/mnt/newroot /dev/sdx

Now you can remove the existing drive and install your new one.

The new drive should boot with both Ubuntu and Windows in the GRUB menu. Ubuntu should boot and you should be just as you were with the old disk.

Windows is another issue. It will likely come up with a complaint about a corrupt BootMgr. That is the file Windows uses that serves a purpose somewhat like fstab does for Ubuntu. The easiest way to repair it is to use a Windows install or upgrade DVD. Boot the DVD and choose the repair option and then startup repair. I had to run through a couple of boots from the DVD to get BootMgr fixed. There are other ways including copying the file off the DVD and using a special utility and running a start repair command line utility on the DVD. Once BootMgr is fixed, Windows should boot OK. On my machine, it detected a new drive, loaded new drivers, and requested a reboot for them to take effect.

Now you can resize the partitions if you want to, Run the LiveCD, launch gparted, and have at it. As long as you don’t rearrange the order or numbering of the partitions, have a good backup, and check and recheck and take appropriate precautions, you should be able to get your new drive configured just how you want it.

UPDATE: one reason the Windows BootMGR might be a problem is that it is often on a “system reserved” 100 MB partition. If you are removing this partition to simplify things like I did, then you’ll have to fix the Windows boot by getting that stuff on the primary windows partition. This additional partition may also be why the GRUB install shows 2 bootable Windows partitions when it exists. At least, with Windows 7, it doesn’t overwrite the MBR and wipe out GRUB.

Also note that I told gparted to set up the disk as MBR (msdos) rather than the newer GPT. GPT is coming with EFI replacing BIOS but such modern advances aren’t really needed with sub-2TB drives.

ALSO – note that the Ubuntu system uses two partitions, root and home, and a swapfile rather than a swap partition. Other configurations might require additional considerations.

{ 1 } Trackback

  1. […] way to go. Boot a Linux system off CD or USB and then re-initialize the GRUB that is there – see Drive upgrade: Ubuntu and Windows 7 dual boot main drive for examples. A Grub re-initialization (command: grub-install –root-directory=/mnt/newroot […]

Post a Comment

You must be logged in to post a comment.