Hello, Linux system administrators and developers! When operating a server, there come times when you need to add a new disk, ensure it connects automatically every time you boot, or protect important data from accidental changes.
Today, we will delve into these two essential scenarios in detail: β Automatic file system mounting at boot and β‘ Protecting data integrity by changing an already mounted file system to read-only.
With just this one post, you’ll gain confidence in file system mount management! πͺ

Part 1. It’s okay to reboot! Auto-mounting file systems with /etc/fstab π
Imagine you’ve added a new backup disk to your server. You connected the disk to the /backups directory using the mount command, but after rebooting the server, the connection is lost! π± You can’t manually mount it every time you boot, can you?
This is where the /etc/fstab file comes in.
What is the fstab file? π€
- fstab = File System Table
- It is a file system list information file that Linux references during boot.
- Devices registered in this file are automatically mounted to their specified locations during the boot process.
Registering directly in the fstab file π
We will automatically mount the /dev/vdb1 device, which uses the xfs file system, to the /backups directory.
Execute the command below in the terminal to add the setting to the very last line of the /etc/fstab file.
echo '/dev/vdb1 /backups xfs defaults 0 0' | sudo tee -a /etc/fstab
Wait! Is this command safe? Yes, it is very safe and a recommended method.
- echo ‘…’: Prints the text inside the quotes.
- | sudo tee -a …: Executes the tee command with administrator privileges (sudo). The -a option means to append content to the end of the file without overwriting it. This is one of the best ways to prevent mistakes when modifying system configuration files!
One added line of configuration, fully dissected!
/dev/vdb1 /backups xfs defaults 0 0 This single line consists of 6 fields.
- Device Name (/dev/vdb1): The name of the partition to be mounted.
- Mount Point (/backups): The directory path where the device will be connected.
- File System Type (xfs): Specifies the type of file system, such as xfs, ext4, ntfs, etc.
- Options (defaults): Options to apply during mounting. ‘defaults’ is a keyword that includes the most common and basic options like rw (read/write), suid, dev, exec, auto, nouser, async.
- Dump Setting (0): Whether to back up with the dump command. 0 means no backup, and nowadays it is almost always set to 0.
- File System Check Order (0): The order of file system checks (fsck) during boot. 0 means no check. The root file system is usually 1, and others are typically 2 or 0.
Testing the settings without rebooting β
You don’t necessarily need to reboot to check if the settings have been added correctly. Try running the command below.
sudo mount -a
The mount -a command is a very convenient command that reads the /etc/fstab file and mounts all items that are not currently mounted. If there are no error messages, the setting has been successfully applied!
Part 2. Data is precious! Remounting as Read-Only π‘οΈ
Now, let’s consider another scenario. A disk containing very important original data (e.g., /dev/vdb2 of ext4 format) is mounted in the /mnt directory. This data must never be modified or deleted.
In such cases, you can prevent data changes by remounting the file system as read-only.
Safely changing with the remount option π
When changing options for an already mounted file system, you don’t need to unmount and then remount it. The remount option solves this very simply.
Enter the command below in the terminal.
sudo mount -o remount,ro /mnt
Command fully dissected!
- sudo mount: Executes the mount command with administrator privileges.
- -o remount,ro: Specifies mount options (-o).
- remount: Reapplies options without unmounting the existing mount.
- ro: Abbreviation for read-only, sets it to read-only.
- /mnt: The target mount point for which options are to be changed.
Verifying if it’s truly applied π
It’s essential to check if the settings have been applied correctly, isn’t it? Let’s check the current mount status with the command below.
mount | grep /mnt
When you run the command, if you see ‘ro’ in the result, it’s a success!
# Example of execution result
/dev/vdb2 on /mnt type ext4 (ro,relatime)
Now, no write operations such as file creation (touch), modification (vi), or deletion (rm) will be possible within the /mnt directory. Your valuable data is now safe!
Wrapping Up β¨
Today, we explored automatic mounting using fstab and read-only settings using remount, which are core techniques in Linux system administration. By effectively utilizing these two techniques, you can significantly enhance server stability and data integrity.
Automation is fundamental to system administration, and data protection is paramount. We encourage you to apply what you’ve learned today to your servers!
Tags: Linux, fstab, mount, remount, filesystem, server management, data protection, xfs, ext4, DevOps, system engineering
Leave a Reply