LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-17-2012, 08:40 AM   #1
steelneck
Member
 
Registered: Nov 2005
Distribution: Slackware, Arch
Posts: 43

Rep: Reputation: 8
Automount removables


I am in search of a decent way of having removables like usb-sticks, cameras or CD/DVDs to be automounted. I do _not_ want any solution that demands graphical apps. I want something that works on a very basic system without X.

For some years i have used the following udev-rule (in Slack and Arch) that mount USB-storage devices in a folder using the partition label if present. Due to some recent change it got even uglier and nowadays i let rc.local mv it in place so it does not automunt all my HD partitions under /media (i actually deleted, by mistake, most of the root partition of an old backup version of Slack that i had laying around when the change occured), and of course rm it on shutdown.

I feel it all is a bit of an ugly hack and since the future life of udev is unceartain due to the systemd/udev mess, i am looking for a better way. From what i understand udev was not even meant to handle things like this.

Code:
KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"

# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"

# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"

# 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,shortname=lower,gid=100,umask=002"

# 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"
Actually, i have been looking for a good way to automount removables since 2002 when i started using Linux more seriously, back then i just wanted to have things accessible like in old DOS, just pop in a CD or floppy and have a place to CD to. Since then we have got many more things that we plug in and out of our machines, but 10 years later (20 compared to DOS) i still miss something simple on a basic system level that do not require megabytes of graphic related software.

Back in the days there was supermount that looked promising, Mandrake used it back then and i used it in Slackware for some years. But supermount required some attention to every new kernel version and development eventually died. It was probably a bad way of doing it anyway and it would probably not have worked for the gizmos of today.

So, has anyone heard of a better way today?

Last edited by steelneck; 11-17-2012 at 08:44 AM.
 
Old 11-17-2012, 08:49 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Have you looked at e.g. https://wiki.archlinux.org/index.php...disks_wrappers? The first item listed works on command line.

Hope this helps,
 
2 members found this post helpful.
Old 11-17-2012, 09:27 AM   #3
steelneck
Member
 
Registered: Nov 2005
Distribution: Slackware, Arch
Posts: 43

Original Poster
Rep: Reputation: 8
Hmm.. The devmon bash script coming with udevil look promising, i will have a closer look on that. A bash script to accomplish this is KISS enough for me ;-)
 
Old 11-17-2012, 12:57 PM   #4
steelneck
Member
 
Registered: Nov 2005
Distribution: Slackware, Arch
Posts: 43

Original Poster
Rep: Reputation: 8
Udevil/devmon actually seem to do the job quite nice, i wonder how i can have missed it.. I will mess around with it for a while longer, so far i have only tried it on my Arch-box and i will probably not try in Slack until i put together my new box. Many thanks "Snark1994" for pointing me in this direction.
 
Old 11-18-2012, 10:43 AM   #5
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
No problem at all. If you consider the issue resolved to your satisfaction, please mark the thread as 'SOLVED' (there's a link near the top of the page).

Regards,
 
Old 11-19-2012, 07:03 AM   #6
lambo69
Member
 
Registered: Sep 2012
Distribution: Slackware, Manjaro, Slackarm, Raspbian, Debian
Posts: 68

Rep: Reputation: Disabled
Have you tried autofs?

lambo
 
Old 11-20-2012, 01:01 PM   #7
steelneck
Member
 
Registered: Nov 2005
Distribution: Slackware, Arch
Posts: 43

Original Poster
Rep: Reputation: 8
Done some more testing today, though still not in slackware (on this machine i am using now i have Arch), but i think i can call my issue solved.

@lambo69: No i have not and so far udevil seem to do what i want in a way that i can live with.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to Automount ISO image unless automount is running in foreground! swests Linux - General 4 05-22-2009 12:47 AM
CentOS 5.2 Automount isos in fstab \other methods that work?automount iso Frankly3D Linux - General 6 07-13-2008 12:34 PM
IDE & SATA dual boot on removables. w@m Linux - Desktop 4 06-21-2007 10:59 PM
Automount: no more in LE LinxNew Mandriva 2 05-07-2005 09:21 AM
Automount jailbait Linux - Software 2 07-16-2003 04:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration