Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to backup my server. For example using dd:

dd if=/dev/md0 of=/some_network_share

I wonder if this image will be vary inconsistent if /dev/md0 is mounted? Would it be possible to convert such dd image to vdi drive and create working virtual machine? Using this command for example:

VBoxManage convertfromraw ImageFile.dd OutputFile.vdi 

Network traffic is disabled on firewall (there is only connection to/from one remote machine where image is copied).

share|improve this question
Chances to get a consistent backup with this method are: 0% – matthias krull Mar 20 '11 at 14:20
@mugen: Not if it's mounted ro. – Hello71 Mar 20 '11 at 14:50
Server backup to create a working virtual machine implies very much that it is mounted rw. – matthias krull Mar 20 '11 at 15:00
@mugenkenichi, re consistent, if all I care about is creating a image to mount in a VM, and no-one is using the machine while dd is active, then would the above work? – IanVaughan Jan 3 '12 at 13:48
Noone using the machine does not mean the disk content is not altered. Usually there are several processes running that do at least log something. LVM snapshots are a good way to go. – matthias krull Feb 16 '12 at 7:51
up vote 2 down vote accepted

If you are using LVM volumes (which you probably should be using in a production enviroment), there is a copy on write snapshot facility that can produce exact snapshots.

There's several commercial products that can do this, in some form or another - vmware vCenter Converter can make a virtual machine out of a live machine, Acronis TrueImage has a linux version of one of their enterprise products that supports live copies.

Otherwise, a hackish way to do it that might work would be to use rsync repeatedly until the differences are small enough that you can remount filesystems read only, rsync one last time, and then remount rw. I've never tried this on a raw filesystem image, but it works well on a directory structure.

share|improve this answer
We diced to install everything on VM from scratch and only export/import data from old machine. But I like idea of using rsync repeatedly. I herd it also from some one else. I think it should work. – Maciek Sawicki Jul 24 '11 at 16:04

I have actually done this and it works. It's fairly reliable, too, all things considered. Is it a good idea? No, probably not. You may lose data or end up with corrupt files. With an ext3 partitions, at boot, you will get a warning that the partition "was not cleanly unmounted, check forced." It will then run 'fsck'. It may take a long time for fsck to return the filesystem to a clean state, but it will get there. An ext4 filesystem will do this faster.

Think about it this way, a 'dd' of a live filesystem is equivalent of pulling the power plug from a server while it is running. If you pulled the power plug from a server would you expect that the filesystem will be ruined and that the machine will not boot again? Of course not. Well, unless you had been updating your boot kernel or initrd or something. I'm sure there are other edge cases. But this is still not the ideal way to shutdown a system. Don't rely on it.

Also, running 'sync' is likely useless in this situation (I say "likely useless" because I'm not 100% sure of my facts here and I don't feel like fact-checking). Running 'sync' before the 'dd' step will not make the image any more consistent because 'dd' does not simply bypass the kernel and talk directly to the hardware. 'dd' still goes through the Linux kernel. If 'dd' requests data from dirty blocks (updated data that has not by synced to drive) it does not ignore this fact. In other words, 'dd' will actually copy the dirty blocks even though they have not been synced to the disk yet. Note that I believe there are options to ask 'dd' to do this (bypass the kernel buffers and talk directly to the hardware), but this is not the default behavior.

share|improve this answer


Don't do it.

The backup will not be usable. Even if your conversion succeed, you will have a hard time verifying the content.

share|improve this answer

It depends on the method. The problem with imaging a running disk is there's no way to ensure consistancy - files change while you're working on them for one.

There's several approaches to avoid this - one is to use some way to make a snapshot of how files are at a very specific period of time and make a backup - windows has VSS, but linux / ext has no equivalent to that.

The other is to make the image off a non live system

So, no, unless its a OS or FS that can snapshot, its not a good way to go around doing things.

share|improve this answer
Linux has LVM snapshots, provided you are using LVM. – Stephanie Jul 11 '11 at 17:05

I think the only way to get this to work would be to make a software(or possibly hardware if you're man enough to configure it) RAID 1 setup with another harddrive. From there, ensure that it's synced and then when it's time to take a backup image, take the second disk in the array out(with a script, not physically) and copy the second harddrive. This would probably have serious performance concerns depending on how smart your RAID is(if you have to completely resync the drive everytime the backup completes), but this is a way to do it without taking your server offline

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .