Thanks both @dalto and @FGD for your input. I managed to solve the problem as @dalto specified. I don´t know what went wrong the first times I tried to send/receive. Maybe it had to do with the fact I had just cleaned caches using Stacer and had done a balance (using the recommend command by @tbg applied to /home
).
The steps I followed and what I learned:
BACKUP YOUR DATA
-
Create a read-only snapshot of my
/home
btrfs partition (lesson: the filesystem volume is itself a subvolume) calledhome-transfer
. This needs to be created inside the same device:
# btrfs subvolume snapshot -r /home /home/home-transfer
Only read-only subvolumes can be send/received across devices. -
Mount the (hidden) top level volume of the system by mounting the corresponding device or partition (in my case this is
/dev/nvme0n1p3
):
# mkdir /mnt/btrfs && mount /dev/nvme0n1p3 /mnt/btrfs/
We do this so we can access the top level and keep a consistent (flat) subvolume layout. It’s still hard to wrap my head around the possibility of mounting the very filesystem being used on a directory inside itself. Even weirder was that this filesystem wasn’t actually mounted, but a subvolume of it on/
. A filesystem can be mounted on multiple directories with no issues, as mentioned in the man page of mount:The same filesystem may be mounted more than once, and in some cases (e.g., network filesystems) the same filesystem may be mounted on the same mountpoint
multiple times. -
Transfer the subvolume (across devices), placing it at the top level:
# btrfs send /home/home-transfer | btrfs receive /mnt/btrfs/
Confirm the operation with
# btrfs subvolume list /
-
Now create a writable snapshot of the transfered subvolume called
@home
:
# btrfs subvolume snapshot /mnt/btrfs/home-transfer /mnt/btrfs/@home
Its good time now to delete the read-only snapshot:
# btrfs subvolume delete /mnt/btrfs/home-transfer
-
Then modify the fstab accordingly. I changed the
/home
mount point line so the UUID pointed to the same device as the other system subvolumes, instead of my original/home
partition UUID, and added the optionsubvol=@home
. Not without making a backup file before:
# cp /etc/fstab /etc/fstab.bak
-
Then
$ reboot
to the new configuration. Everything should be working as nothing had happened. -
Now we can clean our mess by removing the auxiliary mounting directory and backup fstab:
# rmdir /mnt/btrfs && rm /etc/fstab.bak
I still have to erase the now obsolete partition and grow my system’s partition, but this is no issue.
Thanks for all your help.
PS, after mounting the top level subvolume I discovered a timeshift-btrfs
directory with some old snapshot’s json files, which I deleted at once.