Does dd
act at the filesystem level or go to the raw device directly?
-
dd works on device level.– Pilot6Sep 15, 2015 at 9:01
-
1It depends on what you mean exactly. Technically it always reads the filesystem, or it wouldn't be able to determine, for one, the permissions of the regular file / device file or whatever is put to work on.– kosSep 15, 2015 at 9:44
1 Answer
dd
works on whatever you chose it to work on.
You can take the terminal streams (stdin and stdout), or anything represented by a file descriptor as in- and output of dd
.
And as almost everything on Linux has a file descriptor, you can use files, directories, character devices (e.g. /dev/null
, /dev/random
), block devices (e.g. partitions/file systems like /dev/sda1
or directly entire disks like /dev/sda
).
As you can see, dd
is a pretty powerful and versatile tool, but make sure you use it with caution as it's also known as "disk destroyer" if you accidentally use it with unintended arguments.
If you're interested in more information about dd
, read its manpage (run man dd
) or look for example at Answer to "dd vs cat — is dd still relevant these days?" (Unix&Linux.SE) or What does the command name "dd" stand for?
-
Is
dd
powerful in itself or mostly takes advantage of the fact that as almost everything on Linux has a file descriptor?– A.LSep 15, 2015 at 13:37 -
@A.L Good question, I don't really know. You could look at its source code probably if you're interested. But does it matter?– Byte Commander ♦Sep 15, 2015 at 13:40
-
No, that was just nitpicking about the assumption
dd
is a pretty powerful and versatile tool.– A.LSep 15, 2015 at 13:41 -
1Check your command 5 times and write it on a piece of paper and check it another 5 times. Mixing up IF and OF is instant destruction of potentially a lot of data.– NelsonSep 15, 2015 at 13:52
-
3
dd
has some nice features, but the most time it is used in ways which would work equally well withcp
,cat
, the shell ... in this answer some things which are hard withoutdd
are listed. Butdd if=/dev/sda of=/mnt/ext/backup
can better be done withcat /dev/sda > /mnt/ext/backup
for example– JosefSep 15, 2015 at 14:21