You are not logged in.
Pages: 1
I try to mount Samba share on boot with
mount \
-t cifs //$IP/ehdd_part /mnt/smb/ehdd \
-o username=user1,password=psk,iocharset=utf8,uid=user1,gid=users
But share is not always availalble, so mount print:
CIFS VFS: BAD_NETWORK_NAME : \\192.168.2.1\ehdd_part
CIFS VFS: cifs_mount failed w/return code=-2
How can i suppress this message?
I have tried "nofail" option for mount. It doesn't work.
"mount ... 2> /dev/null" doesn't help.
Last edited by Kirill Bugaev (2018-08-10 09:20:37)
Offline
Why are you using a separate distinct mount command instead of a relevant FSTAB entry? Where are you executing that anyway? There are likely better suited options
Offline
I execute it in script on boot using systemd service, because i need to obtain IP address ($IP) of machine with Samba before mount.
IP=$(/sbin/ip route | awk '/default/ { print $3 }')
I don't know how i can obtain IP address of Samba machine using FSTAB.
If i try to mount after boot, i will get the same message.
Last edited by Kirill Bugaev (2018-08-10 10:01:13)
Offline
What does your systemd service look like and are you dead sure the default gateway is the proper IP?
Offline
"mount ... 2> /dev/null" doesn't help.
That would do the job. The only reason it doesn't is because that command wasn't actually entered (in a shell) but was passed to the ExecStart line of a systemd service it would seem.
As requested above, show the actual systemd service.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
What does your systemd service look like and are you dead sure the default gateway is the proper IP?
My mount service:
[Unit]
Description=Mount remote shared directories (Samba)
After=network.target
[Service]
Type=idle
ExecStart=/usr/local/bin/mount_smb
[Install]
WantedBy=multi-user.target
Mount script mount_smb:
#!/bin/bash
# Mount Samba shares.
IP=$(/sbin/ip route | awk '/default/ { print $3 }')
mount \
-t cifs //$IP/data_part /mnt/smb/data \
-o username=user1,password=qemu_samba_psswd_f3js9en7qc,iocharset=utf8,uid=user1,gid=users
mount \
-t cifs //$IP/ehdd_part /mnt/smb/ehdd \
-o username=user1,password=qemu_samba_psswd_f3js9en7qc,iocharset=utf8,uid=user1,gid=users
First share (//$IP/data_part) is always available and mounted correct without messages.
Default gateway is the proper IP, because first share is always mounted.
Kirill Bugaev wrote:"mount ... 2> /dev/null" doesn't help.
That would do the job. The only reason it doesn't is because that command wasn't actually entered (in a shell) but was passed to the ExecStart line of a systemd service it would seem.
No, I used "mount ... 2> /dev/null" in script. It doesn't work.
Last edited by Kirill Bugaev (2018-08-10 14:08:53)
Offline
Post the version of the script with that in it.
Does this script do what you want it to when it gives those errors? I doubt that it could as the message says it failed. Why would you want to run a script and surpress the message saying it failed? Either fix the problem, or just don't run the script if it isn't going to work.
Last edited by Trilby (2018-08-10 14:14:14)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Post the version of the script with that in it.
Sorry, here it is
#!/bin/bash
# For tap networking host mode.
# Mount Samba shares.
IP=$(/sbin/ip route | awk '/default/ { print $3 }')
mount \
-t cifs //$IP/data_part /mnt/smb/data \
-o username=user1,password=qemu_samba_psswd_f3js9en7qc,iocharset=utf8,uid=user1,gid=users \
2> /dev/null
mount \
-t cifs //$IP/ehdd_part /mnt/smb/ehdd \
-o username=user1,password=qemu_samba_psswd_f3js9en7qc,iocharset=utf8,uid=user1,gid=users \
2> /dev/null
Does this script do what you want it to when it gives those errors? I doubt that it could as the message says it failed.
When both shares are available on Samba server, script works fine without error messages. But second share not always available and I don't want to see message about it because
Why would you want to run a script and surpress the message saying it failed?
error message merges with login prompt like this
Arch Linux 4.17.10-1-ARCH (tty1)
myhostname login: [ 15.535479] CIFS VFS: BAD_NETWORK_NAME: \\192.168.2.1\ehdd_part
[ 15.543697] CIFS VFS: cifs_mount failed w/return code = -2
Error message is not a problem, but what should i do to clear login prompt?
Last edited by Kirill Bugaev (2018-08-10 14:55:01)
Offline
I have nothing against the error message, but what should i do to clear login prompt?
Hit Enter. Or just ignore them and type your username/login.
But the above doesn't really add up. Error message from your script should not show on tty1, they should go to the journal if the script was started by a systemd service.
Last edited by Trilby (2018-08-10 14:56:48)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
But the above doesn't really add up. Error message from your script should not show on tty1, they should go to the journal if the script was started by a systemd service.
Ok. Thanks everybody for help. I should read more about systemd messages forwarding.
Offline
About the original error: it would seem the 2nd share is on an external disk and not immediately ready - so the issue is more w/ the server than w/ the client?
Since the IP is the gateway: is this an usb drive attached to a router?
Offline
@Trilby I think the output is not getting to the console via stdout or stderr but using syslog https://git.samba.org/samba.git/?p=cifs … =HEAD#l773
Offline
About the original error: it would seem the 2nd share is on an external disk and not immediately ready - so the issue is more w/ the server than w/ the client?
Since the IP is the gateway: is this an usb drive attached to a router?
This is QEMU vm. I have a host with Samba server, guest QEMU vm with Samba client and use virtual tap device for networking. 1st share is internal hdd partition on host, 2nd is external usb hdd. I enable/disable 2nd share manually in smb.conf on host.
Last edited by Kirill Bugaev (2018-08-10 15:50:24)
Offline
iow, the 2nd share is just really not available?
How about cheking the shares before attempting to mount them?
https://wiki.archlinux.org/index.php/Sa … lic_shares
Offline
iow, the 2nd share is just really not available?
I have important data on 2nd share and switch it off to avoid incidental data corrupt.
How about cheking the shares before attempting to mount them?
https://wiki.archlinux.org/index.php/Sa … lic_shares
Good idea. Thanks.
Last edited by Kirill Bugaev (2018-08-11 06:25:11)
Offline
I doubt that error message listed in first post is message that mount give.
Because Trilby is right and "mount ... 2> /dev/null" would do the job.
Maybe it is kernel or other service message.
Offline
Kirill, see loq's post #12 - it is mount generating the message, just not via stdout or stderr. I suppose yes, mount is not what is sending that message to the terminal, but I don't think one would want to completely change the kernel logging just to silence this message.
Last edited by Trilby (2018-08-14 22:31:40)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Trilby, I understand now. Thanks.
Offline
Pages: 1