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
#2
Best laid plans!. I missed an edit.

 /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy

in the first section <action id="org.freedesktop.udisks2.filesystem-mount">


Quote:<defaults>
      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>


change to 

Quote:<defaults>
      <allow_any>yes</allow_any>
      <allow_inactive>yes</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>


I did so many tests I forgot about this. If it works without it please tell me. I'm sure it was critical but I'm human and obviously make mistakes
Don't miss the Doughnut by looking through the hole.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error updating arch pohosh shulamy 3 289 08-03-2022, 02:30 AM
Last Post: shulamy
  Curious About Arch Ferriah 1 203 07-24-2022, 04:40 AM
Last Post: Nooblife
  Help to execute script to install arch with FDE user641 5 457 07-03-2022, 09:25 PM
Last Post: RTP
  repository for arch-phosh oihantto64 8 1,843 06-27-2022, 03:00 AM
Last Post: shulamy
  VPN for Arch Linux ARM? tk1107 5 1,818 04-27-2022, 06:23 PM
Last Post: tk1107
  Best Messaging client for pinephone? (arch-phosh) pineuser0 20 7,041 03-23-2022, 07:13 AM
Last Post: saba
  arch-audit oihantto64 0 423 02-03-2022, 01:26 AM
Last Post: oihantto64
  Arch image for Pinephone - where to get it? MikeMan 7 1,576 02-01-2022, 12:35 AM
Last Post: MikeMan
  audio services shut down after short time on arch-phosh pineuser0 3 1,088 01-22-2022, 01:14 PM
Last Post: elagost
  Rootkit detector for Arch Linux on PinePhone tk1107 11 3,060 01-01-2022, 12:04 PM
Last Post: tk1107

Forum Jump:


Users browsing this thread: 1 Guest(s)