Arch auto mount usb example
#1
After 2 days of head banging and following the wrong answers on google, I finally got my usb to auto mount as user on the Arch Phosh install.

There is no guaranties this will work as everything in linux is dynamic and what worked one day doesn't the next. 

Here is what I did I create 3 file  

/etc/udev/rules.d/99-usb-mount.rules

Quote:ACTION=="add",KERNEL=="sd[a-z][0-9]*",SUBSYSTEMS=="usb",RUN+="/bin/systemctl start usb-mount@%k.service"

ACTION=="remove",KERNEL=="sd[a-z][0-9]*",SUBSYSTEMS=="usb",RUN+="/bin/systemctl stop usb-mount@%k.service"


/etc/systemd/system/usb-mount@.service
Quote:[Unit]
Description=Mount USB Drive on %i
[Service]
Type=simple
User=alarm
Group=alarm
ExecStart=/home/alarm/bin/mountusb.sh add %i
ExecStop=/home/alarm/bin/mountusb.sh remove %i
RemainAfterExit=true
[Install]
WantedBy=default.target



/home/alarm/bin/mountusb.sh
Quote:#!/bin/bash

ACTION=$1
DEVBASE=$2
DEVICE="/dev/${DEVBASE}"

case "${ACTION}" in
    add)
        /usr/bin/udisksctl mount -b ${DEVICE}
        ;;
    remove)
        /usr/bin/udisksctl unmount -b ${DEVICE}
        ;;
esac



Don't forget to chmod -x mountusb.sh it can be called anything and put anywhere, obvious use your path in the usb-mount@.service file.

I found rebooting the phone more reliable than 

Quote:udevadm control --reload-rules

systemctl daemon-reload



EDIT: Check the Second Post, I forgot the polkit edit. If it works without it great, but I am sure it was critical... (end EDIT)

After just plug in a usb and it should auto mount. 

I did manage to get a sound to play, but that was a whole other story and twice as painful as getting the usb working.

Hope it's useful to someone Big Grin
Don't miss the Doughnut by looking through the hole.
  Reply


Messages In This Thread
Arch auto mount usb example - by Lazy_one - 06-12-2021, 09:30 PM
RE: Arch auto mount usb example - by Lazy_one - 06-13-2021, 05:10 PM
RE: Arch auto mount usb example - by luppivega - 10-06-2023, 09:36 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Updating Arch Linux _radv_ 8 561 02-20-2024, 09:35 AM
Last Post: _radv_
  PinePhone AND/OR PinePhone Pro Arch Complete Install and Setup mikehenson 2 2,051 01-14-2024, 08:43 AM
Last Post: shifras
  How to install arch with FDE user641 3 638 01-11-2024, 10:18 PM
Last Post: Kevin Kofler
  How to find software app, on Arch Phosh? general_lee 5 1,796 10-15-2023, 10:12 PM
Last Post: Kevin Kofler
  Arch with FDE user641 1 838 07-29-2023, 08:27 AM
Last Post: alpineduck
  No keyboard on Arch Plasma when entering password on document Chief 0 798 12-03-2022, 08:35 PM
Last Post: Chief
  Curious About Arch Ferriah 2 2,061 11-07-2022, 04:38 PM
Last Post: Ferriah
  Latest version Arch Plasma looks good. Chief 5 2,310 10-23-2022, 01:53 PM
Last Post: Chief
  Evolution no longer runs on Arch Phosh. Chief 2 1,310 10-17-2022, 07:22 AM
Last Post: Chief
  Reticulum's Nomadnet (mesh net) on Arch ARM PineFone 0 786 10-16-2022, 08:28 AM
Last Post: PineFone

Forum Jump:


Users browsing this thread: 1 Guest(s)