Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I just got a new acer netbook, it comes with windows 7. I wanted to know how I could create a recovery image using tools like dd.

I want to know what command creates the exact backup of the hard disk and how I could restore it incase things go wrong when I try to install linux.

I have an external hard disk on which I will store this image and a bootable usb drive with ubuntu 12.04. If this isn't the best way then do suggest alternatives.

share|improve this question
1  
Options: use the windows procedure for creating a dvd/cd. I bet you also got a recovery partition. You could re-instal windows from that partition. Or do like me: in Holland it is allowed to download windows IF you own a serial and use that serial to install. I was like: if Ubuntu is not for me I'll just download windows but... I never looked back :D –  Rinzwind Jun 9 '12 at 19:03
add comment

1 Answer 1

up vote 4 down vote accepted
dd --help

will show all the options you have. The commands below use if for input file and of for output file.

Backup

A full hard disc copy can be created with any of these 3 commands:

dd if=/dev/hdx of=/dev/hdy
dd if=/dev/hdx of=/path/to/image
dd if=/dev/hdx | gzip > /path/to/image.gz

Where the x in hdx is the disc your want to copy and the y in hdy is the destination disc. The 1st one is basically copying the disc over to another disc. The last 2 make a file and the last one also zips the file.

Restore

dd if=/path/to/image of=/dev/hdx
gzip -dc /path/to/image.gz | dd of=/dev/hdx 

Where the x in hdx is the disc your want to restore the copy to. The 1st one restores the file (backup option 2). The 2nd one restores the zip file (backup option 3).


  • dd does not make understand empty space and space filled with data but if you use the gzip version the file will be a lot smaller (it can be 10 times smaller).

Alternatives:

  • In the repositories there is also partimage Install partimage

    • Partimage does not support ext4 or btrfs filesystems though and ntfs is in beta and thus experimental.

enter image description here

  • FSArchiver Install FSArchiver is a system tool that allows you to save the contents of a file-system to a compressed archive file. The file-system can be restored on a partition which has a different size and it can be restored on a different file-system. Unlike tar/dar, FSArchiver also creates the file-system when it extracts the data to partitions. Everything is checksummed in the archive in order to protect the data. If the archive is corrupt, you just loose the current file, not the whole archive. As always ... ntfs support is considered experimental.

share|improve this answer
    
I'm just a bit nervous, so I just wanted to know that it is safe to do this isn't it? –  nikhil Jun 9 '12 at 19:36
    
well... safe. safe. it works. but if you make a typo it -can- be fatal. Then again it is a very easy command and a very nice method ;) –  Rinzwind Jun 9 '12 at 20:58
    
One more thing, the hard disk size is 320gb and the data is around 20GB anything I can do to conserve space? –  nikhil Jun 9 '12 at 21:15
    
@nikhil use the gzip version and the empty space will get compressed. I also included 2 Linux options for you. –  Rinzwind Jun 10 '12 at 5:18
    
Thanks, this is an awesome answer. –  nikhil Jun 10 '12 at 9:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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