Eastonboy99
Posts: 6
Joined: Sat Jan 16, 2016 11:04 pm

Auto Mount USB drive When it is plugged in.

Sat Jan 16, 2016 11:18 pm

Hi there.

I am currently working on a project that requires being about to plug in a usb drive and have it automount without using fstab. I fount a guide here (http://www.axllent.org/docs/view/auto-m ... b-storage/) that works, but when I plug in my exfat drive, it says:

Code: Select all

Transport endpoint is not connected
If I unmount and remount in the command line, It works perfectly.
Does anyone have any ideas?

System:
Raspberry pi 2
OS: Minibian https://minibianpi.wordpress.com/

Thanks in advance.[/size]

elatllat
Posts: 1337
Joined: Sat Dec 17, 2011 5:05 pm

Re: Auto Mount USB drive When it is plugged in.

Sun Jan 17, 2016 5:46 pm

SBC with 32GB RAM: https://hardkernel.com

FAQ : https://raspberrypi.stackexchange.com

Unanswered: https://www.raspberrypi.org/forums/search.php?search_id=unanswered

Eastonboy99
Posts: 6
Joined: Sat Jan 16, 2016 11:04 pm

Re: Auto Mount USB drive When it is plugged in.

Sun Jan 17, 2016 7:07 pm

I have tried this and I can get the script to run. The problem is that the usb will not mount correctly when the script is called from udev. If I run the script crom the command line it works without any problems. I think there is a problem with exFAT.

elatllat
Posts: 1337
Joined: Sat Dec 17, 2011 5:05 pm

Re: Auto Mount USB drive When it is plugged in.

Sun Jan 17, 2016 10:42 pm

check printenv or using fusermount directly.
SBC with 32GB RAM: https://hardkernel.com

FAQ : https://raspberrypi.stackexchange.com

Unanswered: https://www.raspberrypi.org/forums/search.php?search_id=unanswered

Eastonboy99
Posts: 6
Joined: Sat Jan 16, 2016 11:04 pm

Re: Auto Mount USB drive When it is plugged in.

Mon Jan 18, 2016 3:03 am

I'm sorry but I have no idea how to use those. From what I see on google is that fusermount is used to unmount a drive which I don't have any issues with. I think I have narrowed down what my problem is. When I monitor udev with udevadm monitor -u --environment I get back this:

Code: Select all

pi@raspberrypi:/media $ udevadm monitor -u --environment
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing

UDEV  [18113.436239] add      /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5 (usb)
ACTION=add
BUSNUM=001
DEVNAME=/dev/bus/usb/001/013
DEVNUM=013
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5
DEVTYPE=usb_device
ID_BUS=usb
ID_MODEL=Ultra_Fit
ID_MODEL_ENC=Ultra\x20Fit
ID_MODEL_ID=5583
ID_REVISION=0100
ID_SERIAL=SanDisk_Ultra_Fit_4C530001090220116482
ID_SERIAL_SHORT=4C530001090220116482
ID_USB_INTERFACES=:080650:
ID_VENDOR=SanDisk
ID_VENDOR_ENC=SanDisk
ID_VENDOR_FROM_DATABASE=SanDisk Corp.
ID_VENDOR_ID=0781
MAJOR=189
MINOR=12
PRODUCT=781/5583/100
SEQNUM=1239
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=113422832

UDEV  [18113.442549] add      /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0 (usb)
ACTION=add
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0
DEVTYPE=usb_interface
ID_VENDOR_FROM_DATABASE=SanDisk Corp.
INTERFACE=8/6/80
MODALIAS=usb:v0781p5583d0100dc00dsc00dp00ic08isc06ip50in00
PRODUCT=781/5583/100
SEQNUM=1240
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=3424393

UDEV  [18113.446688] add      /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8 (scsi)
ACTION=add
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8
DEVTYPE=scsi_host
SEQNUM=1241
SUBSYSTEM=scsi
USEC_INITIALIZED=3424622

UDEV  [18113.451471] add      /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/scsi_host/host8 (scsi_host)
ACTION=add
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/scsi_host/host8
SEQNUM=1242
SUBSYSTEM=scsi_host
USEC_INITIALIZED=3424789

UDEV  [18114.427819] add      /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0 (scsi)
ACTION=add
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0
DEVTYPE=scsi_target
SEQNUM=1243
SUBSYSTEM=scsi
USEC_INITIALIZED=4421398

UDEV  [18114.429730] add      /devices/virtual/bdi/8:0 (bdi)
ACTION=add
DEVPATH=/devices/virtual/bdi/8:0
SEQNUM=1249
SUBSYSTEM=bdi
USEC_INITIALIZED=114425376

UDEV  [18114.433887] add      /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0 (scsi)
ACTION=add
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0
DEVTYPE=scsi_device
MODALIAS=scsi:t-0x00
SEQNUM=1244
SUBSYSTEM=scsi
USEC_INITIALIZED=4421708

UDEV  [18114.441322] add      /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/scsi_device/8:0:0:0 (scsi_device)
ACTION=add
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/scsi_device/8:0:0:0
SEQNUM=1246
SUBSYSTEM=scsi_device
USEC_INITIALIZED=4421974

UDEV  [18114.443763] add      /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/scsi_disk/8:0:0:0 (scsi_disk)
ACTION=add
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/scsi_disk/8:0:0:0
SEQNUM=1245
SUBSYSTEM=scsi_disk
USEC_INITIALIZED=4421851

UDEV  [18114.446779] add      /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/scsi_generic/sg0 (scsi_generic)
ACTION=add
DEVNAME=/dev/sg0
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/scsi_generic/sg0
MAJOR=21
MINOR=0
SEQNUM=1247
SUBSYSTEM=scsi_generic
USEC_INITIALIZED=114422604

UDEV  [18114.447790] add      /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/bsg/8:0:0:0 (bsg)
ACTION=add
DEVNAME=/dev/bsg/8:0:0:0
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/bsg/8:0:0:0
MAJOR=252
MINOR=0
SEQNUM=1248
SUBSYSTEM=bsg
USEC_INITIALIZED=114423305

UDEV  [18114.788434] add      /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/block/sda (block)
ACTION=add
DEVLINKS=/dev/disk/by-id/usb-SanDisk_Ultra_Fit_4C530001090220116482-0:0 /dev/disk/by-path/platform-3f980000.usb-usb-0:1.5:1.0-scsi-0:0:0:0
DEVNAME=/dev/sda
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/block/sda
DEVTYPE=disk
ID_BUS=usb
ID_INSTANCE=0:0
ID_MODEL=Ultra_Fit
ID_MODEL_ENC=Ultra\x20Fit\x20\x20\x20\x20\x20\x20\x20
ID_MODEL_ID=5583
ID_PATH=platform-3f980000.usb-usb-0:1.5:1.0-scsi-0:0:0:0
ID_PATH_TAG=platform-3f980000_usb-usb-0_1_5_1_0-scsi-0_0_0_0
ID_REVISION=1.00
ID_SERIAL=SanDisk_Ultra_Fit_4C530001090220116482-0:0
ID_SERIAL_SHORT=4C530001090220116482
ID_TYPE=disk
ID_USB_DRIVER=usb-storage
ID_USB_INTERFACES=:080650:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=SanDisk
ID_VENDOR_ENC=SanDisk\x20
ID_VENDOR_ID=0781
MAJOR=8
MINOR=0
SEQNUM=1250
SUBSYSTEM=block
TAGS=:systemd:
UDISKS_PARTITION_TABLE=1
UDISKS_PARTITION_TABLE_COUNT=1
UDISKS_PARTITION_TABLE_SCHEME=mbr
UDISKS_PRESENTATION_NOPOLICY=0
USEC_INITIALIZED=4468345

UDEV  [18115.012883] add      /devices/virtual/bdi/8:1-fuseblk (bdi)
ACTION=add
DEVPATH=/devices/virtual/bdi/8:1-fuseblk
SEQNUM=1252
SUBSYSTEM=bdi
USEC_INITIALIZED=5011402

UDEV  [18115.180791] add      /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/block/sda/sda1 (block)
ACTION=add
DEVLINKS=/dev/disk/by-id/usb-SanDisk_Ultra_Fit_4C530001090220116482-0:0-part1 /dev/disk/by-label/test /dev/disk/by-path/platform-3f980000.usb-usb-0:1.5:1.0-scsi-0:0:0:0-part1 /dev/disk/by-uuid/8831-F631
DEVNAME=/dev/sda1
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/block/sda/sda1
DEVTYPE=partition
ID_BUS=usb
ID_FS_LABEL=test
ID_FS_LABEL_ENC=test
ID_FS_TYPE=exfat
ID_FS_USAGE=filesystem
ID_FS_UUID=8831-F631
ID_FS_UUID_ENC=8831-F631
ID_FS_VERSION=1.0
ID_INSTANCE=0:0
ID_MODEL=Ultra_Fit
ID_MODEL_ENC=Ultra\x20Fit\x20\x20\x20\x20\x20\x20\x20
ID_MODEL_ID=5583
ID_PART_ENTRY_DISK=8:0
ID_PART_ENTRY_FLAGS=0x80
ID_PART_ENTRY_NUMBER=1
ID_PART_ENTRY_OFFSET=2048
ID_PART_ENTRY_SCHEME=dos
ID_PART_ENTRY_SIZE=121432064
ID_PART_ENTRY_TYPE=0x7
ID_PART_ENTRY_UUID=00003adc-01
ID_PATH=platform-3f980000.usb-usb-0:1.5:1.0-scsi-0:0:0:0
ID_PATH_TAG=platform-3f980000_usb-usb-0_1_5_1_0-scsi-0_0_0_0
ID_REVISION=1.00
ID_SERIAL=SanDisk_Ultra_Fit_4C530001090220116482-0:0
ID_SERIAL_SHORT=4C530001090220116482
ID_TYPE=disk
ID_USB_DRIVER=usb-storage
ID_USB_INTERFACES=:080650:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=SanDisk
ID_VENDOR_ENC=SanDisk\x20
ID_VENDOR_ID=0781
MAJOR=8
MINOR=1
SEQNUM=1251
SUBSYSTEM=block
TAGS=:systemd:
UDISKS_PARTITION=1
UDISKS_PARTITION_ALIGNMENT_OFFSET=0
UDISKS_PARTITION_FLAGS=boot
UDISKS_PARTITION_NUMBER=1
UDISKS_PARTITION_OFFSET=1048576
UDISKS_PARTITION_SCHEME=mbr
UDISKS_PARTITION_SIZE=62173216768
UDISKS_PARTITION_SLAVE=/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/block/sda
UDISKS_PARTITION_TYPE=0x07
UDISKS_PRESENTATION_NOPOLICY=0
USEC_INITIALIZED=4468662
dir_name=test
mount_options=relatime

UDEV  [18118.238332] change   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/block/sda/sda1 (block)
ACTION=change
DEVLINKS=/dev/disk/by-id/usb-SanDisk_Ultra_Fit_4C530001090220116482-0:0-part1 /dev/disk/by-label/test /dev/disk/by-path/platform-3f980000.usb-usb-0:1.5:1.0-scsi-0:0:0:0-part1 /dev/disk/by-uuid/8831-F631
DEVNAME=/dev/sda1
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/block/sda/sda1
DEVTYPE=partition
ID_BUS=usb
ID_FS_LABEL=test
ID_FS_LABEL_ENC=test
ID_FS_TYPE=exfat
ID_FS_USAGE=filesystem
ID_FS_UUID=8831-F631
ID_FS_UUID_ENC=8831-F631
ID_FS_VERSION=1.0
ID_INSTANCE=0:0
ID_MODEL=Ultra_Fit
ID_MODEL_ENC=Ultra\x20Fit\x20\x20\x20\x20\x20\x20\x20
ID_MODEL_ID=5583
ID_PART_ENTRY_DISK=8:0
ID_PART_ENTRY_FLAGS=0x80
ID_PART_ENTRY_NUMBER=1
ID_PART_ENTRY_OFFSET=2048
ID_PART_ENTRY_SCHEME=dos
ID_PART_ENTRY_SIZE=121432064
ID_PART_ENTRY_TYPE=0x7
ID_PART_ENTRY_UUID=00003adc-01
ID_PATH=platform-3f980000.usb-usb-0:1.5:1.0-scsi-0:0:0:0
ID_PATH_TAG=platform-3f980000_usb-usb-0_1_5_1_0-scsi-0_0_0_0
ID_REVISION=1.00
ID_SERIAL=SanDisk_Ultra_Fit_4C530001090220116482-0:0
ID_SERIAL_SHORT=4C530001090220116482
ID_TYPE=disk
ID_USB_DRIVER=usb-storage
ID_USB_INTERFACES=:080650:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=SanDisk
ID_VENDOR_ENC=SanDisk\x20
ID_VENDOR_ID=0781
MAJOR=8
MINOR=1
SEQNUM=1253
SUBSYSTEM=block
TAGS=:systemd:
UDISKS_PARTITION=1
UDISKS_PARTITION_ALIGNMENT_OFFSET=0
UDISKS_PARTITION_FLAGS=boot
UDISKS_PARTITION_NUMBER=1
UDISKS_PARTITION_OFFSET=1048576
UDISKS_PARTITION_SCHEME=mbr
UDISKS_PARTITION_SIZE=62173216768
UDISKS_PARTITION_SLAVE=/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/host8/target8:0:0/8:0:0:0/block/sda
UDISKS_PARTITION_TYPE=0x07
UDISKS_PRESENTATION_NOPOLICY=0
USEC_INITIALIZED=4468662
dir_name=test
This is when I plug the flashdrive in. The ACTION=change part happens about 4-5 seconds later which is when the flashdrive becomes unusable. Any ideas why this would happen?

mocart
Posts: 3
Joined: Thu Nov 12, 2015 1:17 am

Re: Auto Mount USB drive When it is plugged in.

Thu Jan 28, 2016 12:35 pm

Hi, I have same problem, I use automount control by udev and mount/umount bash scripts, it was work at wheezy, but after I change to Jessie it not works. After insert USB storage it mount, but after some seconds I see at syslog umount message, without any messages

Eastonboy99
Posts: 6
Joined: Sat Jan 16, 2016 11:04 pm

Re: Auto Mount USB drive When it is plugged in.

Thu Jan 28, 2016 1:10 pm

Hi. Sorry for not replying sooner but I solved the automounting. I followed this tutorial http://jmeosbn.github.io/blog/minimal-r ... usb-drives. If you just do the automounting USB drives then it should work. Make sure you use the supervisor method to autostart. If you have issues with ntfs, follow this tutorial http://myanwyn.blogspot.com/2014/09/how ... l.html?m=1, and make sure you add the automount_options part.
Last edited by Eastonboy99 on Thu Jan 28, 2016 2:02 pm, edited 1 time in total.

mocart
Posts: 3
Joined: Thu Nov 12, 2015 1:17 am

Re: Auto Mount USB drive When it is plugged in.

Thu Jan 28, 2016 1:19 pm

Hi, this tutorial is good, but in this method I can't use Ntfs-3G mount options, like "big_writes", I asked about it at the comments of this tutorial...

Eastonboy99
Posts: 6
Joined: Sat Jan 16, 2016 11:04 pm

Re: Auto Mount USB drive When it is plugged in.

Thu Jan 28, 2016 2:04 pm

So you can't add

Code: Select all

automount_options = { sync, noatime, "dmask=0000", "fmask=0000” }
to your /etc/udisk-glue.conf file underneath the automount = true section?

bobbydriver
Posts: 70
Joined: Thu Oct 18, 2012 9:06 am

Re: Auto Mount USB drive When it is plugged in.

Tue Mar 22, 2016 4:40 pm

If it helps anyone, I found the simplest solution to this was to add these lines to my /etc/rc.local
sleep 5
umount /dev/sda1
sleep 20
sudo mount -a
Absolutely no idea why Jessie is refusing to just mount the fstab properly, but this effectively just recreates the manual fix which is to umount the USB drive and then mount it again - but as a startup action

Return to “Raspbian”