How do I create a backup image of an SD card?

34,093

Run mount | grep "/media/oneiric". This will show the sdcard device (/dev/sdXX). Then run:

sudo umount /media/oneiric
sudo dd if=/dev/sdXX of=~/sd-card-copy.img
Share:
34,093

Related videos on Youtube

Adi
Author by

Adi

Updated on September 18, 2022

Comments

  • Adi
    Adi over 1 year

    I have to copy my SD card to my hard-drive. I know that I have to mount and unmount it, but the following line doesn't work:

    dd if=/media/oneiric of=~/sd-card-copy.img
    

    That was my first try, but then I found out that I have to unmount my card and select /dev/sdX. The problem is that the command fdisk -l isn't showing anything. Nothing happens and therefore I can't copy my files.

    How can I fix this?

    • hmayag
      hmayag about 11 years
      fdisk requires root privileges. Try typing sudo fdisk -l instead.
    • Adi
      Adi about 11 years
      Ok Great. I could have had the same idea if I would have thought of it. ok so this works now. But how do i know now which of the devices my sd-Card is. I umounted it and i dont recognize any difference
    • Piskvor left the building
      Piskvor left the building about 11 years
      sudo blkid will list all your devices, their identifiers, and labels, e.g. /dev/sdc1: SEC_TYPE="msdos" LABEL="FooBarBaz" UUID="1234-1234" TYPE="vfat". That should give you some indication - the above you would see if you named your card FooBarBaz, and it would be at /dev/sdc1 . I'd probably copy the whole disk (/dev/sdc here) instead of just the first partition (/dev/sdc1).
  • Adi
    Adi about 11 years
    ok the device is now /dev/mmcblk0p1 can this be true? i've read everywhere something with sdX so this confues me
  • Eric Carvalho
    Eric Carvalho about 11 years
    That's it. I have only seen mmcblk0p1 in android devices. sdX is used for hard disks and usb sticks. Maybe this is the right device name for card readers.
  • Piskvor left the building
    Piskvor left the building about 11 years
    @Eric Carvalho: /dev/mmcblkX is used for (SD,MMC,...) card readers, it's quite common in laptops (some readers report as normal USB drives - getting the /dev/sdX name - some use this convention); /dev/mmcblk0p1 would be the first partition on a card in card reader #0.
  • M.Hefny
    M.Hefny about 3 years
    You can go extra mile and compress your image using pishrink github.com/Drewsif/PiShrink