fstrim -av tries to trim read only mounted ntfs-3g and fails

Bug #1797717 reported by Boris Gjenero
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
util-linux (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

If I run sudo fstrim -av I see:
/media/SSD_Data: 2 GiB (2145820672 bytes) trimmed
fstrim: /media/Win7: FITRIM ioctl failed: Bad file descriptor
/: 26.9 GiB (28823887872 bytes) trimmed

/media/SSD_Data is read-write mounted NTFS via ntfs-3g, and /media/Win7 is read-only mounted NTFS, also via ntfs-3g. Lines from fstab:
UUID=censored /media/SSD_Data ntfs-3g rw,noatime,nofail,big_writes,windows_names,nosuid,nodev,allow_other,hide_hid_files,inherit,noexec 0 0
UUID=censored /media/Win7 ntfs-3g ro,nofail,big_writes,windows_names,nosuid,nodev,allow_other,noexec,hide_hid_files 0 0

If I do sudo umount /media/Win7 and then sudo mount -o rw /media/Win7 then sudo fstrim -av takes longer and succeeds for all filesystems. So, it seems the read only is the problem.

This seems cosmetic, but it causes periodic runs of fstrim via systemd to report failures.

ProblemType: Bug
DistroRelease: Ubuntu 18.10
Package: util-linux 2.32-0.1ubuntu1
ProcVersionSignature: Ubuntu 4.18.0-8.9-generic 4.18.7
Uname: Linux 4.18.0-8-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 2.20.10-0ubuntu11
Architecture: amd64
CurrentDesktop: XFCE
Date: Sat Oct 13 15:25:41 2018
SourcePackage: util-linux
UpgradeStatus: Upgraded to cosmic on 2018-10-11 (2 days ago)

Revision history for this message
Boris Gjenero (boris-gjenero) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in util-linux (Ubuntu):
status: New → Confirmed
Revision history for this message
Ivan Larionov (xeron-oskom) wrote :

I see the same warnings in systemd log.

systemd[1]: fstrim.service: Main process exited, code=exited, status=64/USAGE
systemd[1]: fstrim.service: Failed with result 'exit-code'.
systemd[1]: Failed to start Discard unused blocks.

If I run it manually:

$ sudo fstrim -av
/home: 9.7 GiB (10445021184 bytes) trimmed
fstrim: /mnt/win_c: FITRIM ioctl failed: Bad file descriptor
fstrim: /mnt/win_d: FITRIM ioctl failed: Bad file descriptor
fstrim: /mnt/win_g: FITRIM ioctl failed: Bad file descriptor
fstrim: /mnt/win_e: FITRIM ioctl failed: Bad file descriptor
fstrim: /mnt/win_f: FITRIM ioctl failed: Bad file descriptor
fstrim: /mnt/win_re: FITRIM ioctl failed: Bad file descriptor
/: 2.4 GiB (2608013312 bytes) trimmed

with exit status 64.

Related mount points:

$ mount | grep win
/dev/sda4 on /mnt/win_re type fuseblk (ro,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
/dev/sdc1 on /mnt/win_f type fuseblk (ro,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
/dev/sdb1 on /mnt/win_e type fuseblk (ro,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
/dev/sdd1 on /mnt/win_g type fuseblk (ro,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
/dev/sda5 on /mnt/win_d type fuseblk (ro,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
/dev/sda3 on /mnt/win_c type fuseblk (ro,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
/dev/sde1 on /mnt/win_h type fuseblk (ro,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)

tags: added: disco
tags: added: eoan
Revision history for this message
Boris Gjenero (boris-gjenero) wrote :

Right now in 19.10, /lib/systemd/system/fstrim.service runs /sbin/fstrim --fstab --verbose --quiet , which doesn't cause the service to report these errors. According to the fstrim man page, for the --fstab option: "Errors from filesystems that do not support the discard operation, read-only devices and read-only filesystems are silently ignored."

So, I consider this fixed now. Feel free to close the issue.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.