LCA File Systems & Storage Management 5 — Questions and Answers
Question 1: Which command creates a 2 GB sparse file named 'disk.img' using dd?
- dd if=/dev/zero bs=1 count=0 seek=2G of=disk.img (Correct answer)
- dd if=/dev/zero bs=1M count=2048 of=disk.img
- truncate -s 2G disk.img
- fallocate -l 2G disk.img
Correct answer: dd if=/dev/zero bs=1 count=0 seek=2G of=disk.img
Using seek=2G with count=0 creates a sparse file by placing the file pointer without writing zeros, consuming no actual disk blocks.
Question 2: What is the effect of running 'vgreduce vg0 /dev/sdb' without pvmove first?
- Fails if /dev/sdb still holds active physical extents (Correct answer)
- Removes /dev/sdb and destroys all data on it
- Moves all extents to remaining PVs automatically
- Shrinks the VG by the PV size and pads with zeros
Correct answer: Fails if /dev/sdb still holds active physical extents
vgreduce refuses to remove a PV that still contains allocated physical extents; pvmove must be run first.
Question 3: Which command mounts an ISO image file as a loopback device at /mnt/iso?
- mount -o loop image.iso /mnt/iso (Correct answer)
- mount --bind image.iso /mnt/iso
- losetup /mnt/iso image.iso
- mount -t iso9660 image.iso
Correct answer: mount -o loop image.iso /mnt/iso
The -o loop option tells mount to use a loop device to mount the image file as if it were a block device.
Question 4: What does the XFS 'xfs_growfs' command do?
- Expands a mounted XFS filesystem to fill available space on its underlying device (Correct answer)
- Increases the XFS journal size
- Defragments and compacts an XFS filesystem
- Adds a new device to an XFS volume
Correct answer: Expands a mounted XFS filesystem to fill available space on its underlying device
xfs_growfs can expand an XFS filesystem online (while mounted) to use newly added space on the underlying block device.
Question 5: Which command lists all open files on a specific mount point, useful before unmounting?
- lsof +D /mnt/data (Correct answer)
- fuser -m /mnt/data
- ls -la /proc/*/fd | grep /mnt/data
- openfiles /mnt/data
Correct answer: lsof +D /mnt/data
lsof +D recursively lists all open files under a directory, helping identify processes preventing unmount.
Question 6: In ext4, what is the purpose of the 'reserved blocks' and which command adjusts the percentage?
- Blocks reserved for root to prevent full-disk lockouts; adjusted with tune2fs -m (Correct answer)
- Blocks for filesystem metadata; adjusted with resize2fs
- Emergency space for journaling; adjusted with e2fsck
- Blocks pre-allocated for new inodes; adjusted with mke2fs
Correct answer: Blocks reserved for root to prevent full-disk lockouts; adjusted with tune2fs -m
ext4 reserves a percentage (default 5%) of blocks for the root user; tune2fs -m sets this percentage to maintain root access when the disk is nearly full.
Question 7: Which command shows the physical extent layout and allocation status of a specific logical volume?
- lvdisplay -m /dev/vg0/lv0 (Correct answer)
- pvdisplay /dev/vg0/lv0
- vgdisplay vg0
- lvscan /dev/vg0/lv0
Correct answer: lvdisplay -m /dev/vg0/lv0
lvdisplay -m (--maps) shows the physical volume mapping for each logical extent of the LV.
Which command creates a 2 GB sparse file named 'disk.img' using dd?