anticapitalista
Posts: 5,955
Site Admin
Joined: 11 Sep 2007
#1
In my quest to find a replacement for halevt to auto-mount usb devices in rox, I have found a way to do it.

This works on my box, it should work on yours. Make sure you have pmount installed.

If you use thunar or pcmanfm, do not use this method, or edit it accordingly.

Thanks to arch wiki for information.

Code: Select all

KERNEL!="sd*[1-9]*", GOTO="exit"

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

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

# Global mount options
SUBSYSTEMS=="usb", ACTION=="add", ENV{pmount_options}="--noatime"

# File system specific mount options to avoid auto probing
SUBSYSTEMS=="usb", ACTION=="add", ENV{ID_FS_TYPE}=="ntfs|vfat", ENV{pmount_options}="%E{pmount_options} --umask 007 --charset utf8"
SUBSYSTEMS=="usb", ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", ENV{pmount_options}="%E{pmount_options} -t ntfs-3g"
SUBSYSTEMS=="usb", ACTION=="add", ENV{ID_FS_TYPE}=="vfat", ENV{pmount_options}="%E{pmount_options} -t vfat"
SUBSYSTEMS=="usb", ACTION=="add", ENV{ID_FS_TYPE}=="ext2", ENV{pmount_options}="%E{pmount_options} -t ext2"
SUBSYSTEMS=="usb", ACTION=="add", ENV{ID_FS_TYPE}=="ext3", ENV{pmount_options}="%E{pmount_options} -t ext3"
SUBSYSTEMS=="usb", ACTION=="add", ENV{ID_FS_TYPE}=="ext4", ENV{pmount_options}="%E{pmount_options} -t ext4"

# Mount the device
SUBSYSTEMS=="usb", ACTION=="add", RUN+="/bin/su antiX -c '/usr/bin/pmount $env{pmount_options} /dev/%k /media/%E{dir_name}'"

# Clean up after removal
SUBSYSTEMS=="usb", ACTION=="remove", ENV{dir_name}!="", RUN+="/usr/bin/pumount /dev/%k"

# Exit
LABEL="exit"
You need to make one change to the above. Change /bin/su antiX -c to your username. eg /bin/su kostas -c

Copy/paste into a file, save as 99-usbstorage.rules and put in /etc/udev/rules.d

Next time you plug in a usb device it should auto-mount in rox/media. To unmount, right-click on folder and choose Unmount.
Make sure rox uses pmount/pumount rather than mount/umount. (Options-Action window in rox via right click.)

If you get an error when trying to open the folder, right-click on folder, Properties, and click entries for Group and World.

If you have a testing version of antiX-M11-base, remove usbmount.

I have also changed mountbox in antiXcc to mount usb devices as user.
Posts: 1,062
Dave
Joined: 20 Jan 2010
#2
Hello anti, have just tried the above and found to work great with rox. However, when using pcmanfm or thunar it will not unmount with default. There is a work around for thunar, adding a custom command to use pumount EX:"pumount %f". I think this is a great find anti, works great.
anticapitalista
Posts: 5,955
Site Admin
Joined: 11 Sep 2007
#3
I have found another one.


========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://igurublog.wordpress.com/downloads/script-devmon/"
linktext was:"http://igurublog.wordpress.com/downloads/script-devmon/"
====================================


This can be set to auto-open rox once a device is plugged in.
Posts: 1,062
Dave
Joined: 20 Jan 2010
#4
anti, I have noticed that with thunars volume management you can automount usb devices by adding thunar --daemon & to startup. I works well for me, and no conflicts with rox. It is also configurable via edit --> prefferances --> advanced, to open a file manager or to just simply mount.

information found here

========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://crunchbanglinux.org/forums/topic/3622/automount-of-external-usb-drives/"
linktext was:"http://crunchbanglinux.org/forums/topic ... sb-drives/"
====================================


P.S. looking at the other script as well, but I think thunar will complain because it is mounted via the command line
anticapitalista
Posts: 5,955
Site Admin
Joined: 11 Sep 2007
#5
Dave, I'll edit my first post to make it clear that the tip is for those not using thunar nor pcmanfm. It is for rox.
Posts: 609
dark-D
Joined: 02 Jun 2008
#6
good find anti. it works for me, i tested it on three usb sticks 2 with one partition on them and one with two partitions.
Posts: 18
pbachert
Joined: 04 Aug 2009
#7
Anti,

no offense to you, I am sticking happily to antiX though I have recently bought a current laptop.

However, I think it is quite a mediocre impression Linux gives in this respect. What is so hard just to recognize a usb-drive and to show it properly in the file manager? I am using pcmanfm and I find it quite difficult to mount an sd-card let alone automount it when plugged in. I am no expert and I feel I have to become root just to access the files on the card in the /media folder.

Cheers and thanks for the good work,
pbachert
Posts: 1,081
OU812
Joined: 29 Sep 2007
#8
Nice tip. I tried using pcmanfm in ctkarch, but it crashed quite a bit (this is on my desktop). So I installed rox and followed the same arch wiki to get things working. The only difference is that I only have udev and pmount installed.

john
Posts: 4,164
rokytnji
Joined: 20 Feb 2009
#9
Worked for me in latest install of AntiX 11 base. Only using rox-file for file manager. No thunar or pcmanfm for this install.

Believe it or not. I got it to mount a XD flash card using a Vivitar 50 in 1 pendrive adapter. The file structure is raw. But I was able to pull the pictures off of it in /media. It is a 1 gig camera XD flash drive.

Too Cool. __{{emoticon}}__
Posts: 4,164
rokytnji
Joined: 20 Feb 2009
#10
you can automount usb devices by adding thunar --daemon & to startup
Which startup file Dave?

~/.xinitrc
~/.fluxbox/startup
~/.icewm/startup
/usr/local/bin/add-start

Where did you put it and how in a file, (location_beginning_end_middle), for us inept users who want to know (like yours truly __{{emoticon}}__ ).

From your favorite pest. __{{emoticon}}__
Posts: 1,062
Dave
Joined: 20 Jan 2010
#11
Just caught this before I went to my cave for the night __{{emoticon}}__

You can use add-start to add it to startup, all you would need to do is select the WM you are using and then where it autofills"roxterm" just type thunar --daemon and press ok.

If you would like to do what add-start does, just add thunar --daemon & close to the beginning of ~/.fluxbox/startup or ~/.icewm/startup, but after the #!/bin/bash line
Posts: 4,164
rokytnji
Joined: 20 Feb 2009
#12
Thanks Bro.

Edit: thunar --daemon & was already present on ~/.icewm/startup and ~/.fluxbox/startup.

~/.icewm/startup below

Code: Select all

# Auto-mount usb devices in rox /media. Do not use with /etc/udev/rules.d/99-usbstorage.rules
# Do not use if you use Thunar or pcmanfm file managers.
#sleep 5 && devmon --exec-on-drive"rox /media" &
thunar --daemon &

## Set wallpaper via nitrogen
#rm $HOME/.config/nitrogen/bg-saved.cfg
#ln -s $HOME/.config/nitrogen/bg-saved-icewm.cfg $HOME/.config/nitrogen/bg-saved.cfg 
#nitrogen --restore &

sleep 5 && volumeicon &
~/.fluxbox/startup below

Code: Select all


# Auto-mount usb devices in rox /media. Do not use with /etc/udev/rules.d/99-usbstorage.rules
# Do not use if you use Thunar or pcmanfm file managers.
#sleep 5 && devmon --exec-on-drive"rox /media" &

volumeicon &
thunar --daemon &

# And last but not least we start fluxbox.
Must be suffering from Old Timers Disease as I don't remember adding it on this AntiX 11 Full Iso Install on this IBM A22M I have.

Code: Select all

$ inxi -F
System:    Host: Biker Kernel: 2.6.36-1-mepis-smp i686 (32 bit) 
           Desktop IceWM 1.3.7 Distro: antiX-M11-686 Jayaben Desai 01 May 2011
Machine:   Mobo: IBM model: 2628TWU Bios: IBM version: KXET33WW (1.06 ) date: 09/05/2001
CPU:       Single core Pentium III (Coppermine) (-UP-) cache: 256 KB flags: (sse) clocked at 1000.00 MHz 
Graphics:  Card: ATI Rage Mobility P/M AGP 2x 
           X.Org: 1.10.2.902 drivers: ati,mach64 (unloaded: fbdev,vesa) Resolution: 1024x768@87.0hz 
           GLX Renderer: Rasterizer GLX Version: 2.1 Mesa 7.10.3
Audio:     Card: Cirrus Logic CS 4614/22/24/30 [CrystalClear SoundFusion Audio Accelerator] driver: Sound Fusion CS46xx
           Sound: Advanced Linux Sound Architecture ver: 1.0.23
Network:   Card-1: 3Com 3c556B CardBus [Tornado] driver: 3c59x 
           IF: eth0 state: down speed: 10 Mbps duplex: half mac: 
           Card-2: Ralink RT2561/RT61 802.11g PCI driver: rt61pci 
           IF: wlan0 state: up mac:
Drives:    HDD Total Size: 20.0GB (21.9% used) 1: /dev/sda IC25N020ATCS04 20.0GB 
Partition: ID: / size: 6.3G used: 3.0G (49%) fs: ext4 ID: /home size: 12G used: 1.2G (11%) fs: ext4 
           ID: swap-1 size: 0.76GB used: 0.00GB (0%) fs: swap 
Sensors:   System Temperatures: cpu: 59.0C mobo: 47.0C 
           Fan Speeds (in rpm): cpu: 0 
Info:      Processes: 106 Uptime: 2:11 Memory: 280.8/501.2MB Client: Shell inxi: 1.7.20-2 
I only mention this as I inserted a USB drive tonight and it showed up in thunars side pane file tree but gave me a permission denied in thunar. I ended up using Slitaz Mountbox to get to it in /media in rox. Of course anything I put on USB was as root user using Mountbox.
Posts: 1,062
Dave
Joined: 20 Jan 2010
#13
If you have 99-usbstorage.rules enabled on your machine, it will cause that error. Other than that I am not sure. I have seen the same error countless times with pcmanfm, I have yet to see it with thunar ( aside from when I had 99-usbstorage.rules enabled __{{emoticon}}__ )
Posts: 4,164
rokytnji
Joined: 20 Feb 2009
#14
If you have 99-usbstorage.rules enabled on your machine
As usual. You hit the crux of the biscuit. I did have a 99-usbstorage.rules enabled in /etc/udev/rules.d/ .

My bad as usual. __{{emoticon}}__ I thought it could co-exist. Sometimes my tinkering is done in ignorance.

Funny thing was. When I checked it out again after I had made the file and read your post. It renamed itself to 99-usbstorage.rules.unused

I have deleted it since then. Haven't tested yet. Thanks for the heads up.
anticapitalista
Posts: 5,955
Site Admin
Joined: 11 Sep 2007
#15
roky, in the first post in this thread I did write 'If you use thunar or pcmanfm, do not use this method, or edit it accordingly.' __{{emoticon}}__