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

Posted on 2012-08-24
Medium Priority
Last Modified: 2012-09-01
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.
Question by:rye004

Expert Comment

ID: 38331374

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

Author Comment

ID: 38331386
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.
LVL 31

Accepted Solution

serialband earned 1500 total points
ID: 38331514
Have you tried tar?
tar -cf directory.tar Directory_To_Archive

Open in new window

LVL 40

Expert Comment

ID: 38331868
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

Author Closing Comment

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

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question