Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two drives on my computer that have the following configuration:

Drive 1: 160GB, /home
Drive 2: 40GB, /boot and /

Unfortunately, drive 2 seems to be dying, because trying to write to it is giving me errors, and checking out the SMART settings shows a sad state of affairs.

I have plenty of space on Drive 1, so what I'd like to do is move the / and /boot partitions to it, remove Drive 2 from the system, replace Drive 2 with a new drive, then reverse the process.

I imagine I need to do some updating to grub, and I need to move some things around, but I'm pretty baffled how to exactly go about this. Since this is my main computer, I want to be careful not to mess things up so I can't boot.

share|improve this question

You'll need to boot from a live cd. Add partitions for them to disk 1, copy all the contents over, and then use sudo blkid to get the UUID of each partition. On disk 1's new /, edit the /etc/fstab to use the new UUIDs you just looked up.

Updating GRUB depends on whether it's GRUB1 or GRUB2. If GRUB1, you need to edit /boot/grub/

If GRUB2, I think you need to mount your partitions as they would be in a real situation. For example:

sudo mkdir /media/root
sudo mount /dev/sda1 /media/root
sudo mount /dev/sda2 /media/root/boot
sudo mount /dev/sda3 /media/root/home

(Filling in whatever the actual partitions are that you copied things to, of course)

Then bind mount /proc and /dev in the /media/root:

sudo mount -B /proc /media/root/proc
sudo mount -B /dev /media/root/dev
sudo mount -B /sys /media/root/sys

Now chroot into the drive so you can force GRUB to update itself according to the new layout:

sudo chroot /media/root
sudo update-grub

The second command will make one complaint (I forget what it is though...), but that's ok to ignore.

Test it by removing the bad drive. If it doesn't work, the bad drive should still be able to boot the system, but I believe these are all the necessary steps.

share|improve this answer
Wow, fantastically complete answer, thank you! – mlissner Sep 4 '10 at 1:28

If you replace the drive right away you can use the "dd"-Program (tried it on my server some months ago, worked like a charm).

You'll need a boot-CD for this as well.

  • Start boot-CD - only mount Drive 1
  • Type "dd if=/dev/sdb1 of=/media/drive1/backuproot.img" - sdb1 being your root (/) partition. This will save the whole partition in a file.
  • same for /boot
  • reboot/replace disk
  • "dd if=/media/drive1/backuproot.img of=/dev/sdb1" - write it back.
  • Same for /boot

The above will create 2 partitions with the exact same size as they had before. You might need to adjust grub (check macos post).

If you want to resize your partitions (as i did):

  • Create 2 Partitions on the new drive (for / and /boot; size whatever you want)
  • Mount the backup-image: "mount /media/drive1/backuproot.img /media/backuproot/"
  • Mount the empty /-Partition "mount /dev/sdb1 /media/sdb1/"
  • copy its contents to the new partition (i'm unsure about this command, it's really important to preserve ownership, cp -R won't do it!) "cp -R --preserve=all /media/backuproot/* /media/sdb1"
  • same for /boot/

This should do it.

share|improve this answer
It turns out that the new "40GB" drive I'm trying to install is smaller than my current "40GB" drive. I have both of them connected, and I'm booted into a liveCD. Is there an easy way to just dd from the old one to the new one, and call it a done deal? – mlissner Sep 4 '10 at 3:02
Actually, I sorted this question out. The partition that was too big was an ext4 partition, so I booted a liveCD, and used gparted to shrink it a bit. – mlissner Sep 4 '10 at 8:31
up vote 1 down vote accepted

My final solution to this was a combination of a number of techniques. I connected the dyring drive and its replacement to the computer simultaneously. The new drive was smaller than the old, so I shrank the partitions on the old using gparted. After doing that, I copied the partitions on the old drive, and pasted them on the new (also using gparted). Next, I added the boot flag to the correct partition on the new drive, so it was effectively a mirror of the old drive.

This all worked well, but I needed to update grub2 per the instructions here:

After all this was done, things seem to work. Thanks to everybody for their help.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.