Say, you want to use a USB storage device with your Linux home server. All you have to do is to run the mount /dev/sdbX /mount/point/
command as root to mount the device (sdbX
, in this case) in the specified mount point. Easy, but hardly practical — because you have to do it every time you reboot the server. One way to solve the problem is to create a systemd service that automatically mounts the device on boot.
To do this, use the lsblk
command to find the name of the storage device. Create then a /etc/systemd/system/mountdev.service file, open it for editing, and specify the following service (replace sdbX
with the actual name of the device and /mount/point/
with the directory where the device should be mounted):
[Unit]
Description=Mount external storage
[Service]
ExecStart=mount /dev/sdbX /mount/point/
[Install]
WantedBy=multi-user.target
Save the file, and run the command below as root to enable the service:
systemctl enable mountdev.service
That's all there is to it. Next time you reboot the server, the storage device will be mounted automatically.