How to Auto-Mount File Systems on Startup in RedHat Linux
Learn how to configure the fstab file on RedHat Linux to auto-mount file systems at startup. This guide covers identifying file system UUIDs, creating mount points, editing fstab, and mounting file systems, ensuring your drives are accessible automatically on boot for seamless system operation.
Linux systems often require manual configurations, especially for mounting disks. This guide walks you through the process of configuring the fstab file on RedHat servers to auto-mount file systems or drives (e.g., external disks, USBs) at startup.
Understanding the fstab File
The fstab (file system table) is located in the /etc directory on Unix-like systems. It lists available disk partitions and other file systems, specifying how they are integrated into the larger file system structure.
Here’s an example of an fstab file:
#/etc/fstab
# Created by anaconda on Wed Nov 16 18:06:51 2022
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=cee77f86-bf0a-4039-88f4-2c01361a392f /boot xfs defaults 0 0
UUID=6B73-F145 /boot/efi vfat umask=0077,shortname=winnt 0 2
/dev/mapper/rhel-home /home xfs defaults 0 0
/dev/mapper/rhel-swap none swap defaults 0 0
Key components of fstab entries:
- File system identifier: Can be a UUID or a label.
- Mounting point: Directory where the file system will be accessible.
- File system type: Types like
xfs,vfat,swap,ext4, etc. - Mount options: Commonly
defaults(rw, suid, dev, exec, auto, nouser, async). - Dump value: Specifies backup frequency (0 = no backup).
- Pass value: Order for checking file systems at boot (0 = no check, 1 = first, 2 = second).
Adding a New File System to fstab
To auto-mount a new SSD on your server:
- Identify the File System Use the
blkidcommand to get the UUID:
[root@kvm ~]# blkid
Example output:
/dev/sdc1: LABEL="SSD1" UUID="77f8b83f-2941-433d-8c3e-547940113ad5" TYPE="ext4"
- Create a Mount Point Create a directory for the new file system:
[root@kvm ~]# mkdir /newfilesystemfolder
- Edit the
fstabFile Openfstabfor editing:
[root@kvm ~]# nano /etc/fstab
- Add the new entry:
UUID=77f8b83f-2941-433d-8c3e-547940113ad5 /newfilesystemfolder ext4 defaults 0 0
- Mount the File System Mount all file systems listed in
fstab:
[root@kvm ~]# mount -a
- Verify the file system is mounted using the
dfcommand:
[root@kvm ~]# df -h
Important Notes:
- Always backup your
fstabfile before editing. - To unmount a file system, use:
[root@kvm ~]# umount /dev/sdd2
After these configurations, you can safely reboot your server to ensure the settings take effect.
This article was first published in December 2023. checkout the original version here: https://archives.genzis.net/blog/set-up-file-systems-to-auto-mount-on-startup-redhat-server
