Can you use the DD command on a directory in Linux?

Is it possible to use the DD command to create and image of a directory?  I realize that the DD command is traditionally intended to create a copy of data on a piece of media and that if is in allocated or unallocated space is irrelevant.  What I am looking for is a bit stream of data from allocated data within a directory.
If I should use another command please let me know.  Any examples would be greatly appreciated.
rye004Asked:
Who is Participating?
 
serialbandCommented:
Have you tried tar?
tar -cf directory.tar Directory_To_Archive

Open in new window

0
 
jfer0x01Commented:
Yes

dd if=/dev/your folder of=/where you want to output file
0
 
rye004Author Commented:
Thank you for your response.  I had tried your example before I posted and all I got was an empty file.  The DD command indicated that what I was trying to DD was a directory.
0
 
omarfaridCommented:
dd command cannot be used for copying / imaging a directory.

on unix / linux, a directory is a especial file that contains info about subdirs and files under that dir.

so, when you dd a dir then dd will just copy that especial file and not the full directory content.

you could use command like tar

tar -cvf /somedir/mydir.tar /path/to/mydir

but make sure you have enough space on /somedir

to restore it

tar -xvf /somedir/mydir.tar
0
 
rye004Author Commented:
Thank you for your help.  This actually makes more sense to use.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.