Score:0

files moved or erased from zfs drive don't free space on the drive

aq flag

I'm using ubuntu 21.10, installed anew with zfs filesystem. If I delete some files, and then empty the trashcan, or move them to another (external) drive) this doesn't free up space on the drive. actually df shows: rpool/ROOT/ubuntu_zooqq5 35G 4,5G 31G 13% / where 35GB is the drive size.

Every time I add some file to the disk, the drive size decrease.

I recover space (and drive size goes up) by deleting zfs snapshots with a script, but how can this be right?

Maybe it's a bug?

freezed avatar
cn flag
Welcome to Ask Ubuntu. Please [take the tour](https://askubuntu.com/tour) to learn how Ask Ubuntu works. Read [how to ask](https://askubuntu.com/questions/how-to-ask) to improve the quality of your question. Then take a look to [the help center](https://askubuntu.com/help/on-topic) to see if some _on-topic questions_ are already asked.
Score:2
ru flag

Removed files are still referenced by past snapshots, so what you describe is expected behaviour.

As you already observed, the space remains used due to snapshots; only after deleting the last snapshot that references the deleted files will the corresponding space be available again for new files.

Note that df does not provide accurate values for free space in ZFS file systems. ZFS uses one or more disks (or partitions) to store pools that can contain one or more datasets (interpreted by df as filesystems), all of which share the pool's free space. Snapshots also fill up the pool (as part of datasets), further affecting the 'Size' df reports for an individual file system. ZFS is both a file system, a volume manager, and optionally manages RAID arrays; it would be analogous to, e.g., ext4 on LVM optionally on RAID.

To see how pools correspond to disks or partitions, you can use zpool status. In Ubuntu, you can find the listed disks or partitions under /dev/disk/by-uuid/ and /dev/disk/by-partuuid/ respectively. To see the free space in pools, you can list all pools via zpool list. You can list all ZFS datasets ("file systems") via zfs list, where the USED column indicates the space used by the dataset, which includes the files, child datasets and snapshots belonging to a specific dataset; AVAIL indicates the remaining space in the pool, and REFER indicates the size of the files specific to this file system, i.e., not snapshots or child filesystems.

Andrea avatar
aq flag
Thanks for the info!
Andrea avatar
aq flag
Thanks for the info! "Removed files are still referenced by past snapshots, so what you describe is expected behaviour" I understand and agree to this technical opinion but my point is that in a desktop environment not in beta or other development status this shouldn't happen. ZFS on last version of Ubuntu is not marked as "experimental" and that's the reason I decided to try it. But for a file system to not make available the space freed by deleting files is something absurd in my opinion
ru flag
Happy to help! Since you do not like that snapshots prevent you from freeing disk space immediately, you are welcome to disable them: https://askubuntu.com/questions/1233049/disable-automatic-zsys-snapshots-zfs-on-root. If you feel strongly that you should not have to do this, you could file a bug report requesting Canonical to disable ZFS snapshots out-of-the-box: https://bugs.launchpad.net/ubuntu. If you feel your question is answered, please mark the answer as accepted.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.