Making automount easier to disable with this new package, udev-automount

This commit is contained in:
Mike Staszel 2011-07-24 13:03:48 -05:00
parent 2929ca8dbf
commit 1b588c30da
3 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1,23 @@
KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
PROGRAM="/bin/grep -q ' %M:%m /[^ ]* /' /proc/self/mountinfo", PROGRAM!="/bin/grep -q ' %M:%m / /media/' /proc/self/mountinfo", GOTO="media_by_label_auto_mount_end"
# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"
# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="hd-%k"
# Global mount options
ACTION=="add", ENV{mount_options}="noatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
# Exit
LABEL="media_by_label_auto_mount_end"

View file

@ -0,0 +1,12 @@
KERNEL!="mmcblk[0-9]p[0-9]", GOTO="sd_cards_auto_mount_end"
PROGRAM="/bin/grep -q ' %M:%m /[^ ]* /' /proc/self/mountinfo", PROGRAM!="/bin/grep -q ' %M:%m / /media/' /proc/self/mountinfo", GOTO="sd_cards_auto_mount_end"
# 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"
ACTION=="add", RUN+="/bin/mkdir -p /media/sd-%k", RUN+="/bin/ln -s /media/sd-%k /mnt/sd-%k", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/sd-%k"
ACTION=="remove", RUN+="/bin/umount -l /media/sd-%k", RUN+="/bin/rmdir /media/sd-%k"
LABEL="sd_cards_auto_mount_end"

30
core/udev-automount/PKGBUILD Executable file
View file

@ -0,0 +1,30 @@
# ALARM Maintainer: Mike Staszel <mikestaszel@plugapps.com>
# This is an ALARM-exclusive package for easy USB/SD drive automounting
plugrel=1
pkgname=udev-automount
pkgver=1.0
pkgrel=1
pkgdesc="Automount rules for udev"
arch=('arm' 'armv7h')
url="http://archlinuxarm.org/"
license=('GPL')
groups=('base')
depends=('udev')
backup=('etc/udev/rules.d/11-media-by-label-auto-mount.rules' 'etc/udev/rules.d/11-sd-cards-auto-mount.rules')
source=(11-media-by-label-auto-mount.rules
11-sd-cards-auto-mount.rules)
md5sums=('155554f488388e3f994ace619ad1e8d4'
'173b71ab6466677c12c99ef37c56a3db')
build() {
# Nothing to see here!
}
package() {
mkdir -p $pkgdir/etc/udev/rules.d
cp $srcdir/11-media-by-label-auto-mount.rules $pkgdir/etc/udev/rules.d/
cp $srcdir/11-sd-cards-auto-mount.rules $pkgdir/etc/udev/rules.d/
}