I have an SSD disk with several partitions. One of them is has a btrfs volume, mounted as
/home, which holds an ecryptfs home directory.
When I trim the volumes, it seems that fstrim doesn't trim data blocks on such volume - why? Below you can see all the informations about the setup, and the procedure I follow, with comments.
$ cat /etc/fstab:
UUID=xxx / ext4 errors=remount-ro 0 1 UUID=yyy /media/vfio ext4 defaults 0 2 UUID=zzz /home btrfs defaults 0 2
$ mount | grep sda:
/dev/sda5 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered) /dev/sda1 on /media/vfio type ext4 (rw,relatime,stripe=32721,data=ordered) /dev/sda2 on /home type btrfs (rw,relatime,ssd,space_cache,subvolid=5,subvol=/)
$ ls -la /home /home/myuser/.Private # summary:
/home: .ecryptfs myuser /home/myuser/.Private -> /home/.ecryptfs/myuser/.Private
$ df -h:
Filesystem Size Used Avail Use% Mounted on /dev/sda5 16G 11G 4,7G 69% / /dev/sda1 93G 52G 36G 60% /media/vfio /dev/sda2 828G 542G 286G 66% /home /home/myuser/.Private 828G 542G 286G 66% /home/myuser
I execute fstrim on all the volumes, for the first time.
$ fstrim -va:
/home/myuser: 286,4 GiB (307518836736 bytes) trimmed /home: 286,4 GiB (307485450240 bytes) trimmed /media/vfio: 40,4 GiB (43318886400 bytes) trimmed /: 5,4 GiB (5822803968 bytes) trimmed
It seems that fstrim runs twice on the
/home tree, due to the additional ecryptfs mount. This would be ok (I could avoid it by running an fstrim with specific mountpoints). The problem is that trimming
/home is not working as expected, as each run finds and trims the same amount of data.
This is shown by a further run.
$ fstrim -v / (this is ok):
/: 0 B (0 bytes) trimmed
$ fstrim -v /home (this isn't ok):
/home: 286,4 GiB (307478061056 bytes) trimmed
Note that the sda2 (
/home) trimming takes some time to run, so it's actually doing something.