TL;DR: Is there a way to clone a disk's metadata to another disk?
I'm trying to copy all the data (including metadata) of a 4TiB disk to another 2TiB disk. I've verified that the 4TiB disk contains only 1TiB data, and its filesystem is
My previous approach was as follows:
- Resize the filesystem on the source disk:
resize2fs -M <source disk mountpath>
- Calculate the number of 16MiB blocks needed for the shrunk filesytem.
- Use dd to copy all the data (including metadata):
dd bs=16M if=<src> of=<dst> count=<# block calculated in step2.
This method works fine when the data amount is relatively small. But when the data size is large, for example
dd can take a long time.
I'm thinking about using
rsync instead of
dd, so there is no need to resize the original filesystem, and plus
rsync seems to be faster than
dd. But one problem is that
rsync does not copy over the disk metadata, like uuid, label, etc.
I would like the new disk to have the exact the same metadata as the original one, so that I can directly use the new disk to replace the original one without modifying anything on the server. Is there a way to clone the disk's metadata as well?