When my user inserts a usb memory stick I want to show a quick response in my application. Now it takes close to 3 seconds before the USB drive is mounted. Is it possible to reduce this time?
Here an excempt from the logging when inserting a USB drive:
Tue Jun 30 20:16:55 2020 kern.info kernel: [ 621.695598] usb 1-1: new high-speed USB device number 5 using ehci-platform
Tue Jun 30 20:16:55 2020 kern.info kernel: [ 621.921996] usb-storage 1-1:1.0: USB Mass Storage device detected
Tue Jun 30 20:16:55 2020 kern.info kernel: [ 621.955596] scsi host0: usb-storage 1-1:1.0
Tue Jun 30 20:16:55 2020 user.notice root: testlog YES!!!!!
Tue Jun 30 20:16:56 2020 kern.notice kernel: [ 622.976969] scsi 0:0:0:0: Direct-Access USB 2.0 Flash Disk 1100 PQ: 0 ANSI: 0 CCS
Tue Jun 30 20:16:56 2020 kern.notice kernel: [ 622.990157] sd 0:0:0:0: [sda] 990208 512-byte logical blocks: (507 MB/484 MiB)
Tue Jun 30 20:16:56 2020 kern.notice kernel: [ 623.005593] sd 0:0:0:0: [sda] Write Protect is off
Tue Jun 30 20:16:56 2020 kern.debug kernel: [ 623.010531] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
Tue Jun 30 20:16:56 2020 kern.err kernel: [ 623.032037] sd 0:0:0:0: [sda] No Caching mode page found
Tue Jun 30 20:16:56 2020 kern.err kernel: [ 623.037543] sd 0:0:0:0: [sda] Assuming drive cache: write through
Tue Jun 30 20:16:56 2020 kern.info kernel: [ 623.274030] sda: sda1
Tue Jun 30 20:16:56 2020 kern.notice kernel: [ 623.283487] sd 0:0:0:0: [sda] Attached SCSI removable disk
Tue Jun 30 20:16:57 2020 kern.warn kernel: [ 624.085781] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
In /etc/hotplug.d/usb/20-autorun I added a log line "YES!!!" which was logged within 1 second after insertion. I added a sleep(4) here, but even that delay is not always long enough for the drive to be properly accesible on the mounted location.
Questions:
- Is it possible to speed up the mount process? Perhaps reduce the number of supported file types? etc?
- I hate the hard coded timeout. Is it possible to be signalled when the usb drive finished mounting?