3v-Hosting Blog

Manually remount fstab without rebooting the Linux server

Administration

7 min read


The /etc/fstab file is a text-based configuration file on Linux-like operating systems that defines what file systems you have and how they are mounted during the operating system boot process. Typically, changes made to fstab are applied during the OS reboot, but often rebooting a Linux server is not desirable, especially if it is a production server of some application that cannot simply be rebooted. In this case, it is possible to apply the changes made to the fstab file without rebooting and without interrupting the operation of your server. In this short guide we will tell you how to do this.

 

 


Why and when you might need to change fstab

 

So in some cases it may be useful to remount fstab manually using the mount command:

    Testing Mount Options: After modifying fstab with new mount options, remounting allows you to test their functionality without rebooting.
    Mounting a Previously Unmounted Filesystem: If you need to mount a filesystem that wasn't mounted during boot, remounting fstab facilitates its inclusion.
    Fixing Mounting Errors: In rare instances, fstab configurations can lead to mounting errors. Remounting specific filesystems can help isolate and address these errors without a full reboot.

 

Important Note! While remount fstab offers convenience, it's crucial to exercise caution when modifying fstab and remounting filesystems. Improper configurations can lead to system instability.

 

 


'mount' command syntax

 

Now that you understand the reasons for manually remounting fstab, let's dive into the practicalities. And at the very beginning, before mounting or remounting anything, we need to find out what the state of affairs is now, which file systems are already mounted. So the first thing we need to do is define the file systems. Before attempting to mount again, determine the specific file system you want to configure. Use the df command to list mounted file systems and their corresponding mount points.


    user@server$ df -H
    File system Size Used Access Used % Mounted in
    tmpfs 1.3G 2.2M 1.3G 1% /run
    /dev/sda3 251G 186G 53G 78% /
    tmpfs 6.3G 105M 6.2G 2% /dev/shm
    tmpfs 5.3M 4.1k 5.3M 1% /run/lock
    tmpfs 6.3G 0 6.3G 0% /run/qemu
    /dev/sda2 537M 6.4M 531M 2% /boot/efi
    tmpfs 1.3G 148k 1.3G 1% /run/user/1000

 

When we have figured out the state of affairs in the system, we can proceed directly to mounting or remounting the file system we need. The mount command is your primary tool for remounting file systems. Its syntax is very simple:


    user@server$ mount -o remount,new_options /dev/device_name /mount_point


Replace /dev/device_name with the actual device name of the filesystem (e.g., /dev/sda1).
Replace /mount_point with the mount point of the filesystem (e.g., /home).
Replace new_options with the desired new mount options (e.g., noatime).

 


Example: remounting /dev/sda1 (mounted on /home) with the noatime option, which disables file access time recording:

 

    user@server$ mount -o remount,noatime /dev/sda1 /home


After executing the mount command, use the df command or df -H again to check if the file system was remounted with the new settings.

 

 


Additional Methods

 

Occasionally there are situations when it is necessary to remount all file systems listed in fstab. To do this, you can use the mount command with the -a parameter (short for 'all'). However, be careful with this command, as it may inadvertently remount file systems that you do not intend to change.

 

    user@server$ mount -a


In case you need to remount the filesystem read-only (for example, for maintenance purposes), use the -o ro option with the mount command:

    user@server$ mount -o ro remount,noatime /dev/sda1 /home


Above we gave only a couple of examples of using the mount command, but in fact the scope of its application is much wider, with many parameters that allow you to more accurately define tasks and solve them effectively. So if you decide to read the full description of all the parameters of the mount command, feel free to refer to the official manual.

 

 

Conclusion

By understanding the concept of fstab remount, the commands provided, and their associated usage scenarios, you have gained valuable proficiency in one of the most important Linux administration tools. This knowledge will allow you to make fstab changes effective without resorting to reboots, increasing the efficiency and flexibility of managing your Linux systems. Remember that responsible fstab editing and careful remount techniques are necessary to maintain system stability.