Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've run into this scenario a few time: I need to replace a drive because I need more space, it's having problems, moving to a new box, etc.

What's the best way to copy data from one partition size to another (presuming the target has enough space)?

What about if it's a different file system (such as ReiserFS to ext4)?

If it's just a new drive on an existing system, how do I ensure I don't need to reinstall to get everything working?

Update - many of the options are highly viable, and I've changed this question to community wiki because I don't think there's a "right" answer.

share|improve this question
1  
superuser.com/questions/32164/… was asked for windows drives/partitions –  warren Sep 10 '09 at 6:33

8 Answers 8

Another option would be to boot from a liveCD and mount the old drive as read only. This is to prevent the livecd from changing it during the copy. Then rsync -avz /mnt/olddisk/ /mnt/newdisk (the trailing slash after olddisk is necessary). As the others have mentioned, if this is the boot disk that is being expanded you will need to rerun grub-install <new device> before it can be bootable.

share|improve this answer
    
there's one I'd not thoguht of :) –  warren Nov 5 '09 at 13:17

The solution I've used in the past is tar. If the partitions are the exact same size and type, you can use dd.

Here's my answer to the quandary:

  1. boot using a live cd distro such as Slax
  2. verify the partitions you want are on the new drive
  3. make sure both the old and new drives are mounted, for example /tmp/driveold and /tmp/drivenew'
  4. run from a terminal the following tar command:

    (tar cp --xattrs /tmp/driveold/path) | (tar x /tmp/drivenew/path)

  5. repeat for each partition you need to copy

This works for every partition I've ever tried it on (excluding /boot, for which I ensure the partitions are identical, and use dd).

share|improve this answer
1  
I like this solution because it's so simple, but I think you would need some extra options like p (preserve permissions) to get all of the meta-data. –  Jay Conrod Jul 23 '09 at 15:01
1  
you're right on the p - I've added that :) –  warren Jul 23 '09 at 15:37
1  
Speaking of meta-data, the --xattrs option (store ACLs and SELinux info) should be used too. –  Cristian Ciupitu Sep 8 '09 at 11:19
    
The 2 tars connected with a pipe could be replaced with cpio --pass-through. –  Cristian Ciupitu Sep 8 '09 at 11:20
    
thanks, @Christian, for the --xattrs call –  warren Sep 8 '09 at 11:52

+1 to warren and to use tar.

However, I usually tries to restore from my backups instead. And moving from one disk to a new one seems like a good opportunity to see if your backup plan is working.

If you simulate a disk failure (pull the power from the old disk), start to recover to the new disk. And when you are done, you start up the old disk and diff them to see if you got all the files.

If they are identical you both have moved all your data, and you know that your backup plan is valid and working.

share|improve this answer
    
good idea - though for those among us (<whistle mode="innocent"/>) who don't have a "backup" solution, this might also be a Good Time to come up with one :) –  warren Sep 8 '09 at 15:59
1  
:) –  Johan Sep 8 '09 at 19:17

I also found Disk Copy, which doesn't apepar to be on the wikipedia list, but have never used it.

share|improve this answer
    
Disk Copy is a good one. –  craigmoliver Aug 9 '09 at 1:00

This is one reason I like LVM. Just add the new disk to the volume group, pvmove the logical volumes from the old to new disk, remove the old disk from the volume group, and then from the system. If it's your boot disk you're replacing then you also need to update your boot loader.

share|improve this answer
    
That is a great idea - except if you're not running LVM, it's a bit of a pain :) Thanks for the suggestion, though! –  warren Jul 23 '09 at 15:38
    
Something to consider next time you install :-) –  pgs Jul 23 '09 at 15:50

Create image from original partition and put this image to new HDD.

Norton Ghost™ 14.0 do that or other image software


Here is list of disk cloning software

Comparison of disk cloning software [wikipedia]

share|improve this answer
4  
Acronis True Image is another alternative (acronis.com/homecomputing/products/trueimage) –  fretje Jul 23 '09 at 14:35
6  
Unfortuately this method requires purchasing Norton Ghost –  craigmoliver Jul 23 '09 at 14:36

Most disk cloning utilities can do this. I like using g4u from a livecd. Ghost is nice, but I'd rather use a free one.

share|improve this answer

Clone the drive using CloneZilla, then use gparted to resize it. Keep your old one in case if goes wrong :-)

By the way, this way is free.

share|improve this answer
2  
I like the free part here, though nothing beats GOOD working software that does everything (instead of 3 freewares together) –  Ivo Flipse Jul 23 '09 at 14:44
1  
It's just two freewares and it's quite painless. ISOs boot no problem. –  craigmoliver Jul 24 '09 at 4:20
    
I can confirm that this works. I successfully moved my secondary drive with Windows 7 from a 160GB drive to a 1TB drive. Cloned it to my linux disk with Clonezilla. Restored it on the new disk and resized it with the Windows 7 Disk Management tool. This was from a NTFS to a NTFS though. –  Thomas Watnedal Oct 5 '09 at 13:20
    
you say 'clone the drive' though he asked clone the partition. Also he said different file system. –  barlop Jun 24 at 7:57

Your Answer

 
discard

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.