I tried btrfs for the first time a few weeks ago. I had been looking for mature r/w filesystems that support realtime compression, and btrfs seemed like a good choice.
My use case is this: I normally make full disk images of my systems and store them on a (100TB) NAS. As the number of systems grows, the space available for multiple backup generations shrinks. So compression of disk images is good, until you want to recover something from a compressed disk image without doing a full restore. If I put an uncompressed disk image in a compressed (zstd) btrfs filesystem, I can mount volumes and access specific files without waiting days to uncompress.
So I gave it a try and did a backup of an 8TB SSD image to a btrfs filesystem, and it consumed less than 4TB, which was great. I was able to mount partitions and access individual files within the compressed image.
The next thing I tried, was refreshing the backup of a specific partition within the disk image. That did not go well.
Here's what I did to make the initial backup:
(This was done on an up-to-date Ubuntu 24.04 desktop.)
cd /btrfs.backups
truncate -s 7696581394432 8TB-Thinkpad.btrfs
mkfs.btrfs -L btrfs.backup 8TB-Thinkpad.btrfs
mount -o compress=zstd 8TB-Thinkpad.btrfs /mnt/1
pv < /dev/nvme0n1 > /mnt/1/8TB-Thinkpad.nvme0n1
All good so far. The backup took about three hours, but would probably go twice as fast if I had used my TB4 dock instead of a regular USB-C port for the backup media.
Things went bad when I tried to update one of the backed up partitions:
kpartx -a /mnt/1/8TB-Thinkpad.nvme0n1
pv < /dev/nvme0n1p5 > /dev/mapper/loop20p5
This sort of thing works just fine on a normal, uncompressed ext4 filesystem.
I did not really expect this to work here, and my expectations were met.
The result was a bunch of kernel errors, the backup device being remounted r/o, and a corrupt btrfs filesystem with a corrupt backup file.
So for this use case, btrfs is a big improvement for reading compressed disk images on the fly, but it is not suitable for re-writing sections of disk images.
My use case is this: I normally make full disk images of my systems and store them on a (100TB) NAS. As the number of systems grows, the space available for multiple backup generations shrinks. So compression of disk images is good, until you want to recover something from a compressed disk image without doing a full restore. If I put an uncompressed disk image in a compressed (zstd) btrfs filesystem, I can mount volumes and access specific files without waiting days to uncompress.
So I gave it a try and did a backup of an 8TB SSD image to a btrfs filesystem, and it consumed less than 4TB, which was great. I was able to mount partitions and access individual files within the compressed image.
The next thing I tried, was refreshing the backup of a specific partition within the disk image. That did not go well.
Here's what I did to make the initial backup:
(This was done on an up-to-date Ubuntu 24.04 desktop.)
cd /btrfs.backups
truncate -s 7696581394432 8TB-Thinkpad.btrfs
mkfs.btrfs -L btrfs.backup 8TB-Thinkpad.btrfs
mount -o compress=zstd 8TB-Thinkpad.btrfs /mnt/1
pv < /dev/nvme0n1 > /mnt/1/8TB-Thinkpad.nvme0n1
All good so far. The backup took about three hours, but would probably go twice as fast if I had used my TB4 dock instead of a regular USB-C port for the backup media.
Things went bad when I tried to update one of the backed up partitions:
kpartx -a /mnt/1/8TB-Thinkpad.nvme0n1
pv < /dev/nvme0n1p5 > /dev/mapper/loop20p5
This sort of thing works just fine on a normal, uncompressed ext4 filesystem. I did not really expect this to work here, and my expectations were met.
The result was a bunch of kernel errors, the backup device being remounted r/o, and a corrupt btrfs filesystem with a corrupt backup file.
So for this use case, btrfs is a big improvement for reading compressed disk images on the fly, but it is not suitable for re-writing sections of disk images.