4 ms·
I managed to break a btrfs filesystem by exhausting metadata blocks. The filesystem would show as 50% occupied, but 0 bytes free. Everything started crashing. T
by janci 6y ago
I managed to break a btrfs filesystem by exhausting metadata blocks. The filesystem would show as 50% occupied, but 0 bytes free. Everything started crashing. The resolution is to run btrfs balance to free unused metadata blocks. There is a catch - you need at least some free space to run the balance. I had none, but managed to remove some unnecessary files (system package manager cache) to have just enough free space to run the balance. In meantime I discovered this condition was created by npm creating thousands of files while installing packages.
Later I run into the same problem (again with npm), but this time there was not enough of unnecessary files to delete to be able run the balance (package manager cache was already purged). Normally this can only be solved by adding new partition to the btrfs filesystem and I had no unformatted or unused partiton on disk left. Instead I wanted to get rid of the btrfs that failed me twice and rsynced whole btrfs content into a loop-mounted ext4 disk image on a NTFS drive and then after unmounting I dd-ed the disk image over the btrfs. It booted! Had not any more filesystem trouble ever since.