Should I edit /etc/fstab?

Hi! I need to do some edits to fstab to auto mount smb shares from my home server.

Should I edit fstab in /etc/? If so, do edits to /etc/fstab persist between updates? From what I understand /etc/ should be a “normal” directory in atomic land.

I’m not an expert on this but I’ll add my experience in case it helps (and so others can correct me!).

It doesn’t seem that fstab is the right place for network mounts in UBlue, as you run into two issues:

  1. You need to be root to mount the drive.
  2. If you try and set the drive as user-mountable (user option in fstab line), you will get an error from UBlue that it’s not allowed.

So what I’ve been doing is creating systemd user .mount files for the drives I want mounted, and doing it that way.

3 Likes

Yes that’s fine, it is mentioned in this topic under “Alternative Methods (CLI)”.

1 Like

That’s for local drives though. Fstab is fine for those since they’re always connected and you can have them mounted by root on boot.

1 Like

Why would this be different than on a non-atomic OS, where you’d simply use noauto and user ? IDK if it’s perfectly matching the atomic pattern, but it’s probably an intended use. Why else would /etc be a layered thing if not to support and preserve existing configuration habits?

Why would this be different than on a non-atomic OS, where you’d simply use noauto and user ?

I mentioned this in my previous comment; you get an error:

This program is not installed setuid root -  "user" CIFS mounts not supported.

Thanks! I’ll look into this.

Here’s one of my mount unit files:

Hi again! Where do you place these files? I suspect /etc/systemd/system isn’t the right place? Do you use .mount + .automount files? Can you give a more precise example?

Thanks!

They go in ~/.config/systemd/user/.

automount is for when you only want the mount to happen when you open the folder. You can see in my mount file that the trigger is network-online, i.e. it will automatically mount when my laptop has a network connection.

There’s nothing UBlue specific about this - just search on Google to read up on systemd user mounts.

Thanks again @Alan!

I read your message after having done the stuff below. It seems to work after reboot. Do you see any problems with using the dirs I have used if they seem to work now? I’d like to survive a system update. :smiley:

mkdir /var/mnt/serverstorage/

Saved var-mnt-serverstorage.automount in /etc/systemd/system/ with these contents:

[Unit]
Description=Automount serverstorage

[Automount]
Where=/var/mnt/serverstorage

[Install]
WantedBy=multi-user.target

Saved var-mnt-serverstorage.mount in /etc/systemd/system/ with these contents:

[Unit]
Description=serverstorage

[Mount]
What=//192.168.0.30/serverstorage/
Where=/var/mnt/serverstorage
Type=cifs
Options=_netdev,noauto,rw,nofail,credentials=/path/to/smb_credentails
TimeoutSec=30

[Install]
WantedBy=multi-user.target

Lastly: sudo systemctl enable var-mnt-serverstorage.automount

I can’t write to the SMB share after having done what I did in my previous message.

Have tried sudo chown myuser:myuser /var/mnt/serverstorage/

Does not seem to work. It’s still owned by root:

ls -l /var/mnt/
drwxr-xr-x. 2 root root 0 Jun 19 22:53 serverstorage

I’m trying to follow this thread to get my NFS share auto mounted. It doesn’t seem to want to mount. Is your example only for SAMBA shares and won’t work with NFS, or am I missing something.

Below is terminal output when I manually run the symlink

./nas.mount: line 1: [Unit]: command not found
./nas.mount: line 6: [Mount]: command not found
./nas.mount: line 14: [Install]: command not found

Below is my .mount contents, I’ve tried all sorts of things but not having much luck.

[Unit]
Description=NAS
After=network-online.target
Wants=network-online.target

[Mount]
Type=nfs
What=/0.0.0.0:/mnt/storage/share
Where=/var/home/user/usrname/share/
Options=

[Install]
WantedBy=default.target

I’m sure I’m missing something, but I can’t seem to wrap my head around things.

Systemd mount files are not meant to be executed directly. You need to place them in a well-known directory (for example, /etc/systemd/system) and use systemctl enable.

Maybe a guide such as this one would be helpful: Automatic mounts using systemd | Anteru's Blog

Thank you, I’ll go through that.

I have done systemctl enable but nothing seemed to happen after rebooting, the mount point remained empty.

I can mount through the command line, but auto mounting would be nicer.

Thank you again, that blog post was a big help. Following his sample of the .mount file I kept getting a no device error when trying to access. Eventually I corrected a typo in TYPE where I had it as NFS instead of nfs (not sure if that matters) then removed all the options from Options= field and now it works perfectly.

Now to make sure it works after a reboot.

Ok, I’ve done systemctl enable on my .automount unit and am able to systemctl start and see my share. But after rebooting the unit doesn’t auto start. the symlink created when I enabled it is in /etc/systemd/system

Here’s my .mount

[Unit]
Description=NAS mount
After=network-online.target
Wants=network-online.target

[Mount]
What=0.0.0.0:/mnt/storage
Where=/var/home/username/NAS
Type=nfs
Options=auto
#Options=rw,file_mode=0700,dir_mode=0700,uid=1000
DirectoryMode=0700

[Install]
WantedBy=multi-user.target

the What=0.0.0.0:/mnt/storage is that way because if I used What=//0.0.0.0/mnt/storage I would get a

bash: cd: NAS: No such device

when I try to enter the folder.

and my .automount

[Unit]
Description=NAS automount

[Automount]
Where=/var/home/username/NAS

[Install]
WantedBy=multi-user.target

I’m really lost on why the .automount doesn’t seem to work after a reboot.

Hi all, I use a different way of automounting my nas and find that very easy to setup.

I create the target folder in a terminal using: sudo mkdir /mnt/NAS

In /etc/fstab I add the following line:
192.168.x.xxx/:nfs/<Folder> /mnt/NAS nfs x-systemd.automount 0 0

Then, again in the terminal, I use: sudo mount -a
so all entries in the fstab file are mounted and I can start using the mount without the need of a reboot.
At reboot, because fstab is being read, the new mount will be mounted automatically.

That’s all. It works perfectly for quite some years already in different distro’s and version numbers.

I used to use the /etc/fstab to automount my NAS, but with the nature of Bazzite, an update to the main image will eliminate the change and then have to edit again. I might go that way though because what I’ve been trying hasn’t been working.

To add to things, after a reboot I opened a terminal and did the following:

systemctl start var-home-username-NAS.automount

Which then brought up the following error

Failed to start var-home-username-NAS.automount: Unit var-home-username-NAS.automount not found.

I look in /etc/systemd/system and the symlink for var-home-username-NAS.automount is there. But the weird thing is the path it points to is

/var/home/username/.config/systemd/user/./var-home-username-NAS.automount

Could the ./ in the path be causing issues, or why else are things not working?