5

So I've found this command:

dd if=/dev/sdx of=/directory/for/image bs=1M

But that gives me this error:

dd: failed to open ‘directory/for/image’: Is a directory

So I found that the directory has to be unmounted. Trying the same command, but changing the directory to my /home/user directory got the same error. Well, lucky for me, the original location is an extra partition I use for independent storage between my OSes, so I unmounted it and tried again. This time I got this error:

dd: failed to open ‘/directory/for/image’: No such file or directory

So that doesn't work either. But it doesn't make sense that it has to be unmounted because the majority of people don't have another partition for storage. I found another post that said you have to be operating from the directory where the .img file is, but I'm trying to read the whole card and write an image of it, so there isn't an image file yet. So I tried one more time, executing the command from within the directory I am writing to and got the same error as I got first:

dd: failed to open ‘/directory/for/image’: Is a directory

So what the heck is going on and how in the world do you use the dd tool?

Ubuntu 15.04
Thanks!

4 Answers 4

3

Your /directory/for/image must also contain the name for the image. So if you wanted to save it in your home directory then you would use ~/myimage.img or ~/myimage.dmg.

EDIT:

If you are taking a backup of the Pi using dd with the same Pi, some serious issues can occur, I have corrupted 2 sd cards like this, check the answer to this question instead: https://raspberrypi.stackexchange.com/a/5492/33979

Don't use dd for the backup unless you are using a separate computer to take the backup.

1
  • 3
    the wording should read: 'don't use dd to backup a live system...', however will work OK (most of the time).
    – fcm
    Commented Jan 13, 2016 at 5:02
2
sudo dd if=/dev/sdc of=/home/user/new.img

Use GPARTED to identify your USB/SD card adapter with confidence, or dmesg upon insertion.

Use a USB 3.0 or faster if available: this may take a long time

Use an adapter that flashes during transfers: dd give NO indication of progress. Kind looks like a lock-up in the terminal.

When using SD cards, do all you configs & downloads and then do his backup BEFORE expanding the files system to the max amount. You DO NOT want a 64Gb file of empty filespace.

Its good practice to run off you BACKUP and keep the original to test the dd success. (duplicate sd cards needed)

1
  • Another, maybe easier, way to detect the USB/SD-card adapter is to watch df before insertion of the adapter.
    – Bex
    Commented Aug 19, 2017 at 9:06
0

Your of must be the disk image name you want to give it. So:

sudo dd bs=1m if=/path/to/sdcard of=/path/to/image/backup.img

-1

Here are commands that can be used. Make sure you know the actual device name of the SD card. It is /dev/sdc on my system:

wget https://downloads.raspberrypi.org/raspbian_latest
unzip raspbian_latest
dd bs=4M if=2015-11-21-raspbian-jessie.img of=/dev/sdc

The rasbian_latest version (2015-11021) will be different when a new raspian is released.

EDIT: As was pointed out, I went the wrong way. Here is the correct command (again with /dev/sdc):

dd bs=4M of=sd.img if=/dev/sdc
1
  • 3
    This is copying a disk image to an SD card, the OP wants to copy the SD card to a disk image. Commented Jan 13, 2016 at 5:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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