Linux Advanced File System and Storage 3 — Questions and Answers
Question 1: Which command is used to resize an ext4 filesystem online (while mounted)?
- resize2fs (Correct answer)
- e2fsck -f
- tune2fs -r
- fsadm resize
Correct answer: resize2fs
resize2fs can resize ext2/3/4 filesystems; when the filesystem is mounted and the kernel supports it, online growing is possible.
Question 2: What does the 'dm-crypt' subsystem provide in Linux?
- Transparent block-level encryption via the device mapper (Correct answer)
- Filesystem-level encryption for ext4
- Network-attached storage encryption
- RAM disk encryption
Correct answer: Transparent block-level encryption via the device mapper
dm-crypt is a Linux kernel device mapper target that provides transparent encryption of block devices using the kernel crypto API.
Question 3: What is the function of the 'fstrim' command?
- Send TRIM/discard commands to an SSD to free unused blocks (Correct answer)
- Trim whitespace from filesystem labels
- Remove orphaned inodes
- Reduce journal size
Correct answer: Send TRIM/discard commands to an SSD to free unused blocks
fstrim issues TRIM commands to SSDs for all unused blocks in a mounted filesystem, helping maintain SSD performance and longevity.
Question 4: In Btrfs, what command creates a read-write snapshot of a subvolume?
- btrfs subvolume snapshot (Correct answer)
- btrfs subvolume create --rw
- btrfs snapshot -rw
- cp --reflink=always
Correct answer: btrfs subvolume snapshot
btrfs subvolume snapshot creates a snapshot of a subvolume; by default it is read-write unless the -r flag is passed.
Question 5: Which file in /proc provides real-time information about mounted filesystems and their usage?
- /proc/mounts (Correct answer)
- /proc/filesystems
- /proc/diskstats
- /proc/partitions
Correct answer: /proc/mounts
/proc/mounts lists all currently mounted filesystems with their options, similar to /etc/mtab but always up to date.
Question 6: What does setting the 'sticky bit' on a directory do?
- Prevents users from deleting files they do not own in that directory (Correct answer)
- Makes the directory inherit parent permissions
- Sets the SGID bit automatically
- Prevents the directory from being deleted
Correct answer: Prevents users from deleting files they do not own in that directory
The sticky bit on a directory (e.g., /tmp) restricts file deletion so only the file owner, directory owner, or root can remove files.
Question 7: Which LVM command removes a Physical Volume from a Volume Group?
- vgreduce (Correct answer)
- pvremove
- lvreduce
- vgchange -r
Correct answer: vgreduce
vgreduce removes one or more unused Physical Volumes from a Volume Group; pvremove is then used to remove the LVM metadata from the disk.
Which command is used to resize an ext4 filesystem online (while mounted)?