Linux Mint 20.1, systemd mount fails, mount from command line ok

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
fargodwe
Level 3
Level 3
Posts: 171
Joined: Mon Oct 02, 2017 2:08 am

Linux Mint 20.1, systemd mount fails, mount from command line ok

Post by fargodwe »

A little background:
  • Acer Chromebook with replacement firmware from mrchromebox. The internal emmc is too small so I cleared it and then installed linux Mint to a 128gb MicroSD card. I boot and run Mint on that MicroSD card.
What I'm trying to do:
  • I have a wireless router with a 4tb hard drive plugged in to one of the USB ports on that router. I have some Windows programs running in wine and a Windows laptop that both need to (at separate times of course) a file on that disk. I am able to manually mount that disk from the command line then access it wine:

    Code: Select all

    sudo mount -t cifs -rw  -o vers=1.0,credentials=/home/dave/volume1.smb  //192.168.0.1/volume1 /home/dave/shares/volume1
  • I want to have this share automatically mounted at boot so I created the following /etc/systemd/system/home-shares-dave-volume1.mount:

    Code: Select all

    [Unit]
    [Unit]
    Description=cifs mount @ /home/dave/shares/volume1
    Before=remote-fs.target
    BindsTo=network.target
    After=network.target
    
    [Mount]
    What=//192.168.0.1/volume1
    Where=/home/dave/shares/volume1
    TimeoutSec=15s
    Type=cifs
    Options=UID=dave,vers=1.0,user=xxxxx,password=xxxxx
    
    [Install]
      WantedBy=multi-user.target
The problem:
  • The mount fails at boot:

    Code: Select all

    ● home-dave-shares-volume1.mount - cifs mount @ /home/dave/shares/volume1
         Loaded: loaded (/etc/systemd/system/home-dave-shares-volume1.mount; enabled; vendor preset: enabled)
         Active: failed (Result: exit-code) since Sat 2021-03-06 00:51:21 CST; 21s ago
    TriggeredBy: ● home-dave-shares-volume1.automount
          Where: /home/dave/shares/volume1
           What: shares@sharesdwe://192.168.0.1/volume1
    
    Mar 06 00:51:21 dave-Aleena systemd[1]: home-dave-shares-volume1.mount: Failed with result 'exit-code'.
    Mar 06 00:51:21 dave-Aleena systemd[1]: Failed to mount cifs mount @ /home/dave/shares/volume1.
    Mar 06 00:51:21 dave-Aleena systemd[1]: Mounting cifs mount @ /home/dave/shares/volume1...
    Mar 06 00:51:21 dave-Aleena mount[1346]: mount.cifs: bad UNC (xxxxxx@xxxxxx://192.168.0.1/volume1)
    Mar 06 00:51:21 dave-Aleena systemd[1]: home-dave-shares-volume1.mount: Mount process exited, code=exited, status=1/FAILURE
    Mar 06 00:51:21 dave-Aleena systemd[1]: home-dave-shares-volume1.mount: Failed with result 'exit-code'.
    Mar 06 00:51:21 dave-Aleena systemd[1]: Failed to mount cifs mount @ /home/dave/shares/volume1.
    Mar 06 00:51:21 dave-Aleena systemd[1]: home-dave-shares-volume1.mount: Start request repeated too quickly.
    Mar 06 00:51:21 dave-Aleena systemd[1]: home-dave-shares-volume1.mount: Failed with result 'exit-code'.
    Mar 06 00:51:21 dave-Aleena systemd[1]: Failed to mount cifs mount @ /home/dave/shares/volume1.
    This also occurs exactly the same if I remove the .automount file from /etc/systemd/system. The error says bad UNC. I have looked this up online but things don't make much sense. I am unable to find it now, but at one time journalctl -xe returned the following but I can't find it now. Note the

    Code: Select all

    Mar 04 14:36:54 dave-Aleena systemd[1]: home-dave-shares-volume1.mount: Mount process exited, code=exited, status=1/FAILURE
    -- Subject: Unit process exited
    -- Defined-By: systemd
    -- Support: http://www.ubuntu.com/support
    -- 
    -- An n/a= process belonging to unit home-dave-shares-volume1.mount has exited.
    -- 
    -- The process' exit code is 'exited' and its exit status is 1.
    Mar 04 14:36:54 dave-Aleena systemd[1]: home-dave-shares-volume1.mount: Failed with result 'exit-code'.
    -- Subject: Unit failed
    -- Defined-By: systemd
    -- Support: http://www.ubuntu.com/support
    -- 
    -- The unit home-dave-shares-volume1.mount has entered the 'failed' state with result 'exit-code'.
    Mar 04 14:36:54 dave-Aleena systemd[1]: Failed to mount CIFS mount @ /home/dave/shares/volume1.
    -- Subject: A start job for unit home-dave-shares-volume1.mount has failed
    -- Defined-By: systemd
    -- Support: http://www.ubuntu.com/support
    -- 
    -- A start job for unit home-dave-shares-volume1.mount has finished with a failure.
    -- 
    -- The job identifier is 1268 and the job result is failed.
    Mar 04 14:36:54 dave-Aleena polkitd(authority=local)[556]: Unregistered Authentication Agent for unix-process:1670:11093 (system bus name :1.77, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnect>
    ~
    The "polkitd(authority=local)[556]: Unregistered Authentication Agent for unix-process" is rather cryptic and a search on the net did not yield a solution.
I have been through a long discussion on this on the wine linux forum. The experts there got to where they said it makes no sense I can mount it manually but the .mount fails. They suggested I ask on askubuntu. Within a minute of posting I got 2 replies saying they only support Ubuntu so I needed to post elsewhere.

Any insight on this would be GREATLY appreciated. I would appreciate the reasoning for a solution so I can understand more and forward it back to the support at wine forums.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
SMG
Level 25
Level 25
Posts: 31728
Joined: Sun Jul 26, 2020 6:15 pm
Location: USA

Re: Linux Mint 20.1, systemd mount fails, mount from command line ok

Post by SMG »

On this webpage How to Mount Windows Share on Linux using CIFS under the section on Auto Mounting, it indicates "To automatically mount a Windows share when your Linux system starts up, define the mount in the /etc/fstab file."

Maybe the directions there will help you with this situation.
Image
A woman typing on a laptop with LM20.3 Cinnamon.
jontrv
Level 2
Level 2
Posts: 76
Joined: Thu Mar 03, 2016 11:47 am
Location: UK

Re: Linux Mint 20.1, systemd mount fails, mount from command line ok

Post by jontrv »

I could be wrong (again!), but this looks similar to a problem I had mounting my local NAS drive over Wi-Fi on my laptop. The problem turned out to be timing, the automount was being tried before the network was available.
By the time you are logged in the network is fully available so your manual mount works.
My solution (for which I have no guarantee it would also work for you) puts the mount into a script that waits for the (WiFi) network to be online.
Create nasmount.service and put it in /etc/systemd/system/ with protections 664.

Code: Select all

[Unit]
Description=Mount NAS shares after NM actually online
Requires=NetworkManager-wait-online.service
After=NetworkManager-wait-online.service
[Service]
ExecStart=/usr/local/bin/nasmount.sh
[Install]
WantedBy=multi-user.target

Code: Select all

sudo chmod 664 /etc/systemd/system/nasmount.service
then create nasmount.sh and put it in /usr/local/bin/ with protections 744.

Code: Select all

#!/bin/bash
# Automount Sharecentre volumes
x=0
while (( x < 10 )) # on a very fast machine you might need to increase this
do
mynet=$(iwgetid -r)
if [ "$mynet" == "My_WiFi_ssid" ]  #obviously replace with your network name
then
echo "Currently connected to WiFi network AP" $mynet "after " $(( x )) " seconds"
sudo mount -t cifs //My_NAS_box_name.local/volume_1 -o cred=/etc/cifs-cred,dev,noexec,rw,iocharset=utf8,vers=1.0 /media/nas/volume_1
exit
else
sleep 1s
echo "Waiting " $(( x++ )) " seconds for WiFi network name" $mynet
fi
done
echo "Wrong network," $mynet, "NAS devices not available to mount." 
exit
Then do:

Code: Select all

sudo chmod 744 /usr/local/bin/nasmount.sh
sudo systemctl daemon-reload
sudo systemctl enable nasmount.service
and reboot.
To check if it worked, did you get your nas device pre-mounted as you logged in ? and do

Code: Select all

sudo systemctl status nasmount.service
which should show you either success or what caused it to fail.
(kudos to various website authors/contributors whose ideas inspired my efforts)!
nearly forgot, my example assumes your mount point is '/media/nas/volume_1'
please make sure that the mount point folders you use exist and match the path you put in the script.
JT:
Locked

Return to “Software & Applications”