How to make system wait for network during boot?

I'm trying to setup auto mounting network shares on boot.

I remember having a similar issue before when the system tried to mount the shares before it connected to the network.

How can I make the os wait for the network during boot?

You can use the x-systemd.automount or x-systemd.device-timeout options. Take a look at this thread for some details:

I only ask because of the x's in the Names: does it only work on Xorg? Or on Wayland, too?

It will work on both. The x- prefix is a standard specified in the manual for fstab and is used to write comments that are ignored by the program reading from this file and handling the mounting (like the mount command). This makes it ideal to expand the properties commonly available, which is exactly what systemd does in this case.

In non-system distributions, those options would be completely ignored and have no effect whatsoever. But systemd has taken an existing standard and extended it without breaking nor disrupting the underlying system. As it should be, of course, but we must give credit where credit is due.

1 Like

That thread just confuses me. I'm like do that to what, where, how??? That post is talking about local drives, not network connections

I'm looking for something like this on Raspbian.

How to wait for networking on login after reboot?

The problem is very similar in nature: a drive mount not being available due to external circumstances. In this case, the circumstance is simply network availability.

You add these options to the /etc/fstab entry for your network share. I see from your linked post that you already tried to use a the x-systemd.device-timeout option, but you might want to try x-systemd.automount, instead. This will basically avoid mounting it until it's explicitly accessed. Depending on your use case (I would say for most normal use cases) this will be long after network is available.

Updated from your other post:

[UUID=07ed2f0d-250d-4915-b4ac-2d5b8309e305 /mnt/grab btrfs defaults,rw,nofail,x-systemd.automount 0 0](//192.168.77.104/Shared\040Media)
1 Like

I did? Because I don't even know how.

Here is my current Fstab. Lines #13 and #14 are the ones I added.

Line #15 must have been added automatically when I added a 2GB HDD to the system and formated it as a linux drive because I had never seen that line until just now.

I've been reading elswhere and just as you say, the "x-systemd.automount" seems perfect for what I want to do. How do I do that?

Note: I read about it here but my head started hurting before I could make sense of all of it.
Mount file system Linux systemd's way | TechTarget

1 # /etc/fstab: static file system information.
2 #
3 # Use 'blkid' to print the universally unique identifier for a
4 # device; this may be used with UUID= as a more robust way to name devices
5 # that works even if disks are added and removed. See fstab(5).
6 #
7 # <file system> <mount point>   <type>  <options>       <dump>  <pass>
8 # / was on /dev/sda2 during installation
9 UUID=7e781b6e-de2e-45d4-96ca-74061209be9e /               ext4    errors=remount-ro 0       1
10 # /boot/efi was on /dev/sda1 during installation
11 UUID=A415-20C6  /boot/efi       vfat    umask=0077      0       1
12 /swapfile                                 none            swap    sw              0       0
13 # Mount Shared Media
14 //192.168.77.104/Shared\040Media /mnt/Media cifs credential=/root/.smbcredentials_auto,uid=1000,gid=1000 0 0
15 /dev/disk/by-uuid/d8e5dd52-ea9a-46da-85ba-2b981945bb1d /mnt/d8e5dd52-ea9a-46da-85ba-2b981945bb1d auto nosuid,nodev,nofail,x-gvfs-show 0 0

You need to edit /etc/fstab and find the entry that matches your network share, which looks like it would be on line # 14. Around the end of the line there are a few options separated by commas i.e.:

credential=/root/.smbcredentials_auto,uid=1000,gid=1000

Append any new options at the end, also separated by a comma:

credential=/root/.smbcredentials_auto,uid=1000,gid=1000,x-systemd.automount

Note that you need admin privileges to edit the /etc/fstab file:

If you prefer, you can also do this from the command line, for example:

sudo nano /ets/fstab

To save changes made with nano Save with Ctrl+O and exit with Ctrl+X. But it doesn't matter which method you use, just mentioning this for completeness.

Honestly, this is the new syntax that also makes my head hurt... I know that everything in a single line gets all cramped and cryptic, but it's much easier to follow (in my opinion). If this doesn't work, we can take a look at this later.

The very first line of the article reads as follows.

" Forget about /etc/fstab and autofs. There's a new Linux system around. Systemd manages mounting and automounting of file systems differently."

So why am I still adding lines to fstab?

Note: I already know how to use nano in the terminal.

Now, I did get it to work though it does load a little slowly.

I've added /mnt/Media to favorites and when I click on it it does automount the windows share.

Then I created a shortcut to the folder on the desktop, clicking it mounts and opens the folder.

I organized a little and simplified the line to mount the share.

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=7e781b6e-de2e-45d4-96ca-74061209be9e /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=A415-20C6  /boot/efi       vfat    umask=0077      0       1
/swapfile                                 none            swap    sw              0       0
# Mount HDD
/dev/disk/by-uuid/d8e5dd52-ea9a-46da-85ba-2b981945bb1d /mnt/d8e5dd52-ea9a-46da-85ba-2b981945bb1d auto nosuid,nodev,nofail,x-gvfs-show 0 0
#Mount Shared Media
//192.168.77.104/Shared\040Media /mnt/Media cifs username=Name,password=pass,x-systemd.automount 0 0

The article is correct in that systemd handles all the actual mounting of drives, with its own syntax and file structure. However, systemd still supports using the /etc/fstab file to describe mount points to preserve backwards compatibility. It will read and convert it at boot, and at the end of the day it doesn't matter which one you use.

However, even the systemd.mount manual says that the /etc/fstab should be preferred when configuring mount points manually:

In general, configuring mount points through /etc/fstab is the preferred approach to manage mounts for humans.

It's expected that it takes a little longer to load the first time you access it, as it needs to make a network connection first. But I gather that it's working now?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.