Ubuntu – Copy all files from the old hard drive to the new one

backuphard drivetransfer

I'm changing my old hard drive (500GB full) with a new one (1TB).
I use it to backup all my files, so I just need the best way to copy all files from old one to new one, but I don't want to use the normal file manager to transfer files because I think the process will take a very long time (I have to transfer 500GB of files), so is there a better way to do that?

For instance, do programs like clonezilla help me in this situation?

Best Answer

I would not recommend dd for this task. It will copy sector by sector, raw disk data; so it will work only if the partitions are exactly the same size and layout (leading to corruption otherwise). And then you have again another almost-full partion, that you have to extend... messy. And if the source filesystem is almost full, it's probably quite fragmented, and using dd will copy the fragmentation over.

rsync is a good option, but in this case, giving that you are copying locally to a blank, new disk, I think that the good old cp will do(1). Use it as(2)(3)

cd sourcedir; cp -av . /destdir 

...and be patient. This will rewrite all files, and in the process, the fragmentation of the new filesystem will be better than the original one.

On the speed point of view, this should fill the I/O buffers and then the copy will proceed at the maximum data transfer that the disks (and the bus) allow. If the system is otherwise idle, I do not think that there will be huge difference in speed between any method.


Notes:

(1) caveat: if you have a LOT of small files, cp can be slow. There is an old tar trick for this case... but it's a bit dangerous, so ask if you need it.

(2) v here means verbose, it will print each file it's copying. It will slow down a bit (or a lot if you have a lot of small files) the copy. YMMV.

(3) if there are files of different users, you will need to say sudo cp... to maintain correct ownerships and modes.

Related Question