I was following this answer. I managed to create the service and the script. But when i start the service it gives error.
A dependency job for myusb.service failed. See 'journalctl -xe' for details.
My script is to mount a directory called pop to /mnt automatically.
#!/bin/bash
/bin/mount /media/raven/BC8B-9F35/pop /mnt
I think the issue is with my script.
this is the result of journalctl -xe
Dec 11 20:47:09 dell systemd[1]: myusb.service: Job myusb.service/start failed with result 'dependency'.
Dec 11 20:47:09 dell sudo[4547]: pam_unix(sudo:session): session closed for user root
raven@dell:/etc/systemd/system$ cat myusb.service
[Unit]
Description=My flashdrive script trigger
Requires=media-raven-BC8B\x2d9F35.mount
After=media-raven-BC8B\x2d9F35.mount
[Service]
ExecStart=/home/raven/script.sh
[Install]
WantedBy=media-raven-BC8B\x2d9F35.mount
Can anybody help ?
Day 2
It worked pretty well but now i'm facing another issue with auto mounting.
I changed my script to mount the entire usb to /mnt
instead of a specific directory as asked yesterday.
And it is mounting the USB to /mnt
without issue.
But the issue is that the system itself mounts the USB to default /media
after that. So when i'm listing the contents in /mnt
i got nothing but /media
is full of my usb contents.
and when i run mount command i get the following output.
/dev/sdb1 on /mnt type vfat (rw,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro)
/dev/sdc1 on /media/raven/BC8B-9F351 type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)
You can see that it mounts my USB as sdc1 in /media
and sdb1 in /mnt
.
Actually i have only one USB or external drive attached to this machine. So it should mount the sdb1.
So i disabled the auto mounting by the following command.
gsettings set org.gnome.desktop.media-handling automount false
But still the same.
Any help ?
WantedBy
versisRequires
orAfter
. Change theWantedBy
to add a second escape,WantedBy=media-raven-BC8B\\x2d9F35.mount
. – J. Starnes Dec 11 '17 at 18:36\\
i don't know why. – Dec 12 '17 at 15:43