Linux Advanced File System and Storage — Questions and Answers
Question 1: What does the `df -h` command display on a Linux system?
- Disk space usage of mounted filesystems in human-readable format (Correct answer)
- Detailed file attributes of the current directory
- Disk fragmentation statistics
- Device file listings in /dev
Correct answer: Disk space usage of mounted filesystems in human-readable format
df (disk free) reports filesystem disk space usage; -h makes sizes human-readable (KB, MB, GB) instead of raw block counts.
df -h shows each mounted filesystem's total size, used space, available space, use percentage, and mount point. Useful variants: df -i (inode usage instead of block usage), df -T (show filesystem type), df -hT (both human-readable and type). For a specific path: df -h /home. Note that df shows filesystem-level space — it accounts for reserved blocks (typically 5% on ext4 for root). A filesystem can be 100% used at the block level even if inodes are available (and vice versa).
Question 2: Which command shows the disk usage of a directory and its subdirectories?
- du -sh /path (Correct answer)
- df -sh /path
- ls -lh /path
- find /path -size
Correct answer: du -sh /path
du (disk usage) measures actual file/directory sizes on disk; -s summarizes total for the directory, -h makes it human-readable.
du -sh /path shows the total size of the directory. For a breakdown: du -h --max-depth=1 /path (one level deep), du -ah /path (show all files), du -sh /* 2>/dev/null (all root directories). Finding the largest directories: du -h /var | sort -rh | head -20. The --apparent-size flag shows logical file sizes rather than disk usage (which accounts for block alignment). For large trees, ncdu provides an interactive TUI for exploring disk usage.
Question 3: What is the purpose of the `fsck` command in Linux?
- Checks and repairs filesystem inconsistencies (Correct answer)
- Changes filesystem permissions recursively
- Formats a disk with a new filesystem
- Lists filesystem configuration details
Correct answer: Checks and repairs filesystem inconsistencies
fsck (filesystem check) scans for and repairs filesystem errors — it should be run on unmounted filesystems to avoid further corruption.
fsck /dev/sda1 checks and repairs the specified filesystem. It MUST be run on unmounted filesystems (or in read-only mode) — running on a mounted filesystem can cause worse corruption. At boot, fsck runs automatically if the filesystem's check counter or interval has been exceeded. Force a check on next boot: touch /forcefsck or tune2fs -C 1 /dev/sda1. Different filesystem types use type-specific tools: e2fsck (ext2/3/4), xfs_repair (XFS), fsck.btrfs. Use -y flag to automatically answer yes to all repairs.
Question 4: What is an inode in Linux filesystems?
- A data structure that stores metadata about a file (permissions, timestamps, size, data block pointers) (Correct answer)
- The actual data content of a file
- A directory entry that maps filenames to files
- A special device file in /dev
Correct answer: A data structure that stores metadata about a file (permissions, timestamps, size, data block pointers)
An inode stores all metadata about a file except its name and content: permissions, ownership, timestamps, size, and pointers to data blocks.
Each file and directory has exactly one inode. The inode stores: file type (regular, directory, symlink, etc.), permissions (rwxr-xr-x), owner UID/GID, size, timestamps (atime, mtime, ctime), link count (hard links pointing to it), and block pointers (direct, indirect, double-indirect). Directory entries are just (filename → inode number) mappings — this is why hard links to the same file can have different names. Check inode usage with df -i; view a file's inode with ls -i or stat.
Question 5: What is the difference between a hard link and a symbolic (soft) link in Linux?
- A hard link is a direct reference to the same inode; a symbolic link is a file containing a path to another file (Correct answer)
- A hard link can cross filesystems; a symbolic link cannot
- A hard link can only link directories; a symbolic link can only link files
- A hard link stores the file content twice; a symbolic link stores it once
Correct answer: A hard link is a direct reference to the same inode; a symbolic link is a file containing a path to another file
Hard links share the same inode (same file, multiple names); symbolic links are separate files containing a path, similar to Windows shortcuts.
Hard links: created with ln source dest, share the same inode number, file persists until all hard links are deleted (link count reaches 0), cannot cross filesystems, cannot link directories. Symbolic links: created with ln -s source dest, have their own inode containing the target path, broken if target is deleted/moved, can cross filesystems, can link directories. Use cases: hard links for critical backups (rm source doesn't lose data), symlinks for flexible references (/usr/bin/python → python3.9).
Question 6: Which command creates a new ext4 filesystem on the /dev/sdb1 partition?
- mkfs.ext4 /dev/sdb1 (Correct answer)
- format /dev/sdb1 ext4
- newfs -t ext4 /dev/sdb1
- mkdisk ext4 /dev/sdb1
Correct answer: mkfs.ext4 /dev/sdb1
mkfs.ext4 (or mkfs -t ext4) formats a partition with the ext4 filesystem — this destroys all existing data on the partition.
mkfs.ext4 /dev/sdb1 creates a new ext4 filesystem. Important options: -L label (set volume label), -b 4096 (block size), -m 1 (reduce reserved space to 1% for non-root filesystems), -E lazy_itable_init=0 (initialize inode table at format time for data centers). Other filesystem types: mkfs.xfs (XFS), mkfs.btrfs (Btrfs), mkfs.vfat (FAT32), mkfs.ntfs (NTFS). Always verify the device name carefully — formatting the wrong device is irreversible data loss.
Question 7: What does the `mount -o remount,ro /` command do?
- Remounts the root filesystem as read-only without unmounting (Correct answer)
- Formats the root filesystem and mounts it
- Removes the root filesystem mount
- Mounts a new filesystem over the root
Correct answer: Remounts the root filesystem as read-only without unmounting
remount allows changing mount options on an already-mounted filesystem; ro makes it read-only — used in maintenance mode and rescue situations.
mount -o remount,ro / is used during maintenance to put the root filesystem into read-only mode safely before fsck or before shutdown in emergency situations. The reverse, mount -o remount,rw /, makes it writable again. Other common remount uses: adding noexec to prevent script execution, adding noatime to improve performance. Mount options are specified in /etc/fstab for permanent configuration. The 'ro' initial mount then 'remount,rw' is the standard pattern for systemd's boot process.
Question 8: What is LVM (Logical Volume Manager) in Linux, and what problem does it solve?
- LVM provides a flexible abstraction layer over physical storage, allowing dynamic resizing and management of disk space across multiple devices (Correct answer)
- LVM provides encryption for disk volumes
- LVM is a RAID controller that mirrors data across disks
- LVM manages filesystem permissions for logical groups of files
Correct answer: LVM provides a flexible abstraction layer over physical storage, allowing dynamic resizing and management of disk space across multiple devices
LVM abstracts physical storage into flexible logical volumes that can be resized, snapshotted, and spanned across multiple disks without reformatting.
LVM hierarchy: Physical Volumes (PVs — actual disks/partitions) → Volume Group (VG — pool of storage) → Logical Volumes (LVs — flexible partitions). Key commands: pvcreate, vgcreate, lvcreate, lvextend, lvreduce, lvresize, vgextend (add PV to VG). Advantages: resize logical volumes without moving data, create snapshots for backups, thin provisioning, mirror/stripe across PVs. Extending an LV: lvextend -L +10G /dev/vg0/lv_home; resize2fs /dev/vg0/lv_home (for ext4) or xfs_growfs (for XFS).
Question 9: Which /etc/fstab field specifies the pass number for filesystem check order at boot?
- The 6th field (pass) (Correct answer)
- The 5th field (dump)
- The 4th field (options)
- The 3rd field (type)
Correct answer: The 6th field (pass)
The 6th field in /etc/fstab determines fsck order at boot: 0 = skip, 1 = check first (root fs), 2 = check after root.
/etc/fstab format: device mountpoint type options dump pass. The pass field: 0 = never fsck, 1 = check first (should only be root /), 2 = check after root (other filesystems). Multiple filesystems with pass=2 may be checked in parallel. The dump field (5th) specifies if dump(8) should backup the filesystem: 0 = no, 1 = yes (largely obsolete). Modern systemd systems may ignore /etc/fstab's pass field in favor of their own checks. XFS, Btrfs, and ZFS don't use fsck — use xfs_repair or btrfs check respectively.
Question 10: What is the purpose of the `tune2fs` command?
- Adjusts tunable parameters of ext2/3/4 filesystems, such as reserved block count, check intervals, and mount options (Correct answer)
- Tunes system performance by adjusting kernel parameters
- Converts ext2 to ext4 filesystem
- Tunes RAID parameters for ext filesystems
Correct answer: Adjusts tunable parameters of ext2/3/4 filesystems, such as reserved block count, check intervals, and mount options
tune2fs modifies ext2/3/4 filesystem parameters without reformatting, including reserved space percentage, mount count limits, and filesystem features.
Common tune2fs operations: tune2fs -m 1 /dev/sda1 (reduce reserved blocks to 1% — default 5% wastes space on large non-root filesystems), tune2fs -L 'data' /dev/sda1 (set volume label), tune2fs -c 0 -i 0 /dev/sda1 (disable automatic fsck checks), tune2fs -O ^has_journal /dev/sda1 (remove journaling to convert ext3 to ext2), tune2fs -j /dev/sda1 (add journal to convert ext2 to ext3). View current settings: tune2fs -l /dev/sda1.
Question 11: What is RAID 5 and what are its requirements?
- RAID 5 stripes data with distributed parity across at least 3 disks, allowing one disk failure without data loss (Correct answer)
- RAID 5 mirrors data across exactly 2 disks
- RAID 5 stripes data across disks with no redundancy, requiring exactly 5 disks
- RAID 5 uses a dedicated parity disk and requires exactly 5 disks
Correct answer: RAID 5 stripes data with distributed parity across at least 3 disks, allowing one disk failure without data loss
RAID 5 distributes parity data across all disks (not a dedicated parity disk), providing fault tolerance for one disk failure with good read performance.
RAID 5: minimum 3 disks, usable capacity = (n-1) × disk_size, tolerates 1 disk failure. Parity is distributed: each stripe has parity on a different disk to avoid the write bottleneck of RAID 4's dedicated parity disk. Write performance is slower than RAID 0/10 (parity calculation overhead). RAID 6 needs 4+ disks and tolerates 2 failures. RAID 10 (1+0) mirrors then stripes — better write performance, higher cost. Linux software RAID: mdadm. Hardware RAID: controller card. ZFS has RAIDZ (equivalent to RAID 5) and RAIDZ2/RAIDZ3.
Question 12: What command creates a software RAID 5 array from three disks in Linux?
- mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd (Correct answer)
- mkraid --level 5 /dev/sdb /dev/sdc /dev/sdd
- raidctl create --raid5 /dev/sdb /dev/sdc /dev/sdd
- mdadm --build /dev/md0 -l5 /dev/sdb /dev/sdc /dev/sdd
Correct answer: mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
mdadm is the Linux software RAID management tool; --create builds a new array, --level sets the RAID type, --raid-devices specifies the count.
mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd creates a RAID 5 array. The array rebuilds (syncs) after creation — monitor with cat /proc/mdstat. Save configuration: mdadm --detail --scan >> /etc/mdadm/mdadm.conf. Other mdadm operations: --assemble (start existing array), --stop (stop array), --fail and --remove (remove a disk), --add (add a spare/replacement). Monitor status: mdadm --detail /dev/md0. Automating RAID assembly at boot requires /etc/mdadm/mdadm.conf and initrd updates.
Question 13: What is the Btrfs filesystem's key advantage over ext4?
- Built-in copy-on-write snapshots, checksumming, RAID, and online resizing without separate tools (Correct answer)
- Higher maximum file size support only
- Faster sequential read performance
- Better compatibility with Windows systems
Correct answer: Built-in copy-on-write snapshots, checksumming, RAID, and online resizing without separate tools
Btrfs (B-tree filesystem) provides integrated features: COW snapshots, per-block checksums for data integrity, built-in RAID, compression, and subvolumes.
Btrfs key features: copy-on-write (COW) snapshots (instant, space-efficient), transparent compression (zlib, lzo, zstd), integrated RAID (RAID 0, 1, 5, 6, 10), subvolumes (like partitions within a filesystem), send/receive for efficient backup to another Btrfs, online defragmentation, and checksums for both data and metadata (detects bit rot). Commands: btrfs subvolume snapshot, btrfs filesystem usage, btrfs scrub (verify checksums), btrfs balance. Used by default in Fedora since version 33 and OpenSUSE.
Question 14: What does the `lsblk` command show?
- Tree view of all block devices, their sizes, mount points, and types (Correct answer)
- List of running processes using block devices
- Block device error logs
- Filesystem check results for block devices
Correct answer: Tree view of all block devices, their sizes, mount points, and types
lsblk lists all block devices (disks, partitions, LVM volumes) in a tree structure showing relationships, sizes, and mount points.
lsblk shows a tree of sda → sda1, sda2, etc., including LVM volumes (sda2 → ubuntu--vg-ubuntu--lv). Useful options: lsblk -f (show filesystem type and UUID), lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,UUID (custom columns), lsblk -d (disks only, not partitions). UUIDs from lsblk -f are used in /etc/fstab for persistent device naming (better than /dev/sdX which can change). Compare with: fdisk -l (detailed partition table info), blkid (block device attributes).
Question 15: What is the purpose of swap space in Linux?
- Provides overflow virtual memory on disk when RAM is full, and stores hibernation state (Correct answer)
- Stores temporary files during boot
- Provides a scratch area for file system repair tools
- Caches frequently accessed files for faster access
Correct answer: Provides overflow virtual memory on disk when RAM is full, and stores hibernation state
Swap extends the system's virtual memory by using disk space, and is used to store the contents of RAM during hibernation (suspend-to-disk).
Linux uses swap as overflow when physical RAM fills: it moves less-used memory pages to swap (swapping/paging). Excessive swapping ('thrashing') severely degrades performance. For hibernation, the swap partition must be at least as large as RAM. Swap can be a partition (mkswap /dev/sdX; swapon /dev/sdX) or a file (dd if=/dev/zero of=/swapfile; mkswap /swapfile; swapon /swapfile). The swappiness kernel parameter (vm.swappiness, default 60) controls tendency to swap. Check swap usage: free -h, swapon --show. Modern SSDs make swap less painful but still slower than RAM.
Question 16: Which command shows detailed information about a file's inode, including all timestamps?
- stat filename (Correct answer)
- ls -li filename
- inode filename
- file --info filename
Correct answer: stat filename
stat displays all inode information: size, blocks, inode number, permissions, UID/GID, all three timestamps (atime, mtime, ctime), and device info.
stat output includes: File (name), Size, Blocks, IO Block, File type, Device, Inode number, Links (hard link count), Access (permissions and octal), Uid, Gid, Access time (atime — last read), Modify time (mtime — last content change), Change time (ctime — last metadata/content change). Note: there is no 'creation time' in traditional Linux filesystems, though ext4 stores birth time (crtime) accessible via debugfs. 'touch -a' updates atime, 'touch -m' updates mtime, 'touch' updates both.
Question 17: What is the function of the `/proc/mounts` file in Linux?
- Shows all currently mounted filesystems with their options, similar to the output of 'mount' (Correct answer)
- Lists mount configurations for automount daemons
- Contains the history of all past mount operations
- Defines which filesystems are supported by the kernel
Correct answer: Shows all currently mounted filesystems with their options, similar to the output of 'mount'
/proc/mounts is a kernel-maintained file showing all active mounts in real time, including bind mounts and pseudo-filesystems.
/proc/mounts shows the actual running mount state, which may differ from /etc/fstab (configured mounts). Each line: device mountpoint fstype options dump pass. Pseudo-filesystems like tmpfs, sysfs, proc, devtmpfs are also listed. Related files: /proc/filesystems (supported fs types), /etc/mtab (often a symlink to /proc/mounts on modern systems). The mount command reads /proc/mounts for its output. Programmatically, getmntent() reads this file to enumerate mounts.
Question 18: What is the purpose of the `dd` command in Linux storage management?
- Copies raw data at a block level, used for disk imaging, cloning, and writing bootable images (Correct answer)
- Deletes duplicate files from a directory
- Defragments a disk filesystem
- Checks disk sectors for damage
Correct answer: Copies raw data at a block level, used for disk imaging, cloning, and writing bootable images
dd is a low-level copy utility that works at the block level, capable of creating disk images, cloning drives, writing ISO images, and testing disk performance.
Common dd uses: disk image (dd if=/dev/sda of=/backup/sda.img bs=4M status=progress), clone disk (dd if=/dev/sda of=/dev/sdb bs=4M), write ISO (dd if=ubuntu.iso of=/dev/sdc bs=4M), zero a disk (dd if=/dev/zero of=/dev/sdb bs=4M). The bs (block size) affects performance — larger values (4M-64M) are faster. status=progress shows transfer speed and progress. WARNING: dd is sometimes called 'disk destroyer' — reversing if and of destroys data. Use ddrescue for damaged disks as it handles read errors more gracefully.
Question 19: What is XFS and what type of workloads is it best suited for?
- A high-performance journaling filesystem best suited for large files and parallel I/O workloads (Correct answer)
- A compressed filesystem optimized for small files
- A network filesystem designed for distributed storage
- A filesystem designed specifically for SSDs
Correct answer: A high-performance journaling filesystem best suited for large files and parallel I/O workloads
XFS excels at large file performance, parallel access patterns, and scales to very large filesystems — making it default in RHEL for enterprise storage workloads.
XFS strengths: excellent parallel I/O performance, online growing (xfs_growfs), efficient handling of large files (video, databases), allocation groups for parallelism, no major filesystem size limits (8 exabytes), delayed allocation for write performance. XFS limitations: cannot shrink online (major limitation vs ext4+resize2fs), older tools required (xfs_repair instead of e2fsck, xfs_fsr for defrag). Default on RHEL 7+, used by many HPC and media storage systems. Btrfs and ZFS are more feature-rich but XFS offers raw performance for specific workloads.
Question 20: Which command permanently mounts a filesystem by adding it to the appropriate configuration file?
- Edit /etc/fstab with the device, mount point, filesystem type, options, dump, and pass fields (Correct answer)
- mount --permanent /dev/sdb1 /mnt/data
- mount --save /dev/sdb1 /mnt/data
- systemctl enable mount@mnt-data
Correct answer: Edit /etc/fstab with the device, mount point, filesystem type, options, dump, and pass fields
/etc/fstab is the filesystem table where persistent mount configurations are defined; entries are processed at boot and by 'mount -a'.
An /etc/fstab entry: /dev/sdb1 /mnt/data ext4 defaults 0 2. Best practice: use UUID instead of /dev/sdX (get UUID with blkid or lsblk -f): UUID=abc123 /mnt/data ext4 defaults,nofail 0 2. The 'nofail' option prevents boot failure if the device is missing. After editing fstab, test with: mount -a (mount all fstab entries not yet mounted) — errors will be shown without rebooting. For removable/network storage, consider using systemd mount units (.mount files) instead of fstab for more control.
Question 21: What does the `blkid` command display?
- Block device attributes including UUID, filesystem type, and label (Correct answer)
- Blocked device access attempts from security policies
- Block size information for all filesystems
- I/O block statistics per device
Correct answer: Block device attributes including UUID, filesystem type, and label
blkid probes block devices and displays their UUID, filesystem type, label, and other attributes — essential for writing stable /etc/fstab entries.
blkid output: /dev/sda1: UUID="abc-123" TYPE="ext4" PARTUUID="xyz-456". Use specific device: blkid /dev/sda1. The UUID is preferred over /dev/sdX in /etc/fstab because device names can change (adding/removing disks), while UUIDs are filesystem-specific and stable. LABEL is also stable if set (tune2fs -L or mkfs.ext4 -L). For NVMe drives (/dev/nvme0n1p1), same approach. Use blkid -o value -s UUID /dev/sda1 to get only the UUID in scripts.
Question 22: What is the purpose of the `quotacheck` and `quotaon` commands in Linux?
- quotacheck scans the filesystem to build the quota database; quotaon activates disk quota enforcement (Correct answer)
- quotacheck verifies user permissions; quotaon enables ACLs
- quotacheck repairs filesystem quotas; quotaon displays current quota usage
- quotacheck sets quota limits; quotaon writes them to the inode table
Correct answer: quotacheck scans the filesystem to build the quota database; quotaon activates disk quota enforcement
Disk quotas limit storage per user/group; quotacheck creates the accounting database files (aquota.user, aquota.group), and quotaon starts enforcement.
Quota setup: 1) Add 'usrquota,grpquota' options to fstab entry, 2) remount or reboot, 3) quotacheck -cug /filesystem (create quota files), 4) quotaon /filesystem (activate), 5) edquota -u username (set soft/hard limits for blocks and inodes), 6) repquota /filesystem (report). Limits: soft limit (warning threshold), hard limit (absolute maximum), grace period (time to resolve soft limit exceedance). Modern alternatives: XFS has built-in xfs_quota tool, Btrfs has subvolume quotas (qgroups). Check: quota -v (show your quotas).
Question 23: What does the `parted` command do, and how does it differ from `fdisk`?
- parted supports GPT partition tables and disks >2TB, while fdisk traditionally only supports MBR partitions up to 2TB (Correct answer)
- parted is for SCSI disks; fdisk is for SATA disks
- parted only creates partitions; fdisk can both create and format
- parted requires a GUI; fdisk is command-line only
Correct answer: parted supports GPT partition tables and disks >2TB, while fdisk traditionally only supports MBR partitions up to 2TB
parted handles both MBR and GPT partition tables and isn't limited by the 2TB MBR constraint, making it the preferred tool for modern large disks.
fdisk: text-based, traditional MBR (max 4 primary partitions, 2TB limit), newer versions support GPT but with limitations. parted: supports MBR and GPT natively, handles drives >2TB, interactive or scriptable (parted /dev/sdb mklabel gpt; parted /dev/sdb mkpart primary ext4 1MiB 100%), provides resize capability. gdisk is another GPT-focused partitioning tool with fdisk-like interface. For scripts: sfdisk (scriptable fdisk), sgdisk (scriptable gdisk). Modern recommendation: use parted or gdisk for GPT, especially for drives >2TB.
Question 24: What is tmpfs and what are its characteristics?
- A memory-based filesystem that stores files in RAM/swap, automatically sized and volatile (Correct answer)
- A temporary file cleanup daemon
- A filesystem stored on a temporary partition
- A type of compressed filesystem for backup files
Correct answer: A memory-based filesystem that stores files in RAM/swap, automatically sized and volatile
tmpfs is a virtual memory filesystem — files exist in RAM (and potentially swap), are lightning fast, but are lost on reboot or unmount.
tmpfs is used for /tmp, /run, /dev/shm, and various /run/* paths. Characteristics: uses RAM (and swap if needed), dynamically sized (only uses as much RAM as files actually take), automatically cleaned at reboot, extremely fast (no disk I/O). Mount: mount -t tmpfs -o size=512M tmpfs /mnt/ramdisk. The default size is 50% of RAM. /dev/shm is used by applications for POSIX shared memory. Using tmpfs for /tmp can improve performance on systems with many temp files (like compilation) and reduce SSD wear.
Question 25: What is the function of `e2label` and when would you use it?
- Sets or displays the label of an ext2/3/4 filesystem, used for human-friendly identification in /etc/fstab (Correct answer)
- Changes the ext filesystem version label
- Labels files with extended attributes
- Sets the SELinux label for an ext filesystem
Correct answer: Sets or displays the label of an ext2/3/4 filesystem, used for human-friendly identification in /etc/fstab
e2label assigns a human-readable name to an ext filesystem, which can then be used in /etc/fstab as LABEL=name instead of UUID or device path.
e2label /dev/sdb1 mydata sets the label; e2label /dev/sdb1 shows current label. Labels in fstab: LABEL=mydata /mnt/data ext4 defaults 0 2. Labels are convenient but must be unique across all mounted devices — if two filesystems have the same label, mount by LABEL is ambiguous. For XFS labels: xfs_admin -L. For any filesystem type: use tune2fs -L (ext) or mkfs options (-L for most types). Prefer UUIDs over labels for unambiguous identification in automated systems.
Question 26: What does `smartctl -a /dev/sda` report?
- SMART (Self-Monitoring, Analysis and Reporting Technology) health data including error counts, temperature, and overall health assessment (Correct answer)
- Standard Linux partition table and mount information
- Scheduled maintenance tasks for the device
- Smart power management statistics
Correct answer: SMART (Self-Monitoring, Analysis and Reporting Technology) health data including error counts, temperature, and overall health assessment
SMART (via smartmontools) provides hard drive/SSD diagnostic data including reallocated sectors, read errors, temperature, and a health verdict.
smartctl -a /dev/sda shows: overall health (-H), SMART attributes (reallocated sectors, seek errors, power-on hours, temperature), and recent error logs. Key attributes: Reallocated_Sector_Ct (bad sectors remapped — rising = problem), Spin_Retry_Count, Uncorrectable_Sector_Count. Short self-test: smartctl -t short /dev/sda; long test: smartctl -t long /dev/sda; results: smartctl -l selftest /dev/sda. The smartd daemon monitors drives in the background and sends email alerts. For NVMe: nvme smart-log /dev/nvme0.
Question 27: What is the purpose of `/etc/exports` in Linux?
- Defines which directories are shared via NFS (Network File System) and access permissions for each (Correct answer)
- Exports shell environment variables system-wide
- Lists programs that should be exported to PATH
- Defines files that are excluded from backup
Correct answer: Defines which directories are shared via NFS (Network File System) and access permissions for each
/etc/exports configures NFS exports — which directories are shared, to which clients, and with what permissions (ro/rw, root_squash, etc.).
/etc/exports example: /home 192.168.1.0/24(rw,sync,no_root_squash). Fields: directory, client (IP/hostname/wildcard), options. Common options: ro/rw (read-only/write), sync (write to disk before ACK), async (faster but risky), root_squash (map root to nobody — default), no_root_squash (dangerous, allow root), all_squash (map all users to nobody). Apply changes: exportfs -ra (reload), exportfs -v (show active exports). Mount NFS: mount server:/share /mnt. For persistent: add to /etc/fstab with type nfs.
Question 28: Which command would you use to check and display the detailed layout of a disk's partition table?
- fdisk -l /dev/sda (Correct answer)
- partinfo /dev/sda
- diskstat /dev/sda
- hdparm -I /dev/sda
Correct answer: fdisk -l /dev/sda
fdisk -l displays the partition table of a disk, showing partition start/end sectors, sizes, types, and whether the table is MBR or GPT.
fdisk -l /dev/sda shows disk geometry, partition table type (DOS/MBR or GPT), and all partitions with their start/end sectors, size, and type code. For GPT disks, gdisk -l /dev/sda provides more detailed GPT information. parted -l shows all disks and partitions. For a block device overview, lsblk is more visual. hdparm -I /dev/sda shows ATA device information (model, serial, capabilities) rather than partition layout. For NVMe drives: fdisk -l /dev/nvme0n1 or nvme list.
Question 29: What does `resize2fs` do and when is it needed?
- Resizes an ext2/3/4 filesystem to match a new partition size after the partition has been grown (Correct answer)
- Formats an ext filesystem to a specific size
- Repairs inode size inconsistencies in ext filesystems
- Changes the block size of an existing ext filesystem
Correct answer: Resizes an ext2/3/4 filesystem to match a new partition size after the partition has been grown
After extending a partition (with fdisk/parted/LVM), resize2fs grows the ext filesystem to use the new available space.
The workflow for extending a logical volume: lvextend -L +10G /dev/vg0/data; resize2fs /dev/vg0/data (ext4) or xfs_growfs /mnt/data (XFS — online while mounted). For a physical partition: expand with parted, then resize2fs. resize2fs can also shrink filesystems (offline only): resize2fs /dev/sda1 20G; then resize the partition. For LVM shrink: resize2fs first, then lvreduce. XFS CANNOT be shrunk — only grown. Btrfs: btrfs filesystem resize. ZFS: zpool online -e.
What does the `df -h` command display on a Linux system?