On 1/28/20 11:25 AM, Robbie Smith wrote:
I wanted to try to convert my music library from a directory into a
subvolume so I could use btrfs send/receive to transfer (changed)
files between it and a USB backup. A bit of Googling suggested that
the approach would be:
btrfs subvolume create /library/newmusic
cp -ar --reflink=auto /library/music/* /library/newmusic/.
rm -r /library/music
After about 30 seconds I realised that it was deleting files from both
/library/music and /library/newmusic. It appears I've only lost
everything starting with A, B or C, so I unmounted the device, and am
currently trying to use `btrfs restore` to get the files back and it
doesn't seem to be finding them.
I'm pretty sure deleting files from directory A isn't supposed to also
delete them from directory B, but that's what it did. Is this a bug?
Whatever happened - this is not it. I do this all the time without
problems. Also note that you can use mv directly, since it will
use reflink when possible:
$mkdir data
$echo "foo" > data/data
$btrfs subvolume create newdata
Create subvolume './newdata'
$mv data/* newdata
$ll data
total 0
$rm -rf data
$ll newdata
total 4.0K
-rw-r--r-- 1 root root 4 Jan 28 12:16 data
$cat newdata/data
foo
All as expected.
-h