volcopy for Linux?

Written by:

Reading one of the editions of the Nemeth’s book (Nemeth et al), have read about volcopy — an utility that copies a filesystem from one device to another, making “a literal copy” (here’s a man page, though not too helpful).

The Book said the utility exists for Linux, but quick googlin’ didn’t show many results. So the question is — is it used on Linux, and if not, what is the default alternative to mirror-copy a filesystem ? dump and restore ?

Edit. I was thinking that such an utility could be useful in the case of e.g. hard disk replacement — currently I am using dd to replicate the root partition etc, this is fast but obviously preserves the size of the partition.
So I thought volcopy could be a quick alternative that allows to copy to a bigger partition. dump | restore allow to to that, if I am not mistaken. Sorry for being too unspecific initially.

What you’re looking for is a way to clone a filesystem, a disk or partition. See in particular

Cloning the whole disk or partition with cat or cp is the simplest method. There’s no reason to use dd, especially since dd is slower. It requires that the filesystem not be mounted, and it also copies the empty space, so it can be slow for that reason.

On Linux (or more precisely with GNU coreutils), cp -a does a good job of copying files and preserving metadata, but it’s not perfect. Also, not that copying files can be slower even if the disk is not full, because it is a lot faster to copy disks large swathes at a time than to shuffle back and forth copying each fragment of a file.

If your disks or partitions are on a RAID-1 (mirroring RAID) volume and you want to copy them to a new disk, you can add the new disk to the array. This is pretty fast, less error-prone than using cat on the block devices, and can be done online with everything mounted. The only reason not to do this is when your source partition is not on a RAID-1 volume; you can turn a plain old partition into a Linux software RAID-1 volume, but it takes a bit of low-level work.

If the filesystem you want to copy is on an LVM volume, you can use LVM’s mirroring feature.

Gilles

You can use dd to copy the data from one device to another.

dd if=/my/source/device of=/my/dest/device bs=4096

dd will do a byte-per-byte copy of the source, of course you will not be able to do this on a running filesystem, this will most likely cause corrupt data. If you are using a fileystem or some other utility like LVM with snapshot ability you can create a snapshot and copy it instead.

lvcreate -L1G -s -n my-snapshot-of-lvname /dev/vgname/lvname
dd if=/dev/vgname/my-snapshot-of-lvname of=/my/dest/path bs=4096
lvremove /dev/vgname/my-snapshot-of-lvname

LVM also has some built in tools for volume management.

Linux has the filesystem btrfs, it’s a new still unstable filesystem (inspired by ZFS from Solaris). Btrfs is NOT ready for production but it will most likely be able to do everything you need.

Of course, you may also use rsync (i recommend the a-flag), but that is not a volume copy, but in most cases it will work just fine.

rsync -a /source /path

nsg

Partimage makes exact copies of a partition having a supported filesystem, to the extent that it will copy the filesystem uuid as well. So you may need to change one of the uuids, if it confuses your OS or bootloader. Notable limitation – currently it does not support ext4 or btrfs.

It is also free software, reliable, simple to use, well documented and works on the console so it is easy to use remotely. Basically, it will save the contents of the partition to a file, and then write it back wherever you want.

PS. The partimage page also mentions FSArchiver, but I have never used that.

Faheem Mitha

I would resort to using rsync tool to setup a mirror-copy sync of a filesystem. It is best since in making differential copies faster once the initial sync is done, leading to less copy changes over the destination filesystem instead of whole copy irrespective of the quantity of changes.

Nikhil Mulley

dd is one of the oldest unix utilities, and does exactly that: duplicate a disk. Usually you do not want an exact duplicate though, because there is no reason to waste time and space copying the unused portions of the disk.

While dump does operate on the unmounted block device, restore does not, and together they do not reproduce an exact copy of the filesystem. Instead they just backup and restore the files in the filesystem, much like tar, only faster.

If you are looking to create a smart disk image that can be restored exactly as it was, you want something like Clonezilla or Ghost4Linux, which are smart enough to skip copying the unused disk blocks. They still can not restore to a disk that is smaller than the original though, nor can you selectively restore individual files, nor do incremental backups. For these reasons, I prefer traditional backup utilities like dump or tar.

psusi

volcopy for Linux?
0 votes, 0.00 avg. rating (0% score)

Leave a Reply