Skip to content

Instantly share code, notes, and snippets.

@jcaraballo
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcaraballo/c5c54b63a3ab1400e31a to your computer and use it in GitHub Desktop.
Save jcaraballo/c5c54b63a3ab1400e31a to your computer and use it in GitHub Desktop.
Copy partition into image file

Every now and then I have to reinstall a system from scratch, putting the contents on the side. Before I used to go through the system and decide what to manually copy. Nowadays it's so much easier and relatively cheap to copy the whole thing.

In order to copy the partition /dev/sda1 to an image file:

sudo dd if=/dev/sda1 of=image-file.ddimg bs=4M

(The bs size depends on the hardware)

This will probably work gzipping the image on the fly:

sudo dd if=/dev/sda1 bs=4M | gzip -c > image-file.ddimg.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment