Making full disk image with DD

63,692

Solution 1

Boot from the live cd. Mount your destination media to (say) /mnt.

dd if=/dev/sdXXX of=/mnt/mybackup.ddimg

To restore:

dd if=/mnt/mybackup.ddimg of=/dev/sdXXX

The destination drive should be the same size or bigger than the original.


A better way is using tar.

Mount the source to /mnt, mount the destination to /home (say)

tar cvfpz /home/mybackup.tar.gz /mnt

This can then be restored to any size drive:

tar xvfpz /home/mybackup.tar.gz

(After mounting source to /home and destination to /mnt.)

Then just install grub.

Solution 2

In addition to hatterman's great answer you can compress the image as it's taken using gzip like this:

dd if=/dev/sdx | gzip > /mnt/mybackup.ddimg.gz
Share:
63,692

Related videos on Youtube

Alexander Kim
Author by

Alexander Kim

Middle Frontend-engineer. Working with JS: Vue/Nativescript/Electron/Express || Koa.

Updated on September 18, 2022

Comments

  • Alexander Kim
    Alexander Kim over 1 year

    it is possible to make a full disk image with running ubuntu with following command:

    dd if=/dev/sda of=/image_name
    

    After i make it, how can i restore that image on a crushed system?

    • Taylor Ramirez
      Taylor Ramirez almost 10 years
      Three things I would suggest. One: do it from a live CD. Two: make sure the image you create is not on the same volume as the one being copied. Three: this will probably only work if both hard drives are the same size.
    • Rinzwind
      Rinzwind almost 10 years
      @Heihachi why would you not be able to write to a harddisk from a live DVD?
    • Taylor Ramirez
      Taylor Ramirez almost 10 years
      I would suggest using a USB hard drive as the location to sent the image
  • CervEd
    CervEd about 4 years
    note that this might require gzip to run as root