[rpi-mc] automount udev rules, thx to Arch guys
This commit is contained in:
+4
-1
@@ -9,11 +9,14 @@ ENV LC_ALL=en_US.UTF-8
|
||||
RUN rsync -av "rsync://rsync.at.gentoo.org/gentoo-portage/licenses/" "/usr/portage/licenses/" && \
|
||||
ls /usr/portage/licenses -1 | xargs -0 > /etc/entropy/packages/license.accept && \
|
||||
equo up && equo u && \
|
||||
equo i kodi-raspberrypi app-misc/sabayon-auto-updater && \
|
||||
equo i kodi-raspberrypi app-misc/sabayon-auto-updater sys-fs/ntfs3g && \
|
||||
echo -5 | equo conf update && equo cleanup
|
||||
|
||||
RUN systemctl enable kodi-raspberrypi && systemctl enable sabayon-auto-updater.timer
|
||||
ADD ./config.txt /boot/config.txt
|
||||
ADD ./automount-media.rules /etc/udev/rules.d/10-my-media-automount.rules
|
||||
ADD ./automount-sd.rules /etc/udev/rules.d/11-sd-cards-auto-mount.rules
|
||||
|
||||
# Set environment variables.
|
||||
ENV HOME /root
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# Control starts from sdb, ignoring system one
|
||||
KERNEL!="sd[b-z]*", GOTO="my_media_automount_end"
|
||||
ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="my_media_automount_end"
|
||||
|
||||
IMPORT{program}="/sbin/blkid -o udev -p %N"
|
||||
|
||||
# detect label or create one
|
||||
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
|
||||
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
|
||||
|
||||
# make the dirs in /media
|
||||
ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'"
|
||||
|
||||
# mount options
|
||||
ACTION=="add", ENV{mount_options}="relatime"
|
||||
# ntfs vfat specific options
|
||||
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},gid=100,dmask=000,fmask=111,utf8"
|
||||
|
||||
# use ntfs-3g to mount ntfs filesystems
|
||||
ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/mount -t ntfs-3g -o %E{mount_options} /dev/%k '/media/%E{dir_name}'"
|
||||
# automatic mount for others
|
||||
ACTION=="add", ENV{ID_FS_TYPE}!="ntfs", RUN+="/bin/mount -t auto -o %E{mount_options} /dev/%k '/media/%E{dir_name}'"
|
||||
|
||||
# cleanup on remove
|
||||
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"
|
||||
@@ -0,0 +1,11 @@
|
||||
KERNEL!="mmcblk[0-9]p[0-9]", GOTO="sd_cards_auto_mount_end"
|
||||
|
||||
# global options
|
||||
ACTION=="add", ENV{mount_options}="relatime"
|
||||
# fs specific
|
||||
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"
|
||||
Reference in New Issue
Block a user