Free Linux+ Filesystem and Storage Management Questions and Answers 1 — Questions and Answers
Question 1: A system administrator needs to add a new disk, /dev/sdc, to an existing LVM volume group named 'vg_data' and then use all the new space to extend the logical volume '/dev/mapper/vg_data-lv_apps'. Which of the following command sequences is the correct way to accomplish this?
- pvcreate /dev/sdc && vgextend vg_data /dev/sdc && lvextend -l +100%FREE /dev/mapper/vg_data-lv_apps && resize2fs /dev/mapper/vg_data-lv_apps (Correct answer)
- vgextend vg_data /dev/sdc && pvcreate /dev/sdc && lvextend -r -l +100%FREE /dev/mapper/vg_data-lv_apps
- mkfs.ext4 /dev/sdc && vgadd vg_data /dev/sdc && lvresize --extents +100%FREE /dev/mapper/vg_data-lv_apps
- pvcreate /dev/sdc && vgadd vg_data /dev/sdc && lvextend -l +100%FREE /dev/mapper/vg_data-lv_apps
Correct answer: pvcreate /dev/sdc && vgextend vg_data /dev/sdc && lvextend -l +100%FREE /dev/mapper/vg_data-lv_apps && resize2fs /dev/mapper/vg_data-lv_apps
The correct process involves four steps in order: 1. Initialize the new disk as a physical volume for LVM use with `pvcreate`. 2. Extend the existing volume group to include the new physical volume with `vgextend`. 3. Extend the logical volume to use the newly available free space in the volume group with `lvextend -l +100%FREE`. 4. Resize the filesystem on the logical volume to recognize and use the new space with `resize2fs` (for ext4 filesystems).
Question 2: A system administrator wants to ensure an XFS filesystem on the partition identified by UUID 'a1b2c3d4-e5f6-7890-1234-56789abcdef0' is automatically mounted to `/mnt/archive` at boot. Which of the following lines is correctly formatted for `/etc/fstab`?
- mount /mnt/archive UUID=a1b2c3d4-e5f6-7890-1234-56789abcdef0 xfs defaults 0 0
- UUID=a1b2c3d4-e5f6-7890-1234-56789abcdef0 /mnt/archive xfs defaults 0 0 (Correct answer)
- /mnt/archive UUID=a1b2c3d4-e5f6-7890-1234-56789abcdef0 xfs auto 1 2
- UUID=a1b2c3d4-e5f6-7890-1234-56789abcdef0 /mnt/archive xfs nofail
Correct answer: UUID=a1b2c3d4-e5f6-7890-1234-56789abcdef0 /mnt/archive xfs defaults 0 0
The standard format for an /etc/fstab entry is: <device> <mount_point> <filesystem_type> <options> <dump> <pass>. The correct answer follows this format, using the UUID to identify the device, followed by the mount point, filesystem type, standard options ('defaults'), and the appropriate dump (0) and pass (0) values for a non-root data filesystem.
Question 3: A user reports the `/home` filesystem is nearly full. Which command would be most effective for a system administrator to identify the specific subdirectories within `/home/someuser` that are consuming the most disk space?
- find /home/someuser -type d -size +1G
- df -h /home/someuser
- ls -lR /home/someuser
- du -sh /home/someuser/* | sort -rh (Correct answer)
Correct answer: du -sh /home/someuser/* | sort -rh
The `du -sh /home/someuser/*` command calculates the disk usage (`du`) in a summarized (`-s`) and human-readable (`-h`) format for each item in the `/home/someuser` directory. Piping this output to `sort -rh` sorts the results numerically in reverse (largest first) human-readable format, making it easy to see the largest directories at the top. `df` shows partition-level usage, not directory-level.
Question 4: A Linux server has failed to boot, dropping to an emergency shell. The administrator determines the root filesystem on `/dev/sda2` has errors and needs to be repaired. The filesystem is currently unmounted. Which command should be used to automatically attempt to fix any detected errors non-interactively?
- e2fsck -f /dev/sda2
- fsck -p /dev/sda2 (Correct answer)
- fsck -n /dev/sda2
- mount -o remount,rw / && fsck /dev/sda2
Correct answer: fsck -p /dev/sda2
The `fsck` command is used to check and repair filesystems. The `-p` (preen) option causes `fsck` to automatically repair any filesystem problems that can be safely fixed without user intervention. This is often preferred in scripts or recovery scenarios to avoid manual prompts. The `-y` flag is another common alternative that assumes 'yes' to all prompts.
Question 5: A system administrator has created a new partition, `/dev/sdb3`, to be used as additional swap space. What is the correct command to prepare this partition for use as swap before it can be enabled?
- swapon /dev/sdb3
- mkfs.swap /dev/sdb3
- mkswap /dev/sdb3 (Correct answer)
- format -t swap /dev/sdb3
Correct answer: mkswap /dev/sdb3
The `mkswap` command is used to set up a Linux swap area on a device or in a file. This command initializes the partition with the necessary signature and metadata to be recognized as swap space. Only after running `mkswap` can the `swapon` command be used to activate it.
Question 6: An administrator executes the command `mount -o remount,ro /data` on a filesystem that is currently mounted as read-write. What is the effect of this command?
- The command will fail because the filesystem is already mounted.
- The filesystem will be unmounted and then immediately remounted as read-only.
- The system will enter single-user mode to safely remount the filesystem.
- The filesystem's mount options will be changed to read-only without unmounting it. (Correct answer)
Correct answer: The filesystem's mount options will be changed to read-only without unmounting it.
The `remount` option for the `mount` command allows an administrator to change the mount flags of an already-mounted filesystem without unmounting and remounting it. In this case, it changes the status of the `/data` mount point from its current state to read-only (`ro`).
A system administrator needs to add a new disk, /dev/sdc, to an existing LVM volume group named 'vg_data' and then use all the new space to extend the logical volume '/dev/mapper/vg_data-lv_apps'.
Which of the following command sequences is the correct way to accomplish this?