Backing Up / Making an image of an SD card

From Nearline Storage
Jump to: navigation, search

Backup

  1. Use gparted to shrink the root partition to its minimum size
  2. Get "Last sector" from Partition -> Information for the root partition
  3. Get "Sector size" from View -> Device Information for the SD card
  4. sudo dcfldd if=/dev/sde count=<last sector + 1> bs=<Sector size> | gzip >backup.image.gz

Restore

  1. To restore: gzip -dc backup.image.gz | sudo dcfldd of=/dev/sde
    There will be a long pause at the end while dcfldd flushes its buffer
  2. Just to be sure (this isn't always required but sometimes it is, depending on what the partition table was like on the card before you restored the image to it)
    1. eject /dev/sde
    2. Unplug and plug back in
  3. Use gparted to extend the root partition