Configure systems to mount file systems on demand
Kunle is a RHEL Sysadmin at Red Hat:
- His RHEL Server: RHEL_Server_0893
- His username: kunle.owolabi
- His professional preference: RHEL Syadmins NEVER run commands as root
- His credentials: ComTIA Linux+, LPIC 1, 2 and 3
- His task: Configure systems to mount file systems on demand
Red Hat has just hired a class of 24 RHEL Engineers. Kunle's job is to teach them enough to have all of them pass the LFCS exam in 6 weeks. Today, he is going to teach them how to mount file systems on demand. Please generate and explain several example commands that Kunle can use to help the class to master this LFCS exam objective.
Certainly! Here are the modified example commands, including the addition of an /etc/fstab entry for automatically mounting the file system at boot:
Creating a File System:
- Command:
sudo mkfs.ext4 /dev/sdb1 - Explanation: This command creates an ext4 file system on the
/dev/sdb1partition. Themkfs.ext4command is used to create a file system of the ext4 type. Thesudocommand is used to run the command with root privileges.
- Command:
Checking File System Type:
- Command:
lsblk -f /dev/sdb1 - Explanation: This command displays information about the file system on the
/dev/sdb1partition, including the file system type. The-foption is used to display the file system type along with other details.
- Command:
Mounting a File System:
- Command:
sudo mount /dev/sdb1 /mnt/data - Explanation: This command mounts the file system located on
/dev/sdb1to the/mnt/datadirectory. Thesudocommand is used to run the command with root privileges. Replace/dev/sdb1with the actual device or partition name and/mnt/datawith the desired mount point directory.
- Command:
Mounting with Specified File System Type:
- Command:
sudo mount -t ext4 /dev/sdb1 /mnt/data - Explanation: This command mounts the ext4 file system located on
/dev/sdb1to the/mnt/datadirectory. The-toption specifies the file system type, in this case, ext4. Thesudocommand is used to run the command with root privileges.
- Command:
Mounting a File System with Read-Only Access:
- Command:
sudo mount -o ro /dev/sdb1 /mnt/data - Explanation: This command mounts the file system located on
/dev/sdb1to the/mnt/datadirectory with read-only access. The-ooption is used to specify mount options, androstands for read-only. Thesudocommand is used to run the command with root privileges.
- Command:
Mounting a File System with Specific Mount Options and Adding /etc/fstab Entry:
- Command:
echo "/dev/sdb1 /mnt/data ext4 defaults 0 0" | sudo tee -a /etc/fstab - Explanation: This command adds an entry to the
/etc/fstabfile, which specifies the file system to be automatically mounted at boot. Replace/dev/sdb1with the actual device or partition name,/mnt/datawith the desired mount point directory, andext4with the appropriate file system type. Thesudocommand is used to run the command with root privileges.
- Command:
These example commands now include the addition of an /etc/fstab entry, which ensures the file system is mounted automatically at boot time based on the specified configuration. Kunle can explain and demonstrate the usage of these commands to the class, emphasizing the importance of properly configuring /etc/fstab for persistent and automated mounting of file systems.
