You are not logged in.

#1 2018-08-10 09:17:16

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Suppress mount messages

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

#2 2018-08-10 09:28:56

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,743

Re: Suppress mount messages

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

#3 2018-08-10 09:45:52

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: Suppress mount messages

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

#4 2018-08-10 13:01:20

seth
Member
Registered: 2012-09-03
Posts: 51,299

Re: Suppress mount messages

What does your systemd service look like and are you dead sure the default gateway is the proper IP?

Offline

#5 2018-08-10 13:27:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,534
Website

Re: Suppress mount messages

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.

As requested above, show the actual systemd service.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2018-08-10 14:04:32

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: Suppress mount messages

seth wrote:

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.

Trilby wrote:
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

#7 2018-08-10 14:12:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,534
Website

Re: Suppress mount messages

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

#8 2018-08-10 14:46:34

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: Suppress mount messages

Trilby wrote:

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
Trilby wrote:

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

Trilby wrote:

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

#9 2018-08-10 14:56:17

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,534
Website

Re: Suppress mount messages

Kirill Bugaev wrote:

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

#10 2018-08-10 15:09:22

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: Suppress mount messages

Trilby wrote:

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

#11 2018-08-10 15:25:25

seth
Member
Registered: 2012-09-03
Posts: 51,299

Re: Suppress mount messages

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

#12 2018-08-10 15:35:36

loqs
Member
Registered: 2014-03-06
Posts: 17,377

Re: Suppress mount messages

@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

#13 2018-08-10 15:46:48

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: Suppress mount messages

seth wrote:

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

#14 2018-08-10 18:20:48

seth
Member
Registered: 2012-09-03
Posts: 51,299

Re: Suppress mount messages

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

#15 2018-08-11 06:20:16

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: Suppress mount messages

seth wrote:

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.

seth wrote:

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

#16 2018-08-14 21:11:06

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: Suppress mount messages

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

#17 2018-08-14 22:30:45

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,534
Website

Re: Suppress mount messages

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

#18 2018-08-14 22:50:53

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: Suppress mount messages

Trilby, I understand now. Thanks.

Offline

Board footer

Powered by FluxBB