Skip to contentSkip to conversation

Cross subvolume "cp --reflink"?

DISCUSSION Andrei Borzenkov 3 participants 4 messages Oct 19, 2016 Btrfs file system

lore
Share & tools
lore
#0 lore raw

I get "Failed to clone: Invalid cross-device link". Is it expected? Basically this is (on openSUSE TW which has root on subvolume)

mount -o subvol=/ /dev/vda1 /mnt
btrfs sub create /mnt/var/cache
cp -a --reflink=always /var/cache/* /mnt/var/cache

Kernel 4.7.5-1-default.

#1 lore raw
Quoted 8 lines · Andrei Borzenkov

I get "Failed to clone: Invalid cross-device link". Is it expected? Basically this is (on openSUSE TW which has root on subvolume)

mount -o subvol=/ /dev/vda1 /mnt
btrfs sub create /mnt/var/cache
cp -a --reflink=always /var/cache/* /mnt/var/cache

Kernel 4.7.5-1-default.

Yes, you're trying to copy across a mountpoint boundary. This isn't
going to work. You'll need to mount subvolid=0 on /mnt, and then use the source and target of the cp *both* from within the /mnt subtree.

Reflink operations (including cp --reflink=always, and the
reflink-aware mv) work across subvol boundaries, but not mount boundaries.

Hugo.

Signature · 4 lines
Hugo Mills             | For months now, we have been making triumphant
hugo@... carfax.org.uk | retreats before a demoralised enemy who is advancing
http://carfax.org.uk/  | in utter disorder.
PGP: E2AB1DE4          |                              Eric Frank Russell, Wasp
#2 lore raw

19.10.2016 20:04, Hugo Mills пишет:

Quoted 14 lines · Andrei Borzenkov
Quoted 8 lines

I get "Failed to clone: Invalid cross-device link". Is it expected? Basically this is (on openSUSE TW which has root on subvolume)

mount -o subvol=/ /dev/vda1 /mnt
btrfs sub create /mnt/var/cache
cp -a --reflink=always /var/cache/* /mnt/var/cache

Kernel 4.7.5-1-default.

Yes, you're trying to copy across a mountpoint boundary. This isn't
going to work. You'll need to mount subvolid=0 on /mnt, and then use the source and target of the cp *both* from within the /mnt subtree.

Quoted 6 lines

Reflink operations (including cp --reflink=always, and the
reflink-aware mv) work across subvol boundaries, but not mount boundaries.

Hugo.

Yes, figured that much too. Thank you!

#3 lore raw
In reply to Andrei Borzenkov
Quoted 1 line · Andrei Borzenkov

I get "Failed to clone: Invalid cross-device link". Is it expected?

Yes, you cannot cross a MOUNTPOINT boundary with reflink. Or, for that matter, btrfs subvolume snapshot.

Quoted 6 lines

Basically this is (on openSUSE TW which has root on subvolume)

mount -o subvol=/ /dev/vda1 /mnt
btrfs sub create /mnt/var/cache
cp -a --reflink=always /var/cache/* /mnt/var/cache

You *can* however cross subvolume boundaries within the same mountpoint. Try (assuming your root subvolume is @root)

cp -a --reflink /mnt/@root/var/cache/* /mnt/var/cache

~ Noah