Ajout régle udev pour monter automatiquement les disques USB
authorgobo72 <gobo72@364a67c3-989e-7be9-548d-dae8560ea662>
Sat, 14 May 2011 04:14:49 +0000 (04:14 +0000)
committergobo72 <gobo72@364a67c3-989e-7be9-548d-dae8560ea662>
Sat, 14 May 2011 04:14:49 +0000 (04:14 +0000)
stage2/misc/udev-media-automount.rules [new file with mode: 0644]
stage2/pkg/udev

diff --git a/stage2/misc/udev-media-automount.rules b/stage2/misc/udev-media-automount.rules
new file mode 100644 (file)
index 0000000..e1174ad
--- /dev/null
@@ -0,0 +1,29 @@
+# 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"
index fa10b2d..475748e 100644 (file)
@@ -15,4 +15,5 @@ hvconfig_pre()
 hvbuild_post()
 {
     install -m755 ${SCRDIR}/misc/udev-create-persistent-net.sh /usr/local/bin
+    install -m644 ${SCRDIR}/misc/udev-media-automount.rules /etc/udev/rules.d/10-media-automount.rules
 }