Page 1 of 1

On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Sat Mar 15, 2025 10:56 am
by JusGellin

I was trying to make a laptop automatically mount to my main desktop acting as a samba server on boot up using fstab.

I can manually mount the share to access it so I know that works.
The stanza in the client's fstab is this:
//192.168.70.72/samba_server /mnt/nvme0n1p2/index/samba cifs credentials=/home.smbcredentials 0 0

But it doesn't connect.
If I use mount -a manually, it does connect so there is nothing wrong with the fstab stanza.

I read that "it may not work during boot due to the network stack not being fully operational at the time the /etc/fstab entry is processed"
One suggestion was to add _netdev, but that doesn't work.

Is there a better way to do this to make it work?

My main samba server is PopOs linux.
The laptop client is KLV-vmHost.

Thanks


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Sat Mar 15, 2025 12:10 pm
by Trapster

should

Code: Select all

credentials=/home.smbcredentials

be

Code: Select all

credentials=/home/smbcredentials

Also try:

Code: Select all

//192.168.70.72/samba_server /mnt/nvme0n1p2/index/samba cifs credentials=/home.smbcredentials x-systemd.requires=network-online.target 0 0

Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Sat Mar 15, 2025 12:20 pm
by JusGellin

@Trapster

should

Code: Select all

credentials=/home.smbcredentials

be

Code: Select all

credentials=/home/smbcredentials

I meant for it to be credentials=/home/.smbcredentials which I had.

Thanks


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Sat Mar 15, 2025 12:45 pm
by JusGellin

@Trapster

Also try:
//192.168.70.72/samba_server /mnt/nvme0n1p2/index/samba cifs credentials=/home.smbcredentials x-systemd.requires=network-online.target 0 0

I used this with the hidden file .smbcredentials:
//192.168.70.72/samba_server /mnt/nvme0n1p2/index/samba cifs credentials=/home/.smbcredentials x-systemd.requires=network-online.target 0 0

mount -a gives a parse error when trying this.

I re-verified that without the change doesn't give the parse error:
//192.168.70.72/samba_server /mnt/nvme0n1p2/index/samba cifs credentials=/home/.smbcredentials 0 0

Thanks


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Sat Mar 15, 2025 1:47 pm
by JusGellin

Instead of using fstab, is there a way to either do the mount later in a startup service or to run mount -a later in a startup service?

Thanks


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Sat Mar 15, 2025 2:13 pm
by Trapster

This is what I use:

Code: Select all

mkdir /root/server && sshfs root@192.168.1.101:/mnt/sdb1 /root/server && rox /root/server /

Just unmount and delete /root/server when finished.

I use this for the script for mounting:

Code: Select all

#!/bin/bash

PS3='Choose an option '
dirs=("Music" "Movies" "Photos" "Server" "Root" "Unmount" "Quit")
select fav in "${dirs[@]}"; do
    case $fav in
        "Music")
            mkdir /root/server && sshfs root@192.168.1.101:/mnt/sdb1/mp3 /root/server && rox /root/server/
	    # optionally call a function or run some code here
            ;;
        "Movies")
            mkdir /root/server && sshfs root@192.168.1.101:/mnt/sdb1/movies /root/server && rox /root/server/
	    # optionally call a function or run some code here
            ;;
        "Photos")
            mkdir /root/server && sshfs root@192.168.1.101:/mnt/sdb1/photos /root/server && rox /root/server/
	    # optionally call a function or run some code here
			;;
		"Server")
			mkdir /root/server && sshfs root@192.168.1.101:/mnt/sdb1 /root/server && rox /root/server /
			;;	
		"Root")
			mkdir /root/server && sshfs root@192.168.1.101:/root /root/server && rox /root/server/
			;;
		"Unmount")
			umount /root/server && rm -d /root/server
			break
            ;;
		"Quit")
			umount /root/server && rm -d /root/server
			echo "User requested exit"
	    exit
	    ;;
        *) echo "invalid option $REPLY";;
    esac
done

and I use this to call that script as a shortcut on the desktop

Code: Select all

#!/bin/sh

xterm -hold -e 'bash -c "server-mount; exec bash"' &

Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Sat Mar 15, 2025 11:42 pm
by wizard

@JusGellin

You could use the attached program, mntshare.sh, open in geany, edit the indicated lines and put in the /root/startup directory

wizard


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Sun Mar 16, 2025 1:21 pm
by JusGellin

@Trapster
I liked your example for how you do this.
For me, I wouldn't need to have this connected to the remote server unless I needed it also
So I wouldn't have a need to make it start up automatically using fstab.
Also having a menu like this is just what I need - I just select the one I want when needed.

I've never used sshfs before, so I had a little difficulty making that work initially.
Once I learned that the server needed to have ssh running, I was able to work through your example.
It works really well to get the folders/files from the main desktop computer.
I've modified the menu to suit me.

This seems even simpler than using samba.
But I'm still going to try using what @wizard gave so I can get familiar with that method also.

Thanks


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Sun Mar 16, 2025 4:36 pm
by wizard

@JusGellin

For me, I wouldn't need to have this connected to the remote server unless I needed it also
So I wouldn't have a need to make it start up automatically using fstab.
Also having a menu like this is just what I need

Have 3 samba shares used often, just edited a copy of mntshare.sh and renamed accordingly for each. Then have those in a directory on the desktop named "network". Open directory, click one of the mntshare.sh copies and it is connected. Notice at the bottom of mntshare.sh there is a line you can un-comment that will automatically open the share in rox.

@Trapster code is a lot more sophisticated.

wizard


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Sun Mar 16, 2025 4:54 pm
by wizard

@JusGellin

As an alternate to the last message, mntshare.sh can be used to configure Rox (or any file manager that uses bookmarks) so your network share is available as a bookmark directly in the file manager.

wizard


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Mon Mar 17, 2025 10:20 am
by JusGellin

@Trapster @wizard
Thanks

Using sshfs or samba are incredibly useful and easy - once I do it several times.
I just have to make good notes for doing this. It takes me a lot of time when first figuring out how to do this.
Plus, I don't need to automatically do this on startup since I can select a desktop icon when I need it.
So I don't need to use fstab.

Since both do what I want(share files from my main desktop), are there advantages for using one or the other?

Thanks


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Mon Mar 17, 2025 5:09 pm
by Trapster
wizard wrote: Sat Mar 15, 2025 11:42 pm

@JusGellin

You could use the attached program, mntshare.sh, open in geany, edit the indicated lines and put in the /root/startup directory

wizard

@wizard
Does the server need to be running samba? Your script doesn't work for me.

Code: Select all

/initrd/mnt/dev_save/Downloads$ ./mntshare.sh 
ready
mount-FULL: /mnt/puppyserver: mount(2) system call failed: Connection refused.
/initrd/mnt/dev_save/Downloads$ 

This is with the firewall turned off.


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Mon Mar 17, 2025 5:36 pm
by wizard

@Trapster
@JusGellin

Does the server need to be running samba? Your script doesn't work for me.This is with the firewall turned off.

Yes, see this post for setting up the server: viewtopic.php?p=132971&hilit=file+server#p132971

wizard


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Mon Mar 17, 2025 9:42 pm
by wizard

@JusGellin

Since both do what I want(share files from my main desktop), are there advantages for using one or the other?

Think sshfs is more secure, but samba is easier to set up.

wizard


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Tue Mar 18, 2025 6:30 am
by Clarity

@JusGellin for file exchanges and folder accesses, the simple, cleanest, and a safe & secure approach for systems on your local LAN is SAMBA! It is baked into so much of what has been available in distros since the beginning of this century.

It is found to be baked into MS, MACs, Cell-phone apps, all top 20+ linux distros on distrowatch, etc. And it allows files/folders to be exchange from your VMs with the Host machine.

Do not hesitate its use. Look for the SAMBA Simple Management in ALL WoofCE PUPs. You also see it in KLs. It is designed to be simple clear and straight forward in sharing. Further, it appears to cover all you ask about in your (this) thread.

Any questions you have on its use, merely ask as there are users everywhere on this forum and largely in the Linux community as well outside of the forum who will jump to answer usage as just about everyone understands or have used it.

Hope this is helpful


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Tue Mar 18, 2025 6:45 am
by Clarity

Also, I seem to remember @MochiMoppel shows a fstab entry, but I cannot find it, that will, at boot time, allow a linux PC (aka laptop/desktop/etc) to auto-connect IFF the MS/MAC/SAMBA server is active on the LAN when the Laptop is booted.

But, I think I may have an example on one of my PCs if need.


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Tue Mar 18, 2025 12:36 pm
by JusGellin
Clarity wrote: Tue Mar 18, 2025 6:45 am

Also, I seem to remember @MochiMoppel shows a fstab entry, but I cannot find it, that will, at boot time, allow a linux PC (aka laptop/desktop/etc) to auto-connect IFF the MS/MAC/SAMBA server is active on the LAN when the Laptop is booted.

But, I think I may have an example on one of my PCs if need.

@Clarity
Thanks, I would like to see a fstab entry that works.
My desktop has the samba active, but from what I understand from the internet is that its wifi still wasn't completely up so the samba mount couldn't be accomplished.
Once the laptop is up I can run the same stanza and successfully mount to it.
Maybe fstab has something that could delay the mount a bit to allow the wifi to be fully connected and the mount the client.
It could be that the laptop I'm using is just too fast for the boot up.


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Tue Mar 18, 2025 10:08 pm
by Clarity

@JusGellin, @wizard,@Trapster and other forum users who might find auto-mounting your LAN server's resource at boot-time, a productivity gain.

A forum thread for automounting.

Hope this is helpful


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Wed Mar 19, 2025 12:54 am
by JusGellin
Clarity wrote: Tue Mar 18, 2025 10:08 pm

@JusGellin, @wizard,@Trapster and other forum users who might find auto-mounting your LAN server's resource at boot-time, a productivity gain.

A forum thread for automounting.

Hope this is helpful

Thanks, that really is an excellent document for setting up the samba client.

I've set the fstab like the document before so it confirms I'm doing it correctly
But it still doesn't automatically mount the samba folder from the server just like before.

I still can run mount -a which successfully manually mounts the share.


Re: On Bootup a Laptop Won't Mount a Samba Drive using fstab

Posted: Wed Mar 19, 2025 2:16 am
by Clarity

Hello @JusGellin
So that I am clear (as I may be missing something) ... Are you saying the following after you've created the fstab changes?

  • When you boot the laptop, it does not connect?

  • AND, once booted, you open a terminal to enter mount -a and the mount-point populates?

Curious

BTW - there are 3 logs that I would consider review:

  • On the server, the samba.log

  • On the laptop, dmesg and the syslog

As any activity related to the fstab command should be logged. Let us know.

BTW2 - Could you post your fstab entry? (block the IP address AND the credentials filename OR send to me intact via a PM)