Under windows system I'm used to create an image of HD with driveImageXML.

What's the best approach to have an Image of the hard-drive containing the OS, with Ubuntu Server?

I'd like to have a snapshot of the current configuration so If ever happens that the primary disk will fail I could simply restore this image on a new HD, unplug the broken one, plug the newly created. Saving me days on setting up and reconfigure the whole Unix server.

edit: I've found also this on ubuntu forums, taking SU privileges you can just launch the following command:

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

to create an archive with all OS stuff, without the need to stop the server.

But I've also read that i will need to reinstall GRUB when if I'll move to another HD. Seems that untar and copy files to the new HD will not be enough for the system to start up again. Is it correct?

  • Clonezilla? The downside is that the machine has to be offline to take the image. – tombull89 Apr 10 '13 at 15:26

If you simply want a pure one time snapshot (cloned image) of your drive you can use the dd utility. This utility takes an image of the entire drive. Thus if your drive (partition) is 500mb then your snapshot will also be 500mb.

However if you want to keep an ongoing backup of all the data on the drive you could use a utility like rsync (or rsnapshot).

  • dd utility could be fine for my case. But I'm kind of worried about the restore part. If I'll execute again the dd command from the backup image file as input and the newly installed and formatted Disk as output: will my system boot again from this new disk? Or I'll need to do something more to make it boot? – kante Apr 10 '13 at 16:06
  • If you use dd, it can create an image of the entire drive. Thus, if you restore that image to a new drive it will wipe the new drive and replace it with the contents of the dd image. Thus, the new drive will be an exact duplicate of the image. This means that if the drive was bootable, it should still be bootable. However, if there are other drives/partitions that this drive relies on for booting it would still require those to exist. – SunSparc Apr 10 '13 at 16:13
  • Might I also suggest that if you are worried about losing data you should also consider keeping an online backup of your data. There are many online backup services (eg CrashPlan, Mozy, Carbonite, etc). These will not restore a drive image but they will allow you to restore your data. – SunSparc Apr 12 '13 at 16:07

Perhaps you could use LVM to partition your disk into logical volumes and then take a snapshot of the logical volumes using lvcreate, creating a snapshot on an external/USB drive.

Otherwise you could just use a Ghost boot CD or something similar to clone the hard drive.


What are you trying to protect against or otherwise achieve?

If you want to protect against a single drive dying, use a RAID level with mirroring.

If you want to protect against data corruption, you need a regular backup system; taking disk images is most likely not the best way to achieve this. There are a hundred and one "network backup systems", and in the Linux world a dozen that use rsync; dirvish is my current personal favourite but has its limitations.

If you want to protect against other hardware failure or have some sort of disaster recovery path, a disk image might be the right option; note that reinstalling GRUB is really not that hard.

  • Many thanks, to answer you: once it happened that the Mobo of this server stop functioning, and I got scared because differently from the data that is located on a RAID1 configuration inside the server, the system is on a third single HD. I got scared the disk was broken. That would have been a bad situation because i don't have any backup of it. So just in case... I'd like to have a backup image of this disk to copy in a new one, unplug the broken, plug the new turn the server on as nothing happened... – kante Apr 11 '13 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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