Mounting Linux volumes with systemd vs fstab

fstab file viewed in VIMIf you have ever done anything more than just an out of the box linux installation you have more than likely worked with fstab to get your volumes to mount. The screenshot to the left shows and example of an fstab file. In this example we are going to look at /dev/sda6 which is mounted to /apps using the XFS file partition and using the defaults. In the sample fstab file you will also notice other volumes mounted using UUID and also the volume label. The UUID you can get by running blkid at the command prompt. Both the UUID and label methods are best as things can change in the system that would change the /dev/sda6 name at which point you’ll have issues with your mounts.

I know that Red Hat is going to be using the systemd method of mounting in future versions of Red Hat, so it would be good to understand this way of doing it. In all it is not that much more difficult to setup as before, however the mounts will all be controlled via the systemd process and you can use commands such as systemctl status, start, enable, and disable on your individual mounts.

The first step is to get a sample .mount file that you can edit for your purposes. These files are located on your system at /lib/systemd/system. When you are in this path you can do a ls *mount to get a listing of all the various .mount files available. A good one to choose is the tmp.mount file. We need to copy this file to /etc/systemd/system/.

You want to pick a name that will be descriptive of what you are mounting. In this example we are mounting an apps volume, so that is why I chose the apps.mount filename.

We can then use vim to edit the file and change it to meet our requirements. We can remove any Systemd configuration fileinformation related to the tmp.mount file, and add the proper information to have our apps volume mount. In the screenshot to the right you see an example of what the file should look like. Under the [Mount] section we can enter the following:

  • what=UUID=”277927f6-a97a-4580-b409-eb9b6cb09fca”
  • where=/apps
  • type=xfs
  • options=defaults

As you can see the format is similar to what you have done in the fstab before. Once you have this done you can save your file, and then it all comes down to standard systemctl commands. Instead of all being on one line you enter them on four separate lines. Also the use of UUID=”277927f6-a97a-4580-b409-eb9b6cb09fca” instead of /dev/sda6 is preferred to prevent issues if the device names change due to a file system reconfiguration later on. Remember, you can see what the UUID of any device is by running the blkid command.


Systemctl status apps.mountDon’t forget to add the .mount at the end, as if you forget systemctl will think you are talking about a service and the command will fail. Also be sure as with fstab and any other manual mounting method you have the mount point created, in our chase /apps.

At this point the volume will mount each time the system starts via systemd. You’ll be able to remove this entry from your fstab file.

I hope you found this article informative. If you have any questions, feel free to reach out to me.


Ivan Windon – RHCSA

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.