[mythtv-users] usb mount

Hika van den Hoven hikavdh at gmail.com
Mon Jan 1 10:08:28 UTC 2024


Hoi james,

Monday, January 1, 2024, 10:27:17 AM, you wrote:

> My main mythtv drive is a usb drive.

> If I put, in fstab

> UUID=6a67da23-0789-42a7-bb24-ab7a1f21008c  /store     ext4 defaults
> 1  2

> boot fails with a 'Enter Root Password ..." message about bad disk.

> if I put

> UUID=6a67da23-0789-42a7-bb24-ab7a1f21008c  /store     ext4 
> defaults,nofail      1  2

> Boot is normal, but the disk is not mounted

> I made a systemctl file

> [seagull] /home/jam [842]% cat /etc/systemd/system/mountStore.service
> [Unit]
> Description=Mount /Store
> After=online.target
> Wants=apache2.service
> Wants=network-online.target

> [Service]
> Type=simple
> ExecStartPre=/bin/sleep 30
> ExecStart=mount /dev/disk/by-label/MYTHTV /store

> [Install]
> WantedBy=multi-user.target

> It mounts correctly, but the service file is a bit inelegant. Using Hot
> Plug (google for a fix) seems wrong too.

> The systemd mount options want a fixed bus id (and the usb port can change).

> The drive is a 4T so the occasional fsck will muck up timing. Any ideas
> please.


> James

How about an udev rule in /etc/udev/rules.d. You can have it point to
a shellscript that does the mounting with root privileges. Also this
way it also mounts on the fly. Put the mountpoint in fstab with the
option noauto, so udev gets the mount options from there but they do
not compete/interfere with each other.

For instance I have this one:
The variable $kernel is the partition name in /dev/ and in this case
it only looks at the first partition.
In the shellscript I get the label with:
PartLabel=`blkid -o value -s LABEL /dev/${kernel}`

/etc/udev/rules.d/81-private-usb.rules

SUBSYSTEM=="block", \
        SUBSYSTEMS=="usb", \
        KERNEL=="sd?1", \
        ACTION=="add", \
        RUN+="/root/mount-usb.sh $kernel"



Also check ownership and rights on the mountpoint without te drive
being mounted.


Tot mails,
  Hika                            mailto:hikavdh at gmail.com

"Zonder hoop kun je niet leven
Zonder leven is er geen hoop
Het eeuwige dilemma
Zeker als je hoop moet vernietigen om te kunnen overleven!"

De lerende Mens



More information about the mythtv-users mailing list