You are not logged in.
According to this article, loopback devices support discard operation by punching holes in the backing file. Also the kernel source for loop.c looks that this is the case.
However, when I tried to use it, "fstrim" reports "the discard operation is not supported":
fallocate testfile -l 10000000000
losetup /dev/loop0 testfile
mkfs.ext4 /dev/loop0
mkdir tempdir
mount -o discard /dev/loop0 tempdir
fstrim -v tempdir
fstrim: tempdir: the discard operation is not supportedThe filesystem on which testfile resides is ext4 which should be supported. I can also verify it with "fallocate -v -d testfile" which successfully converts zeros to sparse holes.
What am I missing here? My kernel version is 5.12.12.
Last edited by bachtiar (2022-11-07 14:04:47)
Offline
I don't think you're calling fstrim on the filesystem you want, but instead calling it on the filesystem which contains the mountpoint directory. If that's correct, then:
fstrim -v tempdir/...would do what you are intending I think.
Offline
fstrim tempdir/vs.
fstrim tempdirdoes not make a difference.
However, with kernel 5.19.4 it works as expected (both ways).
Offline