RHCSA Filesystem and Mount Configuration Questions and Answers — Questions and Answers
Question 1: A system administrator has created an XFS filesystem on `/dev/vg01/data_lv` and needs to ensure it is mounted automatically at `/srv/data` upon system boot. Which of the following `/etc/fstab` entries is the most robust and correct way to achieve this?
- /dev/vg01/data_lv /srv/data xfs defaults 0 0
- UUID=550e8400-e29b-41d4-a716-446655440000 /srv/data ext4 defaults 0 0
- UUID=550e8400-e29b-41d4-a716-446655440000 /srv/data xfs defaults 0 0 (Correct answer)
- /srv/data /dev/vg01/data_lv xfs defaults 0 0
Correct answer: UUID=550e8400-e29b-41d4-a716-446655440000 /srv/data xfs defaults 0 0
The correct `/etc/fstab` entry uses the device's UUID to ensure the correct device is mounted, even if its device name (e.g., `/dev/sdX`) changes. The entry must specify the correct mount point (`/srv/data`), filesystem type (`xfs`), and standard mount options (`defaults`). The final two numbers (`0 0`) are for dump and fsck order, respectively.
Question 2: To add a new device to `/etc/fstab` for automounting, a system administrator needs to determine the UUID and filesystem type of the partition `/dev/sdb1`. Which of the following commands provides this information most directly?
- blkid /dev/sdb1 (Correct answer)
- fdisk -l /dev/sdb1
- df -h /dev/sdb1
- mount /dev/sdb1
Correct answer: blkid /dev/sdb1
The `blkid` command is the standard utility for locating and printing block device attributes, including the UUID and filesystem TYPE, without needing the device to be mounted. `fdisk -l` shows partition information but not the filesystem UUID. `df` only works on already mounted filesystems.
Question 3: A system running a database requires a new high-performance XFS filesystem. A logical volume has been created at `/dev/vg_db/lv_logs`. Which of the following commands will correctly format this logical volume with the XFS filesystem?
- format -t xfs /dev/vg_db/lv_logs
- newfs xfs /dev/vg_db/lv_logs
- mkfs -f xfs /dev/vg_db/lv_logs
- mkfs.xfs /dev/vg_db/lv_logs (Correct answer)
Correct answer: mkfs.xfs /dev/vg_db/lv_logs
The command to create (format) a filesystem is `mkfs`. For specific filesystem types like XFS, a dedicated utility `mkfs.xfs` is used. While `mkfs -t xfs` can also work, `mkfs.xfs` is the direct command for this purpose.
Question 4: A system is configured in `/etc/fstab` to mount a non-critical network file share at boot time. However, when the network is down, the system boot process fails while waiting for the share to become available. Which mount option should be added to the `/etc/fstab` entry for this share to allow the system to boot successfully even if the share is unavailable?
- auto
- nofail (Correct answer)
- noauto
- _netdev
Correct answer: nofail
The `nofail` option instructs the systemd init system not to consider this mount a failure if the device is not available during the boot process. The system will continue booting without waiting for the mount to succeed. While `_netdev` is important for network shares, it does not by itself prevent a boot failure.
Question 5: A system administrator has created a 2GB swap file at `/swapfile` using `fallocate`. What is the correct sequence of commands to properly configure and activate this new swap file?
- chmod 600 /swapfile; mkswap /swapfile; swapon /swapfile (Correct answer)
- mkswap /swapfile; chmod 600 /swapfile; swapon /swapfile
- swapon /swapfile; mkswap /swapfile; chmod 600 /swapfile
- chmod 777 /swapfile; mkswap /swapfile; swapon /swapfile
Correct answer: chmod 600 /swapfile; mkswap /swapfile; swapon /swapfile
The correct procedure is to first set restrictive permissions on the file (`chmod 600`) for security. Second, format the file as swap space using `mkswap`. Third, activate the swap space using `swapon`. The order of these steps is critical for proper and secure operation.
Question 6: A filesystem is mounted at `/opt/data` with the `defaults` options. For security reasons, a system administrator needs to remount it with the `noexec` option to prevent binaries from being executed. Which command will achieve this without interrupting access by unmounting the filesystem?
- mount -o change,noexec /opt/data
- remount /opt/data -o noexec
- mount -o remount,noexec /opt/data (Correct answer)
- umount /opt/data && mount -o noexec /dev/sdb1 /opt/data
Correct answer: mount -o remount,noexec /opt/data
The `mount` command with the `-o remount` option allows changing the mount options of an already-mounted filesystem without unmounting it. This prevents service interruption. New options are specified in a comma-separated list following `remount`.
A system administrator has created an XFS filesystem on `/dev/vg01/data_lv` and needs to ensure it is mounted automatically at `/srv/data` upon system boot.
Which of the following `/etc/fstab` entries is the most robust and correct way to achieve this?