Link to home
Start Free TrialLog in
Avatar of rye004
rye004Flag for United States of America

asked on

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.
Avatar of jfer0x01
jfer0x01
Flag of United States of America image

Yes

dd if=/dev/your folder of=/where you want to output file
Avatar of rye004

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of serialband
serialband
Flag of Ukraine image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of rye004

ASKER

Thank you for your help.  This actually makes more sense to use.