An unplugged disk causes a delay in system boot
July 15, 2021
The fstab file contains descriptive information about the file systems that the system can mount. In the /etc/fstab file, you can specify the parameters for mounting a disk, which can be either plugged to the system or unplugged from it. An example of such a disk is an external USB drive. In the latter case, you must additionally specify the nofail option.
An example of such an entry:
UUID=26FC3023FC2FEC2D /mnt/disk_e ntfs nofail,rw,utf8 0 0
Thanks to the nofail option, the system boots normally and shows no errors even if the specified disk is missing.
But starting with systemd 249-3, the system began to try to mount this disk even if it was not connected. As a result, when the computer was turned on, it waited for the timeout of this operation to complete, that is, the boot freeze for 90 seconds (the default timeout).
The following messages appeared in the system log:
HackWare systemd[1]: dev-disk-by\x2duuid-26FC3023FC2FEC2D.device: Job dev-disk-by\x2duuid-26FC3023FC2FEC2D.device/start timed out. HackWare systemd[1]: Timed out waiting for device /dev/disk/by-uuid/26FC3023FC2FEC2D. HackWare systemd[1]: dev-disk-by\x2duuid-26FC3023FC2FEC2D.device: Job dev-disk-by\x2duuid-26FC3023FC2FEC2D.device/start failed with result 'timeout'.
Most likely, this problem is a temporary bug that will be fixed in future versions of systemd. But now you can use the x-systemd.device-timeout mount option so that the computer does not wait a minute and a half.
In the following example, the timeout value is set to 1 second:
UUID=26FC3023FC2FEC2D /mnt/disk_e ntfs nofail,rw,utf8,x-systemd.device-timeout=1 0 0
As a result, the computer began to turn on almost immediately, without delay.
If the specified disk is connected to the computer after turning on, then the disk will be mounted correctly, taking into account the options from the /etc/fstab file. The minimum timeout time is not an obstacle for mounting after turning on the computer.
If the disk is usually unplugged, then the noauto option is more appropriate:
UUID=26FC3023FC2FEC2D /mnt/disk_e ntfs noauto,nofail,rw,utf8 0 0
This option makes it so that the system will not try to mount the disk when you turn on the computer. However, the next time you connect the disk, it will be mounted according to the options in the /etc/fstab file.
Related articles:
- Persistent names for block devices (94.2%)
- How to determine why Linux boots into Emergency mode (86.1%)
- How to repair an LVM disk using fsck (86.1%)
- In-RAM filesystem to speed up file handling and reduce disk load (tmpfs) (80.3%)
- How to move files between iPhone and Linux (how to access iPhone on Linux) (75.6%)
- How to trim a video and how to split a video into multiple files without re-encoding in Linux (RANDOM - 50%)