Guide from
Automatically mounting remote shares in GNOME
Moving between many devices and having to find and open remote shares in GNOME is annoying. Using built-in GNOME tools like gio, it’s possible to automatically mount network shares when you log in without wrangling with Samba or fstab. It works for many protocols, including smb, webdav, and ftp.
Requirements
This guide works with the GNOME Shell, and tested on GNOME 43 on Fedora 37. If glib2 is installed, gio is available, and your desktop environment supports XDG, everything should work. Before continuing, make sure that the credentials for the network share are saved on the GNOME Keyring.
Getting Started
To mount the remote location on login, create a desktop entry in the autostart directory. The autostart directory is usually ~/.config/autostart. If that folder doesn’t exist, create it. Give your desktop file a unique filename, like mount-example-share.desktop. The content should look like the example below, with $SHARE_URL_HERE replaced with the URL to the share.
[Desktop Entry]
Version=1.5
Name=Mount Example Share
TryExec=gio
Exec=gio mount $SHARE_URL_HERE
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true
On the next login, the remote share should be available in the Files app. To add more shares, create more desktop files in the autostart directory.
Limitations
If there’s no internet when logging in, the drives won’t automatically mount if the internet comes back. If the machine is consistently connected to the internet, this usually isn’t a problem, but it’s important for laptops that move around frequently.
Troubleshooting
Check these common issues, in order of likelihood. If one step doesn’t correct the problem, move on to the next. Remember to restart the GNOME session by logging in and out to test if it worked.
- Ensure the computer is connected to the internet.
- Credentials must be in the keyring. Mount manually using the Files app. If it prompts you for a login, save the login. That should put it on the keyring.
- Open up a terminal and run gio. If that command is not there then glib2 is missing.
- Check the URL of the server. Running gio mount $SHARE_URL_HERE should mount the share if it’s valid.
- Not all systems use the default autostart directory. Running systemd-path user-configuration or echo $XDG_CONFIG_HOME should print where the XDG configuration folder is. If it does, move the autostart folder there. If it doesn’t, your system might not support XDG Autostart. See this ArchWiki article for more.
Acknowledgements
Special thanks to Sebastian Keller on the GNOME Matrix for pointing this method out to me. Somehow, this flew under my radar. Most results from searching online turn up complicated instructions for Samba. But, GNOME doesn’t need Samba to connect to remote servers, it uses Gvfs instead.