Welcome! Log In Create A New Profile

Advanced

USB Automount does not work on Boot (Pogoplug Pro)

Posted by schnee 
USB Automount does not work on Boot (Pogoplug Pro)
April 10, 2019 08:36PM
I am trying to figure out what is causing the issue that the attached USB drives are not mounted during boot on my Pogoplug Pro. It worked before the debian 9.8 upgrade with the udev rules I am using from https://forum.doozan.com/read.php?2,24139.

Some system info:
root@sch:/media# cat /etc/debian_version 
9.8
root@sch:/media# uname -r 
4.4.176-oxnas-tld-1
root@sch:/media# cat /etc/udev/rules.d/90-media-by-label-auto-mount.rules 
# 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"

During boot the drive got attached to the system
[    3.543672] sd 1:0:0:0: [sdb] 3907029168 512-byte logical blocks: (2.00 TB/1.82 TiB)
[    3.544506] sd 1:0:0:0: [sdb] Write Protect is off
[    3.544527] sd 1:0:0:0: [sdb] Mode Sense: 28 00 00 00
[    3.545418] sd 1:0:0:0: [sdb] No Caching mode page found
[    3.545431] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[    3.575503]  sdb: sdb1
[    3.582901] sd 1:0:0:0: [sdb] Attached SCSI disk

mount does not show the drive as attached
fsck shows the drive as busy:
root@sch:/media# fsck /dev/sdb1
fsck from util-linux 2.29.2
e2fsck 1.43.4 (31-Jan-2017)
/dev/sdb1 is in use.
e2fsck: Cannot continue, aborting.
root@sch:/media# umount /dev/sdb1
umount: /dev/sdb1: not mounted

/media directory shows the mount points are created by pmount
root@schnas:/media/Data# ls -l
total 8
drwxr-xr-x 2 root root 4096 Nov  3  2016 .
drwxr-xr-x 4 root root 4096 Nov  3  2016 ..
-rw------- 1 root root    0 Nov  3  2016 .created_by_pmount
Note: not sure why the dates are set to 2016, probably during boot gets false datetime value

PS: After creating and runing usb-storage.pmount script (from https://forum.doozan.com/read.php?2,24139) does mount the drives, but want to understand the root problem. Specially because i have the same hardware with the same kernel and Debian version on an other Pogoplug Pro, where mounting works properly

Schnee
Re: USB Automount does not work on Boot (Pogoplug Pro)
April 11, 2019 12:24AM
schnee,

> Specially because i have the same
> hardware with the same kernel and Debian version
> on an other Pogoplug Pro, where mounting works
> properly

Could be 2 USB drives are differrent in formatting? Are they both Ext2/3/4 ? or did you try the same USB drive on both systems?

USB drives are used to not mounted automatically with udev automount rules in previous Debian versions. I could not recall since which version that we don't need the storage.pmount script.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: USB Automount does not work on Boot (Pogoplug Pro)
April 11, 2019 03:09PM
The 2 drives are the same both on how they are attached to the system (sata to USB converter) and on the file system, one has ext4 (works) other has 1 ext4 and 1 ext2 (both are not working).

The difference i found looking in deeper: the working one uses sysV init (-rwxr-xr-x 1 root root 35328 Feb 12 2017 /sbin/init) while the not working one uses systemd (lrwxrwxrwx 1 root root 20 Apr 8 12:51 /sbin/init -> /lib/systemd/systemd)

Could this cause the issue?

Schnee
Re: USB Automount does not work on Boot (Pogoplug Pro)
April 11, 2019 04:32PM
schnee Wrote:
-------------------------------------------------------
> The 2 drives are the same both on how they are
> attached to the system (sata to USB converter) and
> on the file system, one has ext4 (works) other
> has 1 ext4 and 1 ext2 (both are not working).
>
> The difference i found looking in deeper: the
> working one uses sysV init (-rwxr-xr-x 1 root root
> 35328 Feb 12 2017 /sbin/init) while the not
> working one uses systemd (lrwxrwxrwx 1 root root
> 20 Apr 8 12:51 /sbin/init ->
> /lib/systemd/systemd)
>
> Could this cause the issue?

Yes. If you use systemd, the automount is different.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: USB Automount does not work on Boot (Pogoplug Pro)
April 11, 2019 10:12PM
bodhi Wrote:
-------------------------------------------------------
> Yes. If you use systemd, the automount is
> different.

Do you have any documentation how different it is, how to make it work with systemd? Or the only way to make it work again to switch back to sysV init?

I am not a huge fan of systemd, but it seems to be the future....
Re: USB Automount does not work on Boot (Pogoplug Pro)
April 11, 2019 11:54PM
schnee,

I don't have any documentation for that (I don't use systemd on these plugs/NAS that I build kernel and u-boot for).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: USB Automount does not work on Boot (Pogoplug Pro)
April 14, 2019 12:10PM
I looked into the issue and found a few post related to this it on other forums. The root cause is that systemd actually mounts the drives during boot bus private, not visible to other users. To change this behavior an update to the config is needed:

Option 1: create a file /etc/systemd/system/systemd-udevd.service with contents
.include /usr/lib/systemd/system/systemd-udevd.service
[Service]
MountFlags=shared
Option 1create a new directory and file /etc/systemd/system/systemd-udevd.service.d/myoverride.conf with contents
[Service]
MountFlags=shared

I used option 2 and it works perfectly (did not test option 1)

Source: Udev rule to mount disk does not work check accepted answer

Schnee
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: