====== Linux USB-Mount ======
Recently I noticed the problem, that I could write only with speeds of about 500kByte/s onto USB flash drives. 20MBytes/s should be normally possible.
My observeations so far:
===== Errors on already mounted =====
The error message came from my file manager ''nemo'', and it could be removed by disabling the automount feature of ''nemo'', since ''usbmount'' keeps track of this task.
nemo -> menu -> edit -> preferences -> behavior -> media handling -> uncheck "Automatically mount removable media when inserted and on startup"
My system mounts a plugged in USB drive automatically on ''/media/usb0'', or with the suffix 1,2,3. These directories exist on my system permanently. When I plug the drive in the first time after boot, it will be mounted to usb0, after remounting it 3 times, it will be mounted in usb3. On the next replug, it will be mounted e.g. on ''/media/karl/E2A3-F90D''. All the ''/media/usb*'' dirs cannot be deleted:
sudo rm -R /media/usb0
rm: cannot remove 'usb0': Device or resource busy
a
sudo umount /media/usb0
is needed before that folder can be removed.
===== Removed usbmount --> using pmount =====
''usbmount'' is a script installed on my system and it seems to be run by the ''udev''-rule in ''/lib/udev/rules.d/90-usbmount.rules''. It's config is in ''/etc/usbmount/usbmount.conf'':
++++ usbmount.conf |
# Configuration file for the usbmount package, which mounts removable
# storage devices when they are plugged in and unmounts them when they
# are removed.
# Change to zero to disable usbmount
ENABLED=1
# Mountpoints: These directories are eligible as mointpoints for
# removable storage devices. A newly plugged in device is mounted on
# the first directory in this list that exists and on which nothing is
# mounted yet.
MOUNTPOINTS="/media/usb0 /media/usb1 /media/usb2 /media/usb3
/media/usb4 /media/usb5 /media/usb6 /media/usb7"
# Filesystem types: removable storage devices are only mounted if they
# contain a filesystem type which is in this list.
FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus ntfs exfat"
#############################################################################
# WARNING! #
# #
# The "sync" option may not be a good choice to use with flash drives, as #
# it forces a greater amount of writing operating on the drive. This makes #
# the writing speed considerably lower and also leads to a faster wear out #
# of the disk. #
# #
# If you omit it, don't forget to use the command "sync" to synchronize the #
# data on your disk before removing the drive or you may experience data #
# loss. #
# #
# It is highly recommended that you use the pumount command (as a regular #
# user) before unplugging the device. It makes calling the "sync" command #
# and mounting with the sync option unnecessary---this is similar to other #
# operating system's "safely disconnect the device" option. #
#############################################################################
# Mount options: Options passed to the mount command with the -o flag.
# See the warning above regarding removing "sync" from the options.
MOUNTOPTIONS="sync,noexec,nodev,noatime,nodiratime,uid=1000,gid=1000"
# Filesystem type specific mount options: This variable contains a space
# separated list of strings, each which the form "-fstype=TYPE,OPTIONS".
#
# If a filesystem with a type listed here is mounted, the corresponding
# options are appended to those specificed in the MOUNTOPTIONS variable.
#
# For example, "-fstype=vfat,gid=floppy,dmask=0007,fmask=0117" would add
# the options "gid=floppy,dmask=0007,fmask=0117" when a vfat filesystem
# is mounted.
FS_MOUNTOPTIONS=""
# If set to "yes", more information will be logged via the syslog
# facility.
VERBOSE=no
++++
==== mount ====
Calling ''mount'' on a terminal shows these last lines:
/dev/sdc on /media/usb0 type vfat (rw,nodev,noexec,noatime,nodiratime,sync,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/sdd on /media/usb1 type vfat (rw,nodev,noexec,noatime,nodiratime,sync,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/sde on /media/usb2 type vfat (rw,nodev,noexec,noatime,nodiratime,sync,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/sdf on /media/usb3 type vfat (rw,nodev,noexec,noatime,nodiratime,sync,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/sdh on /media/karl/E2A3-F90D type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)
The mount options are quite different.
The option ''nosuid'' is missing for usb0...usb3, which prevents the normal user to unmount it.
I've uninstalled ''usbmount'' without any obvious problems so far.
According to (([[https://community.linuxmint.com/software/view/usbmount]])) ''pmount'' is used instead, which is installed on my Linux Mint 19.1 handles the automatic mounting of USB drives, which results e.g. to such a line in the output of ''mount'':
/dev/sdc on /media/karl/E2A3-F90D type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)
===== Nemo's reported writing speed =====
Normally it showed a reasonable writing speed. But recently this changed to very high speeds, and then hanging at 98 or 100%.
Calling ''sync'' in the terminal synchronizes all block devices (as far as I understand). Calling it with ''time sync'' reports the time ''sync'' needed to finish it's job.
Flash drives should **not** be mounted with the mount-option ''sync'', since this could cause such issues.
Running
sudo sysctl vm.dirty_bytes=15000000
as suggested here (([[https://unix.stackexchange.com/questions/180818/gnome-nautilus-copy-files-to-usb-stops-at-100-or-near]])), which is described more in detail here (([[https://lwn.net/Articles/572911/]])) didn't help.
This problem remains unsolved.
===== Useful Commands =====
mount
sudo umount /media/usb0
time sync
sync
dmesg
lsusb -t
{{tag>english software linux}}