Automount USB drives with udev rules using disk label October 18, 2015 11:11PM |
Admin Registered: 13 years ago Posts: 19,092 |
# NOTE:
# 1. use pmount --sync if drive label ends with Sync/SYNC/sync in add action to allow removal without corruption
# 2. avoid mounting EFI partition for a HFS+ drive
# 3. force mount HFS+ partition as read-write
# 4. mount USB hardrive (which is identified as SSCI)
KERNEL!="sd*", GOTO="media_label_end"
ENV{ID_TYPE}!="disk", GOTO="media_label_end"
IMPORT{program}="/sbin/blkid -o udev -p %N", ENV{name}="%E{ID_FS_LABEL}"
ENV{ID_FS_TYPE}=="", GOTO="media_label_end"
ENV{ID_FS_LABEL}!="EFI", GOTO="continue"
ENV{ID_PART_TABLE_TYPE}=="gpt", GOTO="media_label_end"
LABEL="continue"
ENV{name}=="", ENV{name}="%k"
KERNEL=="sd*", SYMLINK+="usb-storage/%E{name}"
ENV{name}=="*SYNC", ENV{mode}="--sync"
ENV{name}=="*Sync", ENV{mode}="--sync"
ENV{name}=="*sync", ENV{mode}="--sync"
ENV{name}!="*SYNC", ENV{mode}=""
ENV{ID_FS_TYPE}=="hfsplus", ENV{mode2}="--read-write"
ENV{ID_FS_TYPE}=="hfsplus", ENV{mode3}="/bin/mount -v -o remount,force,rw /media/%E{name}"
ENV{ID_FS_TYPE}!="hfsplus", ENV{mode3}="/usr/bin/pmount"
ACTION=="add", RUN+="/usr/bin/pmount -t %E{ID_FS_TYPE} %E{mode} %E{mode2} --noatime --umask 000 %k %E{name}"
ACTION=="add", RUN+="%E{mode3}"
ACTION=="remove", RUN+="/usr/bin/pumount --yes-I-really-want-lazy-unmount %E{name}"
LABEL="media_label_end"
#!/bin/bash logger -s -i "Pmounting all unmounted USB drives" PMOUNT=`which pmount` if [ -z "$PMOUNT" ] then logger -s -i "Error: $0 cant find pmount!" 1>&2 exit 1 fi ROOT="/dev/usb-storage" DEV_LIST=`ls -1 $ROOT` logger -s -i "Mounting all unmounted USB disks: $DEV_LIST (skip rootfs)" for DEV in $DEV_LIST; do if [ "$DEV" != "rootfs" ]; then if ! /bin/mountpoint /media/$DEV -q ; then $PMOUNT --noatime --umask 000 --read-write $ROOT/$DEV $DEV fi fi done logger -s -i "Done Pmounting USB drives" exit 0
Re: Automount USB drives with udev rules using disk label October 28, 2015 06:03AM |
Registered: 9 years ago Posts: 5 |
Re: Automount USB drives with udev rules using disk label October 28, 2015 12:16PM |
Admin Registered: 13 years ago Posts: 19,092 |
Thang
Re: Automount USB drives with udev rules using disk label December 19, 2015 02:37PM |
Thang
Re: Automount USB drives with udev rules using disk label December 19, 2015 02:38PM |
Re: Automount USB drives with udev rules using disk label December 19, 2015 03:05PM |
Admin Registered: 13 years ago Posts: 19,092 |
Thang
Re: Automount USB drives with udev rules using disk label December 19, 2015 03:22PM |
Re: Automount USB drives with udev rules using disk label December 19, 2015 03:39PM |
Admin Registered: 13 years ago Posts: 19,092 |
# Unknown net device (/devices/platform/40400000.ethernet/net/eth0) (stmmaceth) ###SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:25:31:xx:xx:xx", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # PCI device 0x1814:/sys/devices/platform/47c00000.pcie-controller/pci0000:00/0000:00:00.0 (rt2800pci) ###SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="48:5d:60:xx:xx:xx", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"
Thang
Re: Automount USB drives with udev rules using disk label December 19, 2015 04:21PM |
Thang
Re: Automount USB drives with udev rules using disk label December 19, 2015 04:46PM |
Re: Automount USB drives with udev rules using disk label December 19, 2015 05:29PM |
Admin Registered: 13 years ago Posts: 19,092 |
Thang
Re: Automount USB drives with udev rules using disk label December 20, 2015 01:02AM |
Re: Automount USB drives with udev rules using disk label June 05, 2016 01:32PM |
Registered: 9 years ago Posts: 73 |
root@debian:/media# mount /media mount: can't find /media in /etc/fstab
root@debian:/media# mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=30447,mode=755) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000) tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=25092k,mode=755) /dev/sda1 on / type ext2 (rw,noatime,errors=remount-ro,user_xattr,acl) tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k) tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=50160k) tmpfs on /tmp type tmpfs (rw,relatime) rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
root@debian:/media# mount /dev/sda1 mount: /dev/sda1 is already mounted or / busy /dev/sda1 is already mounted on /
Re: Automount USB drives with udev rules using disk label June 05, 2016 04:09PM |
Admin Registered: 13 years ago Posts: 19,092 |
Quote
~# apt-cache show usbmount
Package: usbmount
Version: 0.0.22
Installed-Size: 116
Maintainer: Rogério Brito <rbrito@ime.usp.br>
Architecture: all
Depends: lockfile-progs, udev, util-linux (>> 2.16)
Recommends: pmount
Description-en: automatically mount and unmount USB mass storage devices
This package automatically mounts USB mass storage devices (typically
USB pens) when they are plugged in, and unmounts them when they are
removed. The mountpoints (/media/usb[0-7] by default), filesystem types
to consider, and mount options are configurable. When multiple devices
are plugged in, the first available mountpoint is automatically
selected. If the device provides a model name, a symbolic link
/var/run/usbmount/MODELNAME pointing to the mountpoint is automatically
created.
.
The script that does the mounting is called by the udev daemon.
Therefore, USBmount requires a 2.6 (or newer) Linux kernel.
.
Firewire devices are also supported by USBmount.
.
USBmount is intended as a lightweight solution which is independent of
a desktop environment. Users which would like an icon to appear when an
USB device is plugged in should use the pmount and hal packages
instead.
Description-md5: 665bf065788bff1ada4b796e26321438
Homepage: http://usbmount.alioth.debian.org/
Tag: admin::filesystem, hardware::storage, hardware::usb, interface::daemon,
role::program, scope::utility, use::configuring
Section: admin
Priority: extra
Filename: pool/main/u/usbmount/usbmount_0.0.22_all.deb
Size: 17666
MD5sum: 1d62c98011ac6452d1e9b3be7b56b272
SHA1: 9a4d4d88ac7f609a27db15235bed605f3f6dadc1
SHA256: 764462e65a544fc6a03ca4f90157898a4f289c3f3bea866c5b739ff9184d6c93
Package: usbmount
Status: deinstall ok config-files
Priority: extra
Section: admin
Installed-Size: 112
Maintainer: Rogério Brito <rbrito@ime.usp.br>
Architecture: all
Version: 0.0.21
Config-Version: 0.0.21
Depends: udev, lockfile-progs, util-linux (>> 2.16)
Recommends: pmount
Conffiles:
/etc/usbmount/umount.d/00_remove_model_symlink 06304855418cfe29f6cec46042bdd857
/etc/usbmount/mount.d/00_create_model_symlink 13ef81167c202627ca43b1fe6c7cd0bf
/etc/usbmount/usbmount.conf a78d1be4f28c20bdb0b88b23cc01cf5d
Description-en: automatically mount and unmount USB mass storage devices
This package automatically mounts USB mass storage devices (typically
USB pens) when they are plugged in, and unmounts them when they are
removed. The mountpoints (/media/usb[0-7] by default), filesystem types
to consider, and mount options are configurable. When multiple devices
are plugged in, the first available mountpoint is automatically
selected. If the device provides a model name, a symbolic link
/var/run/usbmount/MODELNAME pointing to the mountpoint is automatically
created.
.
The script that does the mounting is called by the udev daemon.
Therefore, USBmount requires a 2.6 (or newer) Linux kernel.
.
Firewire devices are also supported by USBmount.
.
USBmount is intended as a lightweight solution which is independent of
a desktop environment. Users which would like an icon to appear when an
USB device is plugged in should use the pmount and hal packages
instead.
Description-md5: 665bf065788bff1ada4b796e26321438
Homepage: http://usbmount.alioth.debian.org/
apt-get install usbmount
Re: Automount USB drives with udev rules using disk label June 08, 2016 04:46PM |
Registered: 9 years ago Posts: 73 |
>Quote
> ~# apt-cache show usbmount
> Package: usbmount
> Version: 0.0.22
> Installed-Size: 116
> Maintainer: Rogério Brito <rbrito@ime.usp.br>
> Architecture: all
> Depends: lockfile-progs, udev, util-linux (>>
> 2.16)
> Recommends: pmount
> Description-en: automatically mount and unmount
> USB mass storage devices
> This package automatically mounts USB mass
> storage devices (typically
> USB pens) when they are plugged in, and unmounts
> them when they are
> removed. The mountpoints (/media/usb[0-7] by
> default), filesystem types
> to consider, and mount options are configurable.
> When multiple devices
> are plugged in, the first available mountpoint is
> automatically
> selected. If the device provides a model name, a
> symbolic link
> /var/run/usbmount/MODELNAME pointing to the
> mountpoint is automatically
> created.
> .
> The script that does the mounting is called by
> the udev daemon.
> Therefore, USBmount requires a 2.6 (or newer)
> Linux kernel.
> .
> Firewire devices are also supported by USBmount.
> .
> USBmount is intended as a lightweight solution
> which is independent of
> a desktop environment. Users which would like an
> icon to appear when an
> USB device is plugged in should use the pmount
> and hal packages
> instead.
> Description-md5: 665bf065788bff1ada4b796e26321438
> Homepage: http://usbmount.alioth.debian.org/
> Tag: admin::filesystem, hardware::storage,
> hardware::usb, interface::daemon,
> role::program, scope::utility, use::configuring
> Section: admin
> Priority: extra
> Filename:
> pool/main/u/usbmount/usbmount_0.0.22_all.deb
> Size: 17666
> MD5sum: 1d62c98011ac6452d1e9b3be7b56b272
> SHA1: 9a4d4d88ac7f609a27db15235bed605f3f6dadc1
> SHA256:
> 764462e65a544fc6a03ca4f90157898a4f289c3f3bea866c5b
> 739ff9184d6c93
>
> Package: usbmount
> Status: deinstall ok config-files
> Priority: extra
> Section: admin
> Installed-Size: 112
> Maintainer: Rogério Brito <rbrito@ime.usp.br>
> Architecture: all
> Version: 0.0.21
> Config-Version: 0.0.21
> Depends: udev, lockfile-progs, util-linux (>>
> 2.16)
> Recommends: pmount
> Conffiles:
> /etc/usbmount/umount.d/00_remove_model_symlink
> 06304855418cfe29f6cec46042bdd857
> /etc/usbmount/mount.d/00_create_model_symlink
> 13ef81167c202627ca43b1fe6c7cd0bf
> /etc/usbmount/usbmount.conf
> a78d1be4f28c20bdb0b88b23cc01cf5d
> Description-en: automatically mount and unmount
> USB mass storage devices
> This package automatically mounts USB mass
> storage devices (typically
> USB pens) when they are plugged in, and unmounts
> them when they are
> removed. The mountpoints (/media/usb[0-7] by
> default), filesystem types
> to consider, and mount options are configurable.
> When multiple devices
> are plugged in, the first available mountpoint is
> automatically
> selected. If the device provides a model name, a
> symbolic link
> /var/run/usbmount/MODELNAME pointing to the
> mountpoint is automatically
> created.
> .
> The script that does the mounting is called by
> the udev daemon.
> Therefore, USBmount requires a 2.6 (or newer)
> Linux kernel.
> .
> Firewire devices are also supported by USBmount.
> .
> USBmount is intended as a lightweight solution
> which is independent of
> a desktop environment. Users which would like an
> icon to appear when an
> USB device is plugged in should use the pmount
> and hal packages
> instead.
> Description-md5: 665bf065788bff1ada4b796e26321438
> Homepage:
> http://usbmount.alioth.debian.org/
> apt-get install usbmount >>
Re: Automount USB drives with udev rules using disk label August 31, 2017 10:45PM |
Registered: 7 years ago Posts: 41 |
Re: Automount USB drives with udev rules using disk label September 01, 2017 12:01AM |
Admin Registered: 13 years ago Posts: 19,092 |
Quote
If you are not sure about udev rules, then I'd suggest looking into usbmount, autofs, ... to install one of these Debian packages to handle the automounting.
Re: Automount USB drives with udev rules using disk label September 01, 2017 12:08AM |
Registered: 7 years ago Posts: 41 |
[137246.680981] ntfs: driver 2.1.32 [Flags: R/W MODULE]. [137246.687304] ntfs: (device sdb1): parse_options(): Unrecognized mount option locale
Re: Automount USB drives with udev rules using disk label October 29, 2018 02:33PM |
Registered: 6 years ago Posts: 23 |
> apt-get install usbmount >
Re: Automount USB drives with udev rules using disk label October 29, 2018 04:09PM |
Admin Registered: 13 years ago Posts: 19,092 |
Martin from Dortmund
Re: Automount USB drives with udev rules using disk label October 30, 2018 03:08AM |
Re: Automount USB drives with udev rules using disk label November 01, 2018 02:39AM |
Admin Registered: 13 years ago Posts: 19,092 |
Re: Automount USB drives with udev rules using disk label November 01, 2018 05:07AM |
Registered: 6 years ago Posts: 23 |
Re: Automount USB drives with udev rules using disk label November 01, 2018 06:04AM |
Registered: 6 years ago Posts: 23 |
LABEL=rootfs / ext4 noatime,errors=remount-ro 0 1 tmpfs /tmp tmpfs defaults 0 0 UUID=04aae5de-6bed-4faa-999c-68ba85b591a4 /mnt/data ext2 rw,suid,dev,exec,nouser,async,auto 0 2 UUID=44d90f04-3a0e-4fac-8993-853b3d60afd3 /mnt/unterhaltung ext4 rw,suid,dev,exec,nouser,async,auto 0 2 UUID=e7f3cfb0-6abf-4591-9d18-2ae7bc92be2e /mnt/backup ext4 rw,suid,dev,exec,nouser,async,auto, 0 2
Re: Automount USB drives with udev rules using disk label November 01, 2018 06:06AM |
Admin Registered: 13 years ago Posts: 19,092 |
Re: Automount USB drives with udev rules using disk label November 01, 2018 06:07AM |
Admin Registered: 13 years ago Posts: 19,092 |
Quote
... but the problem remains, trouble, if USB hdd is not found at startup...
Re: Automount USB drives with udev rules using disk label November 01, 2018 06:22AM |
Registered: 6 years ago Posts: 23 |
root@debian:~# mount UUID=04aae5de-6bed-4faa-999c-68ba85b591a4 /mnt/data root@debian:~# mount UUID=44d90f04-3a0e-4fac-8993-853b3d60afd3 /mnt/unterhaltung root@debian:~# mount UUID=e7f3cfb0-6abf-4591-9d18-2ae7bc92be2e /mnt/backup
#!/bin/sh # secure mounting with file system check of mounted partitions fsck UUID=04aae5de-6bed-4faa-999c-68ba85b591a4 if [ $? -eq 0 ] then mount UUID=04aae5de-6bed-4faa-999c-68ba85b591a4 /mnt/data else echo file system check failed, 'mnt/data' not mounted fi fsck UUID=44d90f04-3a0e-4fac-8993-853b3d60afd3 if [ $? -eq 0 ] then mount UUID=44d90f04-3a0e-4fac-8993-853b3d60afd3 /mnt/unterhaltung else echo file system check failed, 'mnt/unterhaltung' not mounted fi fsck UUID=e7f3cfb0-6abf-4591-9d18-2ae7bc92be2e if [ $? -eq 0 ] then mount UUID=e7f3cfb0-6abf-4591-9d18-2ae7bc92be2e /mnt/backup else echo file system check failed, 'mnt/backup' not mounted fi
Re: Automount USB drives with udev rules using disk label November 01, 2018 04:43PM |
Admin Registered: 13 years ago Posts: 19,092 |