Copying install

Soldato
Joined
22 Oct 2005
Posts
2,855
Location
Moving...
Hi all.

I've just got a new hard drive so I'm looking at moving my linux install onto it. I'm quite happy with it now, so I was wondering if I could just make an exact copy of it, then just dump it all on the new drive.

It's ubuntu 9.10, dual booting with windows XP. Not worried about installing windows from scratch but I'd like to keep my linux setup.

Is this possible?

I've seen some other people suggest ghost4linux, looks like it might do the job. Thoughts?

Thanks.
 
Yep, perfectly doable using dd.

dd if=/dev/hda1 of=/dev/hdb1 bs=2M where hda1 is the first partition and hdb1 is the destination partition. Can also do entire drives with just /dev/hda without partition numbers. (Will take a long time with large drives though as every single sector is cloned)
 
I tend to do this using the above command, but with the options conv=sync,noerror

conv=sync ensures the block written is the same size as the one read, appending zeros as required. noerror makes it keep going, even if it hits unreadable sections. A bit hazy on the details of these, as is probably clear from the previous sentences. Taken from a consensus of sites found through google, and not yet had any issues with it yet. You can pipe it through gzip too, but this is more useful for storing images than for cloning.

I'd be inclined to just copy the entire damned thing, i.e. if=/dev/sda of=/dev/sdb then resize the partitions. Otherwise setting up the partitions with matching sizes to the current one before overwriting the partition with the old one is probably wise, though might not be required.
 
Last edited:
Thanks for the advice guys. That looks nice and simple.

One more question though, does this depend on having particular partition sizes?

What I was thinking of doing is starting with a blank drive, formatting it, installing windows XP on the whole disk. Then partition the disk into equal halves and add the swap partition all in XP. Then use the above command to dump it all onto the fresh partition. Will that work if the partition sizes are different or do they have to match?

Cheers.
 
Sorry, another question on top of the above. Does the dd method handle the GRUB bootloader as well or will I have to set something up manually to allow me to boot into windows/linux?

I was looking at partimage as well as it would be easier for me to just dump it onto an external hardrive/usb as an image file rather than copying it directly onto the new hard drive as this will require less faffing around adding/removing hard drives. Would this do the job just as well as dd?
 
Sorry, another question on top of the above. Does the dd method handle the GRUB bootloader as well or will I have to set something up manually to allow me to boot into windows/linux?

It can do, the bootloader/MBR is in the first 512 bytes of the physical drive (normally), so if you dd /dev/sda it will copy it, however if you dd /dev/sda1 it wont.

You could also manually back it up with: dd if=/dev/sda of=/BootSector.bin bs=512 count=1

Not sure how partition sizes work when dd'ing im afraid.
 
I'm now writing this on my new hard drive so I presume everything worked ok! Ended up using a different application in the end.

Just thought I'd write down what I did in case anyone in the future is in the same boat,

- Download and burn CloneZilla
- Restart and boot into CloneZilla
- Create image of entire hard disk and save on external hard drive
- Swap in the new hard drive
- Use gparted live disk to format the disk (Don't think this is necessary but I did it just to be on the safe side)
- Restart and boot into CloneZilla again
- Copy the image onto the new drive

Job's a good'un! This copied all 3 of my partitions (winXP, linux and swap) with no problems. It also copied the GRUB bootloader as well so I didn't have to do anything to get it working, it was up and running straight away.

With regards to the partition sizes, it's kept the sizes the same as on the old drive and any additional space is just left as unallocated so I can decide how to distribute that at a later date.

Thanks again.
 
Back
Top Bottom