[Solved]Ubuntu minimal: How to automount USB to /media/uuid?

Moderators: mdrjr, odroid

[Solved]Ubuntu minimal: How to automount USB to /media/uuid?

Unread postby alpe » Tue Nov 21, 2017 5:08 am

Possibly a dumb question... :?
Using the "default" ubuntu, any (including never seen before) usb drives are automatically mounted/unmounted to /media/odroid/(label or uuid).
How can I achieve the same thing on ubuntu minimal?
Thanks. ;)

Edit:
Solution below: viewtopic.php?f=111&t=29087#p207236
Last edited by alpe on Wed Nov 22, 2017 2:44 am, edited 2 times in total.
alpe
 
Posts: 13
Joined: Sat Apr 12, 2014 1:21 pm
Location: Rio de Janeiro, Brazil
languages_spoken: portuguese, english
ODROIDs: C1

Re: Ubuntu minimal: How can I automount USB to /media/uuid?

Unread postby tobetter » Tue Nov 21, 2017 10:50 am

alpe wrote:Possibly a dumb question... :?
Using the "default" ubuntu, any (including never seen before) usb drives are automatically mounted/unmounted to /media/odroid/(label or uuid).
How can I achieve the same thing on ubuntu minimal?
Thanks. ;)

Probably you can use usbmount.
https://help.ubuntu.com/community/Mount ... _Server.29
tobetter
 
Posts: 2085
Joined: Mon Feb 25, 2013 10:55 am
Location: Kitchener, ON, Canada
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Ubuntu minimal: How can I automount USB to /media/uuid?

Unread postby alpe » Tue Nov 21, 2017 12:05 pm

tobetter wrote:Probably you can use usbmount.
https://help.ubuntu.com/community/Mount ... _Server.29


I think it doesn't support something dynamic (as uuid) as mountpoint. Only static things like /media/usb[0-7] (default). :(

Edit: I think it's possible with udev rules, but I know nothing about it.
I'm searching about it. Tried adding KERNEL=="sd??", RUN+="/bin/mkdir /media/$env{ID_FS_UUID}", RUN+="/bin/mount $devpath /media/$env{ID_FS_UUID}" but appears to do nothing.
Last edited by alpe on Thu Nov 23, 2017 1:10 pm, edited 1 time in total.
alpe
 
Posts: 13
Joined: Sat Apr 12, 2014 1:21 pm
Location: Rio de Janeiro, Brazil
languages_spoken: portuguese, english
ODROIDs: C1

Re: Ubuntu minimal: How can I automount USB to /media/uuid?

Unread postby meveric » Tue Nov 21, 2017 4:26 pm

from what I can see the MATE desktop (and gnome) use udisks2 to automount drives. There are a couple tools around this, one even says it's a daemon for automounting USB devices.

I think if you read up on udisks or udisks2 you will find an easy way to do it even under a server environment, although you might still have to setup some udev rules.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.
User avatar
meveric
 
Posts: 7958
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1

Re: Ubuntu minimal: How can I automount USB to /media/uuid?

Unread postby alpe » Wed Nov 22, 2017 1:58 am

meveric wrote:from what I can see the MATE desktop (and gnome) use udisks2 to automount drives. There are a couple tools around this, one even says it's a daemon for automounting USB devices.

I think if you read up on udisks or udisks2 you will find an easy way to do it even under a server environment, although you might still have to setup some udev rules.


Couldn't find how to do it with udisks2.
̶T̶r̶i̶e̶d̶ ̶t̶h̶i̶s̶ ̶u̶d̶e̶v̶ ̶r̶u̶l̶e̶ ̶b̶u̶t̶ ̶w̶i̶t̶h̶ ̶n̶o̶ ̶s̶u̶c̶c̶e̶s̶s̶:̶ Edit: It works, actually.
Code: Select all
/etc/udev/rules.d/99-media-by-label-auto-mount.rules

Code: Select all
KERNEL!="sd*", GOTO="media_by_label_auto_mount_end" 
ENV{ID_TYPE}!="disk", GOTO="media_by_label_auto_mount_end" 
# Import FS infos 
IMPORT{program}="/sbin/blkid -o udev -p %N" 
ENV{ID_FS_TYPE}=="", GOTO="media_by_label_auto_mount_end" 
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="%E{ID_FS_UUID}"
# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
ACTION=="add", ENV{ID_FS_TYPE}=="ext4", ENV{mount_options}="$env{mount_options},journal_checksum,errors=continue"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
# Exit
LABEL="media_by_label_auto_mount_end"
alpe
 
Posts: 13
Joined: Sat Apr 12, 2014 1:21 pm
Location: Rio de Janeiro, Brazil
languages_spoken: portuguese, english
ODROIDs: C1


Return to General Chat

Who is online

Users browsing this forum: Bing [Bot] and 2 guests