Automount Any External Flash Drive/SD Card

Questions about hardware,drivers and peripherals
Forum rules
Before you post please read this

Automount Any External Flash Drive/SD Card

Postby pnbalaji on Wed Jan 02, 2013 11:35 am

Hi,

I installed linux mint XFCE recently and it is working great, except that automount doesn't seem to work as expected. I always keep a copy of partedmagic in my DVD drive to backup my partitions using clonezilla whenever required.

When I used the liveCD, the internal NTFS partitions, the attached USB flash drive and the DVD drive were mounted automatically. However, after installing Linux Mint into my laptop, the automount doesn't seem to work as expected.

I did use PYSDM to mount the internal windows partitions at boot and this is working fine. I want to be able to automount any USB flash drive/SD card/camera/ipod etc with out touching /etc/fstab since I have several USB flash drives and I don't to add each device in the /etc/fstab. Also, I don't want to manually create any folders under /media. I did try udev option and it worked with partial success. Upon inserting the USB flash drive, it mounted on /media/sdb1, but it did not show up in Thunar. When I added /dev/sdb1 to the favourites, I am able to browse, but I was not able to unmount it from Thunar. The "Eject' icon is not showing in Thunar. I had to go to command line and issue a "sudo umount /dev/sdb1", which I don't want to do.

Can some one tell me a reliable way of automounting any externally connected devices with out editing /etc/fstab? My windows partition is showing up in Thunar as "210GB Volume" and I prefer this kind of mount. It does show the Eject Icon at the side as shown in the attachment.

Thanks,
Balaji.
Attachments
thunar_mount.png
thunar_mount.png (14.93 KiB) Viewed 2400 times
pnbalaji
Level 1
Level 1
 
Posts: 3
Joined: Tue Oct 13, 2009 10:01 am

Linux Mint is funded by ads and donations.
 

Re: Automount Any External Flash Drive/SD Card

Postby rhuddle2000 on Wed Jan 02, 2013 4:06 pm

I have exactly the same problem after upgrading to Mint 14, cinnamon. All usb drives and the sd card reader will not automount even though they are recognized by file manager.Error: "unable to mount. Adding read ACL for uid 1000 to `/media/richard' failed: Operation not supported" . I am a longtime linux user but certainly not an expert.
rhuddle2000
Level 1
Level 1
 
Posts: 3
Joined: Fri Jan 02, 2009 11:39 pm

Re: Automount Any External Flash Drive/SD Card

Postby pnbalaji on Wed Jan 02, 2013 4:15 pm

Hi Rhuddle,

Yours seem to be a different issue.

I did some research and got some success. This is what I did.

1. Created a file called 10-my-media-automount.rules under the directory /etc/udev/rules.d with the following contents.
# vim:enc=utf-8:nu:ai:si:et:ts=4:sw=4:ft=udevrules:
#
# /etc/udev/rules.d/10-my-media-automount.rules

# start at sdb to ignore the system hard drive
KERNEL!="sd[b-z]*", GOTO="my_media_automount_end"
ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="my_media_automount_end"

# import some useful filesystem info as variables
IMPORT{program}="/sbin/blkid -o udev -p %N"

# get the label if present, otherwise assign one based on device/partition
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"

# create the dir in /media and symlink it to /mnt
ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'"

# global mount options
ACTION=="add", ENV{mount_options}="relatime"
# filesystem-specific mount options (777/666 dir/file perms for ntfs/vfat)
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},gid=100,dmask=000,fmask=111,utf8"

# automount ntfs filesystems using ntfs-3g driver
ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/mount -t ntfs-3g -o %E{mount_options} /dev/%k '/media/%E{dir_name}'"
# automount all other filesystems
ACTION=="add", ENV{ID_FS_TYPE}!="ntfs", RUN+="/bin/mount -t auto -o %E{mount_options} /dev/%k '/media/%E{dir_name}'"

# clean up after device removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l '/media/%E{dir_name}'", RUN+="/bin/rmdir '/media/%E{dir_name}'"

# exit
LABEL="my_media_automount_end"
2. Reloaded the UDEV rules with the command "sudo udevadm control --reload-rules"

Now, the USB drives are automatically mounted as I want, but I see a problem with unmounting it from Thunar. Whenever I click the Eject icon, I get the message "there is data that needs to be written to the device. ..before it can be removed. Please do not remove the media or disconnect the drive" and I get a prompt to enter the root password to unmount.
This seems to be an issue with XFCE. I tried to create a group called mountain and added myself to the group and entered this group in the /etc/sudoers file to run mount and umount commands with out asking for root password. It still doesn't seem to work.

Thanks,
Balaji.
pnbalaji
Level 1
Level 1
 
Posts: 3
Joined: Tue Oct 13, 2009 10:01 am

Re: Automount Any External Flash Drive/SD Card

Postby swp2187 on Wed Feb 27, 2013 10:34 pm

Balaji, would your rules work on hard drives installed in a computer also? I'm running Mint/Cinnamon from a thumb drive and I'm getting the same error as Rhuddle when I try to access the computer's hard drives in Nemo. (Unable to mount #### Volume / Adding read ACL for uid 999 to '/media/mint' failed: Operation not supported) I must confess that it's been many years since I've run Unix (not since I was running Solaris 7 when it was released) and I'm extremely rusty. So I simply copied and pasted exactly as you said, named the file, opened Nemo as root, moved it to the rules.d directory and then reloaded the rules and I'm still receiving the same error.

I tried Mint/KDE also running from a thumb drive and I had no trouble there, but I kind of like Cinnamon.

Thank you in advance for your help.

swp

Host: mint Kernel: 3.5.0-17-generic x86_64 (64 bit, gcc: 4.7.2) Desktop: Gnome (Cinnamon) Distro: Linux Mint 14 Nadia
swp2187
Level 1
Level 1
 
Posts: 1
Joined: Wed Feb 27, 2013 10:05 pm

Re: Automount Any External Flash Drive/SD Card

Postby pnbalaji on Thu Feb 28, 2013 10:47 am

Hi,

I am not sure whether your issue is similar to the one I had. After loading the UDEV rules, my external disks were mounted properly. The only issue I had was unmounting them. I finally found that it was an issue with Thunar file manager and changed my default file manager to pcmanfm and everything works as expected. Regarding your other question, you do not need any rules to mount the internal drives. They should be mounted automatically when the OS comes up.

You could try pysdm or gnome-volume-manager or mount-manager and see if those helps.

Thanks,
Balaji.
pnbalaji
Level 1
Level 1
 
Posts: 3
Joined: Tue Oct 13, 2009 10:01 am


Return to Hardware Support

Who is online

Users browsing this forum: No registered users and 21 guests