Add SD card udev automount rule
authorHugo Villeneuve <hugo@hugovil.com>
Sat, 31 Aug 2013 01:21:57 +0000 (21:21 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Thu, 31 Jul 2014 02:15:24 +0000 (22:15 -0400)
stage2/misc/udev-create-persistent-net.sh [deleted file]
stage2/misc/udev-media-automount.rules [deleted file]
stage2/misc/udev/10-media-automount.rules [new file with mode: 0644]
stage2/misc/udev/11-sd-card-automount.rules [new file with mode: 0644]
stage2/misc/udev/udev-create-persistent-net.sh [new file with mode: 0755]
stage2/pkg/udev

diff --git a/stage2/misc/udev-create-persistent-net.sh b/stage2/misc/udev-create-persistent-net.sh
deleted file mode 100755 (executable)
index d0650b8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#/bin/sh
-
-# Pre-generate the rules to ensure the same names get assigned to the same devices at every boot, including the first:
-
-for NIC in /sys/class/net/* ; do
-    INTERFACE=${NIC##*/} udevadm test --action=add $NIC
-done
diff --git a/stage2/misc/udev-media-automount.rules b/stage2/misc/udev-media-automount.rules
deleted file mode 100644 (file)
index 18c365f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-# 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
-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"
diff --git a/stage2/misc/udev/10-media-automount.rules b/stage2/misc/udev/10-media-automount.rules
new file mode 100644 (file)
index 0000000..18c365f
--- /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
+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"
diff --git a/stage2/misc/udev/11-sd-card-automount.rules b/stage2/misc/udev/11-sd-card-automount.rules
new file mode 100644 (file)
index 0000000..de62336
--- /dev/null
@@ -0,0 +1,28 @@
+
+KERNEL!="mmcblk[0-9]p[0-9]", GOTO="sd_cards_auto_mount_end"
+ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="sd_cards_auto_mount_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}="sd-%k"
+
+# create the dir in /media
+ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'"
+
+# Global mount options
+ACTION=="add", ENV{mount_options}="relatime"
+# Filesystem specific options
+ACTION=="add", IMPORT{program}="/sbin/blkid -o udev -p %N"
+ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
+
+# 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="sd_cards_auto_mount_end"
diff --git a/stage2/misc/udev/udev-create-persistent-net.sh b/stage2/misc/udev/udev-create-persistent-net.sh
new file mode 100755 (executable)
index 0000000..d0650b8
--- /dev/null
@@ -0,0 +1,7 @@
+#/bin/sh
+
+# Pre-generate the rules to ensure the same names get assigned to the same devices at every boot, including the first:
+
+for NIC in /sys/class/net/* ; do
+    INTERFACE=${NIC##*/} udevadm test --action=add $NIC
+done
index 32c0c42..e1a3e24 100644 (file)
@@ -16,8 +16,12 @@ hvconfig_pre()
 
 hvbuild_post()
 {
-    install -v -m755 ${SCRDIR}/misc/udev-create-persistent-net.sh /usr/local/bin
-    install -v -m644 ${SCRDIR}/misc/udev-media-automount.rules /etc/udev/rules.d/10-media-automount.rules
+    install -v -m755 ${SCRDIR}/misc/udev/udev-create-persistent-net.sh \
+        /usr/local/bin
+    install -v -m644 ${SCRDIR}/misc/udev/10-media-automount.rules \
+        /etc/udev/rules.d/
+    install -v -m644 ${SCRDIR}/misc/udev/11-sd-card-automount.rules \
+        /etc/udev/rules.d/
 
     mv /lib/pkgconfig/{gudev-*.pc,libudev.pc} /usr/lib/pkgconfig
     rmdir /lib/pkgconfig