You are not logged in.

#1 2012-05-20 19:52:44

redfire
Member
Registered: 2011-12-21
Posts: 5

Automount removable devices (with a write access)

Hello,

Everytime I install a light GNU/Linux system, I have troubles with the automount of removable devices. So this time I tried to read documentation slowly to understand which software is useful or not (HAL, dbus, udev...) to get a clear idea of what happens. From what I read, udev is one of the main component of this action and writing a rule for it is the solution. I took the rule from the wiki about ntfs-3g and mount for the others under /media.

Just for information I use lightdm (I don't know exactly why there is a connection with this software but I saw some people having trouble because of their logging manager) with xfce4 (I installed thunar, thunar-volman, gvfs...). I see the USB key in the media directory but with root as owner instead of me and read-only access instead of read and write access...

I know many people have already been through this but nothing of what I found about solved my problem...

If someone has an idea :-)

Thank you.

Here, I copy paste some files of my configuration :

#
# /etc/rc.conf - Main Configuration for Arch Linux
#
# See 'man 5 rc.conf' for more details
#

# LOCALIZATION
# ------------
HARDWARECLOCK="UTC"
TIMEZONE="Europe/Paris"
KEYMAP="fr-dvorak-bepo"
CONSOLEFONT=
CONSOLEMAP=
LOCALE="en_US.UTF-8"
DAEMON_LOCALE="yes"
USECOLOR="yes"

# HARDWARE
# --------
MODULES=()
USEDMRAID="no"
USEBTRFS="no"
USELVM="no"

# NETWORKING
# ----------
HOSTNAME=rdesktop

interface=eth0
address=
netmask=
broadcast=
gateway=

NETWORK_PERSIST="no"

# DAEMONS
# -------
#
DAEMONS=(syslog-ng dbus networkmanager crond)
# 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}="rw,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"

--
redfire

Offline

#2 2012-05-20 22:10:04

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,302

Re: Automount removable devices (with a write access)

Some suggestions I can think of:

Is the ntfs-3g package installed?

The udev rules execute the RUN commands as root; so the command for ntfs disk will be:

/bin/mount -t ntfs-3g -o rw,relatime,gid=100,dmask=000,fmask=111,utf8 /dev/devicename /media/dirname

which should result in 'root:users' owner:group (there is a gid value but no uid)
and rwxrwxrwx for directories
and rw-rw-rw- for files

But only the ntfs-3g driver can write to ntfs file system.

So the disk is normally mounted as root with the udev rule you posted, and if it is read only then ntfs-3g is probably not used.

Last edited by berbae (2012-05-20 22:14:22)

Offline

#3 2012-05-21 03:34:28

xangelux
Member
Registered: 2010-05-29
Posts: 73

Re: Automount removable devices (with a write access)

I think you just need fuse and netfs daemons to automount in read-write mode

Offline

#4 2012-05-21 08:17:45

redfire
Member
Registered: 2011-12-21
Posts: 5

Re: Automount removable devices (with a write access)

Thank for your answers.

I made some experiments and it seems that only the removable devices that have been formatted thanks to a dd (to make a bootable usb key) can't be written.

I am going to look for the reason bit if someone knows ;-)

Thank you for your time.

--
redfile

Offline

Board footer

Powered by FluxBB