Author Topic: Question - Using dd to clone different sized disks?  (Read 2225 times)

Offline Freedom Kira

  • Member
  • Posts: 4324
  • Rawr™.
Question - Using dd to clone different sized disks?
« on: May 05, 2011, 09:43:32 PM »
Alrighty. Another problem, this time from a coworker.

Ever since upgrading from Ubuntu 10.04 to 10.10, he's noticed the system has been running slower and slower.

One day, he decided to swap his HDD to a new one. He booted Ubuntu with a Live CD and used dd to clone the disk. When he booted with the new drive, the speeds were back to normal.

However, there's a small problem. When he cloned the disk, he (obviously) also cloned the partition table. His old disk was 200GB, and his new one is 250GB. The new disk has been partitioned into 200GB and a 50GB "swap" partition. GParted won't let him extend the partition from 200GB to 250GB.

Any ideas?
Other computer specs unknown, though I could ask him if necessary. Filesystem is ext3 if I'm not mistaken.

Offline toaow

  • Member
  • Posts: 17
Re: Question - Using dd to clone different sized disks?
« Reply #1 on: May 05, 2011, 10:03:33 PM »
If the partition is in use, Gparted won't work. Your friend has to resize the partition by booting from a LiveCD. I recommend using Parted Magic:

http://partedmagic.com/doku.php

You could also use an Ubuntu LiveCD, but the gparted version on Ubuntu is usually a couple of versions older. Plus Parted Magic contains several other rescue/repair tools.

Offline Freedom Kira

  • Member
  • Posts: 4324
  • Rawr™.
Re: Question - Using dd to clone different sized disks?
« Reply #2 on: May 05, 2011, 10:12:44 PM »
Not sure if you quite understood. He booted from the Ubuntu Live CD to do the dd, and when he tried GParted from there it didn't let him extend the partition. So, from what you're saying, GParted won't allow resizing of the partition like that?

I'm getting him to check this thread every so often, so if anyone's got any more suggestions, feel free to throw them in.

Offline toaow

  • Member
  • Posts: 17
Re: Question - Using dd to clone different sized disks?
« Reply #3 on: May 05, 2011, 10:27:04 PM »
Did he reboot to the LiveCD in between the dd operation and attempting to resize? Trying to do it from GParted after booting from the hard disk won't work. You have to reboot from a LiveCD and NOT mount any partitions, then run GParted.

Offline bork

  • Member
  • Posts: 251
  • Huh ?
Re: Question - Using dd to clone different sized disks?
« Reply #4 on: May 06, 2011, 01:27:02 AM »
I have never used dd to clone my boot drive, used a script that mount the partitions on both existing drive and the new drive while in single user and runs dump to move.  If interested, I can provide more details. 

Offline Freedom Kira

  • Member
  • Posts: 4324
  • Rawr™.
Re: Question - Using dd to clone different sized disks?
« Reply #5 on: May 06, 2011, 04:16:03 AM »
Did he reboot to the LiveCD in between the dd operation and attempting to resize? Trying to do it from GParted after booting from the hard disk won't work. You have to reboot from a LiveCD and NOT mount any partitions, then run GParted.

Ah, I believe he did. In that case, wouldn't unmounting the drive and all partitions be sufficient?

I have never used dd to clone my boot drive, used a script that mount the partitions on both existing drive and the new drive while in single user and runs dump to move.  If interested, I can provide more details. 

If I understand correctly, this does a simple data copy of all the data existing on the drive. It doesn't copy partition tables or MBR, which would mean he would have ended up with a drive that contained all the data except for how to boot. Which doesn't make for a very useful boot drive...

Offline toaow

  • Member
  • Posts: 17
Re: Question - Using dd to clone different sized disks?
« Reply #6 on: May 06, 2011, 04:49:33 AM »
Did he reboot to the LiveCD in between the dd operation and attempting to resize? Trying to do it from GParted after booting from the hard disk won't work. You have to reboot from a LiveCD and NOT mount any partitions, then run GParted.

Ah, I believe he did. In that case, wouldn't unmounting the drive and all partitions be sufficient?


It should be. IF all partitions were unmounted and GParted didn't allow a resize, then there's a problem with MBR, or the partition table, or the partition is marked as in use for some reason. Unmount the partition, and run fsck -f on it, then reboot with the LiveCD.

Some older BIOSes don't recognize disks above a certain size, that isn't the case here, is it? You'd know by going to the BIOS setup screen and seeing if it recognized the full size of the disk in question.

Offline kureshii

  • Former Staff
  • Member
  • Posts: 4485
  • May typeset edited light novels if asked nicely.
Re: Question - Using dd to clone different sized disks?
« Reply #7 on: May 06, 2011, 05:13:12 AM »
Stupid question, but has he already resized and moved the swap partition? Can't overwrite an existing partition after all... also, some clue from the error message would be nice.

Might also be worth noting that GParted needs root privileges to carry out some tasks. App launcher is probably running it as user; try "gksu gparted" from a terminal window.
« Last Edit: May 06, 2011, 05:14:54 AM by kureshii »

Offline billlanam

  • Member
  • Posts: 316
Re: Question - Using dd to clone different sized disks?
« Reply #8 on: May 06, 2011, 05:39:26 AM »
You could first delete the swap partition, then try to resize the your main partition, and then create a new swap partition.
All this while booted from the livecd, without any of the hard drive's partitions being mounted.
You might have to edit the fstab file in order to use the swap partition again.

Offline Freedom Kira

  • Member
  • Posts: 4324
  • Rawr™.
Re: Question - Using dd to clone different sized disks?
« Reply #9 on: May 06, 2011, 03:11:44 PM »
Here's a reply from him.

Quote from: Coworker
I used the livecd of gparted too - different cd so had to reboot. Actually tried a couple of times, and it did let me format the remaining 50g.
I'm pretty sure gparted was running as root because I change the privileges on the new 50g from root to myself.

I should probably try the delete - resize - recreate suggestion...

Some older BIOSes don't recognize disks above a certain size, that isn't the case here, is it? You'd know by going to the BIOS setup screen and seeing if it recognized the full size of the disk in question.

Can't be. It's only 50GB more than what he used to use. And the 50GB shows up in the OS.

Stupid question, but has he already resized and moved the swap partition? Can't overwrite an existing partition after all... also, some clue from the error message would be nice.

Might also be worth noting that GParted needs root privileges to carry out some tasks. App launcher is probably running it as user; try "gksu gparted" from a terminal window.

That stupid question might just be the case... >.>
Gotta hate it when those "did you turn on the printer?" questions actually give you the solution.

Also, from my experience, GParted doesn't let you run it as user. IIRC, whenever I try to run it from System -> Administrative Tools/Administration/whatever, it always asks me to login as root before I can continue.

You could first delete the swap partition, then try to resize the your main partition, and then create a new swap partition.
All this while booted from the livecd, without any of the hard drive's partitions being mounted.
You might have to edit the fstab file in order to use the swap partition again.

That's most likely the solution we all have in mind.

Offline bork

  • Member
  • Posts: 251
  • Huh ?
Re: Question - Using dd to clone different sized disks?
« Reply #10 on: May 06, 2011, 03:29:07 PM »
I have never used dd to clone my boot drive, used a script that mount the partitions on both existing drive and the new drive while in single user and runs dump to move.  If interested, I can provide more details.  

If I understand correctly, this does a simple data copy of all the data existing on the drive. It doesn't copy partition tables or MBR, which would mean he would have ended up with a drive that contained all the data except for how to boot. Which doesn't make for a very useful boot drive...

I did not include many details, did not know if there was much interest in an alternate method migrating from one hard drive to another. I will explain it now -

(click to show/hide)
« Last Edit: May 06, 2011, 04:07:36 PM by bork »

Offline Freedom Kira

  • Member
  • Posts: 4324
  • Rawr™.
Re: Question - Using dd to clone different sized disks?
« Reply #11 on: May 06, 2011, 03:51:05 PM »
I still think that only migrates data without copying partition tables or the MBR, MBR being the key point here.

Useful info nonetheless, though.

Offline bork

  • Member
  • Posts: 251
  • Huh ?
Re: Question - Using dd to clone different sized disks?
« Reply #12 on: May 06, 2011, 03:56:30 PM »
It is a manual method, it does not move partition tables.  The disk partitions are created manually when you are doing the "minimal install" of the procedure on the new disk.  I sort of avoid "automated" cloning, I do not like my loss of control of what some of these methods do.  Its mostly due to my past experiences of upgrades gone bad that I do not trust them.
« Last Edit: May 06, 2011, 04:01:50 PM by bork »

Offline Freedom Kira

  • Member
  • Posts: 4324
  • Rawr™.
Re: Question - Using dd to clone different sized disks?
« Reply #13 on: May 06, 2011, 07:19:09 PM »
The thing is, with that method you need to do an install, even if it is minimal. Using the dd command will get you a bootable disk without needing to reinstall, because it just dumps the contents of one drive onto another. Which is ideal when both disks are the same size, of course...

Edit: Problem solved. He says he ended up deleting and recreating the swap partition. I think this means he deleted the swap and extended his original partition... But whatever.
« Last Edit: May 09, 2011, 01:32:24 PM by Freedom Kira »