3
I have a 2.7T hard drive that has been causing some problems lately, so I've bought a new 3.6T disk.
The old drive contains about 2.4T of data (lots of files are hardlinked) in a single ext4 file system.
The normally recommended method I can see of fixing this kind of problem is to make an image of the disk using ddrescue
. However this image file would naturally be 2.7T in size, leaving 0.9T space left. I have an additional 0.5T of space on other disks, but this is obviously not enough to copy the data out of the image.
I don't know where I would find an additional 1T of space to put the rest of the files. So obviously I need to find some other method.
- One possible method could be to write the image directly to
/dev/sd?1
on the new disk, and just resize it. However this sounds dangerous, since it might leave the new disk with a broken file system. - Maybe some
rsync
orcp -a
command could solve this problem? Certain other answers mention thatrsync
could possibly break the disk, but maybe there are options to make this less likely to happen. - Maybe there exists some utility that copies the data out of the image, while shrinking the image file in the progress?
What is the best way of copying the data from the old disk to the new disk? I am thinking that a command like the following might do it:
rsync -aHX --info=progress2 --partial /media/ext_drive/* /media/4tb
After mounting the old disk in read-only mode to /media/ext_drive
and the new one to /media/4tb
.
If you did do a ddrescue-style image first, you could then read from the image and store files temporarily online somewhere, or beg/borrow a 3rd temporary drive. Compressing a raw disk image is possible (ex.
dd if=dev/sda | gzip -9 > dd-image.gz
) but reading it becomes problematic. I once found a method that used some type of network server to uncompress the file "on the fly"... – Xen2050 – 2017-08-23T12:00:29.320