Recovering From a Full btrfs Disk

By chimo on (updated on )

Jotting down the steps I took (found) to recover from a full (or “metadata full”) btrfs disk.

My btrfs disk for Incus storage is /dev/sdc, mounted at /var/lib/incus/storage-pools/pool1. My Operating System’s disk with available storage is /dev/sda.

# Create a 5GB disk-image on another drive
chimo@chromic:~$ dd if=/dev/zero of=/mnt/tmpBtrfs.img bs=1G count=5 # Set it up as loop device
chimo@chromic:~$ losetup -v -f /mnt/tmpBtrfs.img # Add it to btrfs
chimo@chromic:~$ btrfs device add /dev/loop1 /var/lib/incus/storage-pools/pool1 # Re-balance
chimo@chromic:~$ btrfs bal start /var/lib/incus/storage-pools/pool1

Now it’s time to free some disk space. In my case, I got rid of some extra container snapshots I had laying around. Once that’s done, we remove the temporary resources.

# Delete the temporary btrfs device
chimo@chromic:~$ btrfs device delete /dev/loop1 /var/lib/incus/storage-pools/pool1 # Remove loop device
chimo@chromic:~$ losetup -d /mnt/tmpBtrfs.img # Remove disk-image
chimo@chromic:~$ rm /mnt/tmpBtrfs.img