You are not logged in.

#1 2008-09-27 06:09:49

gmhafiz
Member
From: Sydney
Registered: 2008-07-19
Posts: 27
Website

automount external usb hard drive of ntfs partition

I followed the wiki at http://wiki.archlinux.org/index.php/Udev

I created a new file /etc/udev/rules.d/10-usb-automount.rules and pasted this

KERNEL=="sd[a-z]", NAME="%k", SYMLINK+="usbhd-%k", GROUP="users", OPTIONS="last_rule" 
ACTION=="add", KERNEL=="sd[a-z][0-9]", SYMLINK+="usbhd-%k", GROUP="users", NAME="%k" 
ACTION=="add", KERNEL=="sd[a-z][0-9]", RUN+="/bin/mkdir -p /media/usbhd-%k" 
ACTION=="add", KERNEL=="sd[a-z][0-9]", RUN+="/bin/ln -s /media/usbhd-%k /mnt/usbhd-%k" 
ACTION=="add", KERNEL=="sd[a-z][0-9]", PROGRAM=="/lib/udev/vol_id -t %N", RESULT=="vfat", RUN+="/bin/mount -t vfat -o rw,noauto,flush,quiet,nodev,nosuid,noexec,noatime,dmask=000,fmask=111 /dev/%k /media/usbhd-%k", OPTIONS="last_rule" 
ACTION=="add", KERNEL=="sd[a-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,sync,dirsync,noexec,nodev,noatime /dev/%k /media/usbhd-%k", OPTIONS="last_rule" 
ACTION=="remove", KERNEL=="sd[a-z][0-9]", RUN+="/bin/rm -f /mnt/usbhd-%k" 
ACTION=="remove", KERNEL=="sd[a-z][0-9]", RUN+="/bin/umount -l /media/usbhd-%k" 
ACTION=="remove", KERNEL=="sd[a-z][0-9]", RUN+="/bin/rmdir /media/usbhd-%k", OPTIONS="last_rule"

since I want to mount an ntfs partition, I replace vfat with ntfs-3g and changed

ACTION=="remove", KERNEL=="sd[a-z][0-9]", RUN+="/bin/rm -f /mnt/usbhd-%k"

to

ACTION=="remove", KERNEL=="sd[a-z][0-9]", RUN+="/bin/rm -f /media/usbhd-%k"

I also changed sd[a-z] to sd[d-z] as I already have another SATA hard disk ntfs partition automounted at boot.

I restarted the computer but the external hard disk still mount mount automatically. I had to manually mount it using root to do it.

here is my /etc/rc.conf daemons

DAEMONS=(syslog-ng @network !netfs !crond @alsa @hal @fam @kdm @httpd
@mysqld)

and

$ groups
disk dbus hal network video audio optical storage camera users vboxusers

Offline

#2 2008-10-19 11:38:23

lamnk
Member
Registered: 2008-01-30
Posts: 65
Website

Re: automount external usb hard drive of ntfs partition

Bump ... Same question here, usb sticks are automounted, but the NTFS external drive is not.

Here is my udev rule:

KERNEL=="sd[b-z]", NAME="%k", SYMLINK+="usb-%k", GROUP="users", OPTIONS="last_rule" 
ACTION=="add", KERNEL=="sd[b-z][0-9]", SYMLINK+="usb-%k", GROUP="users", NAME="%k" 
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mkdir -p /media/usb-%k" 
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/ln -s /media/usb-%k /mnt/usb-%k" 
ACTION=="add", KERNEL=="sd[b-z][0-9]", PROGRAM=="/lib/udev/vol_id -t %N", RESULT=="vfat", RUN+="/bin/mount -t vfat -o rw,noauto,flush,quiet,nodev,nosuid,noexec,noatime,dmask=000,fmask=111 /dev/%k /media/usb-%k", OPTIONS="last_rule" 
ACTION=="add", KERNEL=="sd[b-z][0-9]", PROGRAM=="/lib/udev/vol_id -t %N", RESULT=="ntfs", RUN+="/bin/mount -t ntfs-3g -o users,noauto,uid=1000,gid=100,fmask=0113,dmask=0002 /dev/%k /media/usbhd-%k", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,sync,dirsync,noexec,nodev,noatime /dev/%k /media/usb-%k", OPTIONS="last_rule" 
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rm -f /mnt/usb-%k" 
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/umount -l /media/usb-%k" 
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /media/usb-%k", OPTIONS="last_rule"

When i mount the drive manually with the ntfs-3g command above everything is ok

Offline

#3 2008-10-20 22:21:06

lamnk
Member
Registered: 2008-01-30
Posts: 65
Website

Re: automount external usb hard drive of ntfs partition

Anyone has an idea ??

Offline

#4 2008-10-21 12:44:51

gmhafiz
Member
From: Sydney
Registered: 2008-07-19
Posts: 27
Website

Re: automount external usb hard drive of ntfs partition

I had to mount vfat partitions manually if I use the udev trick from the wiki. But vfat partitions are mounted automatically if no udev trick is used.

Only ntfs partitions do not mount automatically now.

Offline

Board footer

Powered by FluxBB