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.

2 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