I'm trying to use the dd command to copy the content of the folder boot0 to the my disks intial bytes.

This is the command :

sudo dd if=boot0/ of=/dev/sdb ibs=440 obs=440 count=1 

But I get this error :

dd: error reading ‘boot0/’: Is a directory
0+0 records in
0+0 records out
0 bytes (0 B) copied, 0.000209512 s, 0.0 kB/s

How can I solve this problem?

  • 2
    dd reads files, not folders. As it is, that's not the proper way to write files to the start of a drive. You need to create a FAT32 partition first and then use cp to copy the contents over. – saiarcot895 May 29 '14 at 12:15
  • I think you want to use rsync, man rsync. – ppetraki Nov 14 '14 at 14:21

It can be done

We need to workaround two problems:

  1. dd doesn't know what to do with directories
  2. dd can only copy one file at a time

First let's define input and output directories:


Now let's cd into the source directory so find will report relative directories we can easily manipulate:

cd "$SOURCE"

Duplicate the directory tree from $SOURCE to $TARGET

find . -type d -exec mkdir -p "$TARGET{}" \;

Duplicate files from $SOURCE to $TARGET omitting write cache (but utilising read cache!)

find . -type f -exec dd if={} of="$TARGET{}" bs=8M oflag=direct \;

Please note that this won't preserve file modification times, ownership and other attributes.


The main purpose of dd utility is to convert and copy files.

For example:

dd if=filename of=filename2 conv=ucase
dd if=/dev/urandom of=myrandom bs=100 count=1

If you'd like to copy the content of the folder use either rsync:

rsync -vuar src/ dst/

or cp utility:

cp -va src/. dst/
  • 1
    -R / -r not required when using -a as -a always implies recursive. – thomasrutter May 28 '15 at 2:23
  • 1
    It is not an answer to the question, it its a recommendation. – ArchLinuxTux Sep 10 '18 at 14:59

dd works on the file you specify, making it able to copy data between devices, or from a device to a file. This is commonly used for moving data if devices specifically are involved (create an iso image from a cd-rom disc for example: dd if=/dev/cdrom of=mycdrom.iso), or backup raw devices (sometimes used in RAC databases: dd if=/dev/raw/raw1 of=device_raw1)

cp is used for duplicating file content to a new file or to a new location. things you specifically want there are preservation of ownership, timestamp and mode (rights), and being able to recurse the operation (=being able to copy directories).

Try this command :

   cp -r /home/source_folder/* /home/destination_folder
  • cp -a is preferable to cp -r because it preserves permissions, timestamps, symbolic links etc. cp -r would reset all files to be owned by you with a creation/modification date as now, and symbolic links would be followed and their destinations duplicated. – thomasrutter May 28 '15 at 2:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.