How to copy a btrfs subvolume to another volume (partition/disk)?
The btrfs utility has two commands to write and read a subvolume to a general
file, which can be a stdout/stdin too. They are '
Note that '
send' and '
receive' are designed for
backup purposes. The received subvolume copy will be initially readonly. You
have to normalize the copied subvolume with snapshot.
Reference command sequence for copying subvolumes:
1. Create a readonly snapshot copy of the subvolume to be copied:
btrfs subvolume snapshot /mnt/vol_0/sub /mnt/vol_0/sub.snapshot
btrfs subvolume snapshot -r /mnt/vol_0/sub.snapshot
1. Copy the subvolume to another volume:
btrfs subvolume send /mnt/vol_0/sub.readonly | btrfs receive /mnt/vol_1/
2. Normalize the readonly subvolume copy with snapshot:
btrfs subvolume snapshot /mnt/vol_1/sub.readonly /mnt/vol_1/sub
3. (Optional) Now the copied subvolume is available at /mnt/vol_1/sub for both
read and write. The readonly copy can be deleted safely:
btrfs subvolume delete /mnt/vol_0/sub.readonly
btrfs subvolume delete /mnt/vol_1/sub.readonly