Score:1

Why ubuntu server does not mount fstab samba share on boot?

ms flag

Ciao,

I've a Raspberry Pi 4 running Ubuntu Server 22.04.2 LTS.

I need to mount a samba share at boot time, and I've followed instructions on this site at sections Mount password protected network folders: MountWindowsSharesPermanently

nano ~/.smbcredentials # there i've added my credentials
chmod 600 ~/.smbcredentials
sudo nano /etc/fstab
sudo mkdir /media/windowsshare

And I've added this line of code:

//{samba-share-ipaddress}/sharename /media/windowsshare cifs credentials=/home/{my-ubuntu-username}/.smbcredentials,iocharset=utf8 0 0 

When I execute the command sudo mount -a, the share is mounted correctly, but if I reboot, the folder is not mounted.

I've tried to add _netdev but without success:

//samba-share-ipaddress/sharename /media/windowsshare cifs credentials=/home/{my-ubuntu-username}/.smbcredentials,iocharset=utf8,_netdev 0 0 

How can I resolve this problem?

Thanks

Pilot6 avatar
cn flag
Did you edit `fstab`, or just ran `sudo nano /etc/fstab`?
ilMattion avatar
ms flag
Hi Pilot6, I've edites the fstab file with the configuration, when I execute sudo mount -a It works
Score:2
es flag

Does it have to be mounted under /media? Can it be mounted under /mnt instead?

The problem is most likely that the network stack on your Linux machine is not fully operational when the line in fstab is executed so at that point there is nothing to mount.

The current way around this is to add 2 more options to your fstab line:

noauto,x-systemd.automount

So your line becomes:

//{samba-share-ipaddress}/sharename /media/windowsshare cifs credentials=/home/{my-ubuntu-username}/.smbcredentials,iocharset=utf8,noauto,x-systemd.automount 0 0 

The only problem is since the mount point is under /media another process ( udisks2 ) tends to interfere with this process and it tries to mount it too early.

You can try it as is with the two additional parameters and if it doesn't work change the mount point to /mnt/windowsshare.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.