I'm trying to avoid to mount devices that previously are mounted with fstab. This is what happens now: This is what happens now:
/dev/sda1 on /boot
/dev/sda2 on /
/dev/sda3 on /home
/dev/sda2 on /media/ROOT
/dev/sdc1 on /media/Maximum
/dev/sda3 on /media/HOME
/dev/sda1 on /media/BOOT
As you can see is double-mounted.
This is mi rule:
KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
IMPORT{program}="/sbin/blkid -o udev -p %N"
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="%E{ID_PART_ENTRY_UUID}"
ACTION=="add", ENV{mount_options}="relatime"
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
ACTION=="add", PROGRAM="findmnt -rno SOURCE %N", RESULT!="",GOTO="media_by_label_auto_mount_end"
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
LABEL="media_by_label_auto_mount_end"
I tried to use findmnt
to check if the target exists but doesn't do anything.
Hope to be clear. Thanks.