Cloning hard disks

"Please leave a message at the beep, we will get back to you when your support contract expires."

Moderators: phlip, Moderators General, Prelates

User avatar
Zamfir
I built a novelty castle, the irony was lost on some.
Posts: 7594
Joined: Wed Aug 27, 2008 2:43 pm UTC
Location: Nederland

Cloning hard disks

Postby Zamfir » Tue Feb 15, 2011 12:03 pm UTC

I recently made some attempts with CloneZilla to clone hard disks with Windows on them, in order to replace a small disk by a larger with as little work as necessary.

In both cases, the results were bad. For both machines I had to run Windows' repair utility, and in one case that was not enough to make the system boot all the way to a desktop. In the other case the system eventually booted all the way, but there were strange instabilities and crashes. So I ended up installing the OS from scratch on both systems.

Do people have better experiences than this? It would be really helpful if I could just replace hard drives without reinstalling stuff, and there shouldn't be fundamental reason why I couldn't.

User avatar
Meteorswarm
Posts: 979
Joined: Sun Dec 27, 2009 12:28 am UTC
Location: Ithaca, NY

Re: Cloning hard disks

Postby Meteorswarm » Tue Feb 15, 2011 10:22 pm UTC

I've had good experiences using dd under Linux (and the hardier version on the system rescue CD), but nothing on Windows. Also, be DAMN sure you've got the order of your program arguments right.
The same as the old Meteorswarm, now with fewer posts!

archeleus
Posts: 240
Joined: Wed Sep 29, 2010 1:49 pm UTC
Location: Valenvaryon
Contact:

Re: Cloning hard disks

Postby archeleus » Tue Feb 15, 2011 10:57 pm UTC

^
Seconding what he said.
I write a blog rant here.

User avatar
Jorpho
Posts: 6279
Joined: Wed Dec 12, 2007 5:31 am UTC
Location: Canada

Re: Cloning hard disks

Postby Jorpho » Wed Feb 16, 2011 3:24 am UTC

I remember running into some problems the last time I tried to clone an XP partition - trying to replace a small disk with a larger one. I never did get to the bottom of the problem; eventually I just gave up and used the larger disk as a slave.

I think the problem arises from Windows trying to reassign its drive letter when it starts up, which of course is hugely problematic - what it expects to find in C: is suddenly off on F:, or whatever. But I'm not sure exactly what the factors are - it could be the number of partitions, the number of hard drives, the locations of pre-existing Windows installations, the Active flag being set, or something else entirely. And top top things off, apparently you can set drive letters from the Recovery console too.

So, here's my suggestion: Assuming the smaller hard drive has one partition with Windows on it, clone that single partition to the new drive. Then unplug the smaller drive completely and see if Windows boots properly with just the larger hard drive connected. (You might also have to set the Active flag on the partition of the larger drive.)

Carnildo
Posts: 2023
Joined: Fri Jul 18, 2008 8:43 am UTC

Re: Cloning hard disks

Postby Carnildo » Wed Feb 16, 2011 4:08 am UTC

Jorpho wrote:I remember running into some problems the last time I tried to clone an XP partition - trying to replace a small disk with a larger one. I never did get to the bottom of the problem; eventually I just gave up and used the larger disk as a slave.

I think the problem arises from Windows trying to reassign its drive letter when it starts up, which of course is hugely problematic - what it expects to find in C: is suddenly off on F:, or whatever. But I'm not sure exactly what the factors are - it could be the number of partitions, the number of hard drives, the locations of pre-existing Windows installations, the Active flag being set, or something else entirely. And top top things off, apparently you can set drive letters from the Recovery console too.

Back in the days of Parallel ATA drives and WinXP, the rules were straightforward:

1) The first floppy drive is A:
2) The second floppy drive is B:
3) The boot partition of the boot drive is C:
4) Iterate through the remaining attached drives in order Primary Master->Secondary Master->Primary Slave->Secondary Slave. If the first partition of the drive doesn't have a drive letter yet, give it the next available letter.
5) The remaining partitions of the boot drive are given letters in sequential order.
6) Iterate through the rest of the attached drives in the order given in step (2). For each drive, assign letters to the remaining partitions in order.
7) The drive letters above the last assigned hard-drive letter are available for CD-ROM and network drives (for historical reasons, Windows does not distinguish between them).

Rule 4 has the unfortunate side effect that adding a hard drive to a computer is guaranteed to change the drive-letter assignments.

User avatar
EdgarJPublius
Official Propagandi.... Nifty Poster Guy
Posts: 3715
Joined: Tue Oct 09, 2007 4:56 am UTC
Location: where the wind takes me

Re: Cloning hard disks

Postby EdgarJPublius » Wed Feb 16, 2011 6:52 am UTC

I've used a gparted livecd to clone windows partitions to new disks before without issues.

Did you expand the windows partition to fill the new disk? because I have had issues doing that before, I was able to solve it by massaging everything in the disk management utility (can't remember what exactly I ended up having to do, I just played around with the options for a while and eventually things started working).

It's easier to clone the partition to the new drive, and then create a new partition out of the unallocated space to use.
Roosevelt wrote:
I wrote:Does Space Teddy Roosevelt wrestle Space Bears and fight the Space Spanish-American War with his band of Space-volunteers the Space Rough Riders?

Yes.

-still unaware of the origin and meaning of his own user-title

GeorgeH
Posts: 527
Joined: Mon Aug 17, 2009 6:36 am UTC

Re: Cloning hard disks

Postby GeorgeH » Wed Feb 16, 2011 7:29 am UTC

CloneZilla + Windows system/boot partition (and NTFS in general) == bad juju

CloneZilla can make a perfect copy of a Windows disk, but you need to use "advanced" or "full copy" (I forget the exact wording, it's been awhile) which is basically just dd with some hand holding.

User avatar
Zamfir
I built a novelty castle, the irony was lost on some.
Posts: 7594
Joined: Wed Aug 27, 2008 2:43 pm UTC
Location: Nederland

Re: Cloning hard disks

Postby Zamfir » Fri Feb 18, 2011 9:50 am UTC

Thanks for the replies. At first , I assumed that clonezilla was just dd wrapped in a custom linux with some extra options, so I expected perfect copies. When I saw that it copied partitions separately, and those with file systems much faster than others, I guess I should have realized it wasn't making an exact clone of the disk. But I had this idea of an exact copy in my head, so I was just frustrated that it didn't work as I expected.

Am I right that the best approach is something like this?

- boot some linux from USB drive or so
- unmount the source HD, remount as read-only to prevent dd from screwing it up
- mount destination HD if necessary
- "dd if=/dev/sda of=/dev/sdb", or whatever the mounted drives are called
- reboot, possibly after switching drives

Afterward, I'd have to manually increase the partitions, or make a new one for the empty space. I think I have used parted for this in the past, is that the best option? Increasing partition sizes always feels to me as dangerous, but just adding partitions feels ugly...

archeleus
Posts: 240
Joined: Wed Sep 29, 2010 1:49 pm UTC
Location: Valenvaryon
Contact:

Re: Cloning hard disks

Postby archeleus » Fri Feb 18, 2011 1:29 pm UTC

Yeah the approach would be something like that. Although I'm not sure whether booting into a temporary USB distro is needed (dd from the host OS should be able to handle it). Can someone who has done this before confirm? If you read the manual and remember what 'of' and 'if' stand for, it wont screw up your disk.
I write a blog rant here.

User avatar
Jorpho
Posts: 6279
Joined: Wed Dec 12, 2007 5:31 am UTC
Location: Canada

Re: Cloning hard disks

Postby Jorpho » Fri Feb 18, 2011 2:12 pm UTC

Zamfir wrote:Afterward, I'd have to manually increase the partitions, or make a new one for the empty space. I think I have used parted for this in the past, is that the best option? Increasing partition sizes always feels to me as dangerous, but just adding partitions feels ugly...
Doing anything to one's partitions is inherently dangerous.

I've never had problems with parted.

Carnildo
Posts: 2023
Joined: Fri Jul 18, 2008 8:43 am UTC

Re: Cloning hard disks

Postby Carnildo » Sat Feb 19, 2011 4:07 am UTC

Zamfir wrote:Thanks for the replies. At first , I assumed that clonezilla was just dd wrapped in a custom linux with some extra options, so I expected perfect copies. When I saw that it copied partitions separately, and those with file systems much faster than others, I guess I should have realized it wasn't making an exact clone of the disk. But I had this idea of an exact copy in my head, so I was just frustrated that it didn't work as I expected.

Am I right that the best approach is something like this?

- boot some linux from USB drive or so
- unmount the source HD, remount as read-only to prevent dd from screwing it up
- mount destination HD if necessary
- "dd if=/dev/sda of=/dev/sdb", or whatever the mounted drives are called
- reboot, possibly after switching drives

Afterward, I'd have to manually increase the partitions, or make a new one for the empty space. I think I have used parted for this in the past, is that the best option? Increasing partition sizes always feels to me as dangerous, but just adding partitions feels ugly...


The best approach is this:
1) Boot Linux from a CD or USB drive.
2) Make sure the source and destination hard drives are unmounted. Cloning a mounted drive will almost invariably result in data corruption.
3) "dd if=/dev/sda of=/dev/sdb". This will make an exact duplicate, including partition layout. Make sure you get the order right.
4) Shut down the computer and remove the old disk from your computer. This disk is your backup in case step 5 goes wrong.
5) Enlarge the partitions on the new disk with the tool of your choice.


Return to “The Help Desk”

Who is online

Users browsing this forum: No registered users and 3 guests