How to delete directory containers/migration.957615475/.migration-send on BTRFS

What is the proper way to delete containers/migration.XXXXXXXXX directories from BTRFS storage used by LXD.

Here is the situation:

raspi4a# lxc storage list
+---------+-------------+--------+------------------------------------------------+---------+
|  NAME   | DESCRIPTION | DRIVER |                     SOURCE                     | USED BY |
+---------+-------------+--------+------------------------------------------------+---------+
| BTRFS   |             | btrfs  | /dev/sda2                                      | 13      |
+---------+-------------+--------+------------------------------------------------+---------+

raspi4a# mount | grep sda2
/dev/sda2 on /mnt type btrfs (rw,noatime,space_cache,user_subvol_rm_allowed,subvolid=5,subvol=/)

raspi4a# ls -al /mnt/containers/
total 16
drwx--x--x  1 root    root 304 Jun 17 09:13 .
drwxr-xr-x  1 root    root 200 Jun 17 19:38 ..
d--x------  1 1000000 root  78 Jun 16 06:00 BACKUPS
d--x------  1 1000000 root  78 Jun 12 09:31 DNS-AUTH
d--x------  1 1000000 root  78 Jun  6 21:31 GITEA
d--x------+ 1 1000000 root  78 Jun  6 21:52 LDAP
d--x------  1 1000000 root  78 Jun  6 19:26 MAIL
d--x------  1 root    root  30 Jun 14 13:43 migration.006312335
d--x------  1 root    root  30 Jun 14 13:17 migration.712251996
d--x------  1 root    root  30 Jun 14 13:39 migration.789883147
d--x------  1 root    root  30 Jun 14 13:05 migration.957615475
d--x------  1 root    root  30 Jun 14 13:12 migration.981568801
d--x------  1 1000000 root  78 Sep 17  2019 MONIT
d--x------  1 root    root  78 Feb 22 22:06 NODERED
d--x------  1 1000000 root  78 Nov  9  2018 PIHOLE
d--x------  1 1000000 root  78 Jun  6 22:01 SQL-A
d--x------  1 1000000 root  78 Jun  6 21:41 TEST


raspi4a# btrfs subvolume list /mnt
ID 257 gen 34176 top level 5 path containers/PIHOLE
ID 260 gen 30940 top level 5 path containers/NODERED
ID 263 gen 34176 top level 5 path containers/MONIT
ID 266 gen 34148 top level 5 path containers/MAIL
ID 308 gen 34173 top level 5 path containers/GITEA
ID 310 gen 34176 top level 5 path containers/TEST
ID 314 gen 34164 top level 5 path containers/LDAP-A
ID 318 gen 34176 top level 5 path containers/SQL-A
ID 334 gen 24821 top level 5 path containers/DNS-AUTH
ID 340 gen 23750 top level 5 path containers/migration.957615475/.migration-send
ID 343 gen 23772 top level 5 path containers/migration.981568801/.migration-send
ID 344 gen 23793 top level 5 path containers/migration.712251996/.migration-send
ID 347 gen 23868 top level 5 path containers/migration.789883147/.migration-send
ID 349 gen 23890 top level 5 path containers/migration.006312335/.migration-send
ID 353 gen 34175 top level 5 path containers/BACKUPS
ID 405 gen 32797 top level 5 path images/7b0a9e288e266e8ebc8a238874b4b341cd737ef777d2b0e22ec83288e17f6412
ID 406 gen 33550 top level 5 path images/6db79fb4d39d90d7699dfb5686901fd78a317a0d15f774f6d982048210288636

raspi4a# rm -Rf /mnt/containers/migration.712251996/ 2>&1 | head -5
rm: cannot remove '/mnt/containers/migration.712251996/.migration-send/metadata.yaml': Read-only file system
rm: cannot remove '/mnt/containers/migration.712251996/.migration-send/templates/cloud-init-meta.tpl': Read-only file system
rm: cannot remove '/mnt/containers/migration.712251996/.migration-send/templates/cloud-init-network.tpl': Read-only file system
rm: cannot remove '/mnt/containers/migration.712251996/.migration-send/templates/cloud-init-user.tpl': Read-only file system
rm: cannot remove '/mnt/containers/migration.712251996/.migration-send/templates/hostname.tpl': Read-only file system

So how can I remove containers/migrations.* directories
I guess theese are leftovers from failed lxc copy TEST raspi4a:TEST because source raspberry pi crashed during transfer.

Try removing the read-only property on the subvolume:

btrfs property set /mnt/containers/migration.712251996/.migration-send/  ro false
1 Like

Thank you, that did it. I just hope there aren`t any leftovers in lxd database regarding those migration.* directories.

No there shouldn’t be, it is only a temporary btrfs volume to send the migration in.