Ubuntu: Can the dd command be used to copy clone only certain folders?


I have a failing hdd, all I need from there is my music and movies folder, I have managed to copy all the other files from the failing hdd. But when I try to copy the above 2 folders, I get read write/input out put errors. These 2 folders are my life's collection and I really do not want to loose them. I read that the dd command copies files over as raw data, so i think that that might work in getting them backed up to my external drive. Is there a way for me to use the dd commend to just copy those to folders over to my external?. I cannot use dd to clone complete hdd, because the failing drive is 1 TB and my external only 300GB. The 2 folders together only comes to 224GB.


You can use dd (or better ddrescue which tries to read data several times before it fails) only on files or similar file-like objects. On UNIX systems, a file-like object can be for example a partition (e.g. /dev/sda1), an entire disk (e.g. /dev/sda), a virtual character device (e.g. /dev/zero or /dev/random) or the input/output streams (e.g. STDIN, STDOUT and STDERR).

Directories are also represented by file descriptors in your file system tree, but are not counted as file-like objects in the case of dd because they can't be read as single object.

So using dd (or ddrescue) only works either on single real files that have to be located on a mounted and working file system, or on an entire disk or partition which it would then copy rawly no matter what file system it is formatted with and whether it is mounted and working or not.

To conclude: No, you can't dd a folder.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »