There are several options that each have tradeoffs. You can not use dd
to clone a filesystem while it is mounted read/write or the clone will end up corrupt since the source is being changed during the copy so the destination will be partially out of date and partially not. If you really want to be able to use dd
to hot copy a partition, you can do so with LVM snapshots. This requires that you have installed the system using LVM in the first place, but then you can create a snapshot at any time, and since the snapshot is frozen and not mounted, you can safely dd
the snapshot, then remove the snapshot. The other down side to using dd
is that it wastes time copying all of the unused space in the volume, and requires the destination be at least as large, even if most of the source is unused.
Rather than use dd
, you can simply use traditional backup tools such as tar
or dump
to backup the snapshot. This has the advantage of not wasting time copying free space, and can be restored to a smaller partition as long as it has space for the files. You can also extract only some of the files to do a partial restore. You also don't have to use LVM with this method: as long as you are reasonably sure that no files are being modified when you make the backup, it is safe to do on a mounted filesystem. The worst thing that can happen is that an individual file that is modified during the backup will be corrupt, rather than the entire backup being corrupt, as can happen with dd
.
As you seem to have realized, after restoring the filesystem, you still need to reinstall grub to get the system to boot. I'm not sure why you got that error when you tried, but it seems you were using grub-legacy, since grub2 does not have a stage1.