LFCS Storage Management Practice Question
An administrator needs to add a 2 GB swap area that persists across reboots on a server with no free partition space, using a file at /swapfile on the root filesystem. After creating the file with fallocate and running mkswap /swapfile, which additional actions are required to activate it now and at every boot?
⚠ Common exam trap
The trap here is assuming swap is enabled like a normal filesystem with mount, when the kernel uses the dedicated swapon mechanism.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Run swapon /swapfile and add the line '/swapfile none swap sw 0 0' to /etc/fstab.
A swap file is activated in the running system with swapon and made persistent by adding an fstab entry whose filesystem type is swap and whose dump and pass fields are both zero. Using mount instead of swapon, inventing a mkswap activation flag, or supplying a nonzero pass field all fail to produce a correctly activated and persistent swap area.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Run swapon /swapfile and add the line '/swapfile none swap sw 0 0' to /etc/fstab.
Why this is correct
swapon /swapfile activates the swap area immediately for the running system, and the /etc/fstab entry with filesystem type swap and options sw ensures the kernel enables it during boot. Both steps are necessary: without swapon it is inactive now, and without the fstab line it is lost after reboot. This matches the persistence requirement.
- ✗
Run swapon /swapfile and add the line '/swapfile none swap defaults,nofail 0 2' to /etc/fstab.
Why it's wrong here
The activation command is correct, but the fstab dump and pass fields are wrong for swap: swap entries must use 0 0, and 'nofail' is valid but the trailing '2' makes fsck attempt to check a swap file, which is nonsensical. The fs_passno for swap must be zero, so this line is malformed and would generate boot warnings.
- ✗
Run mount /swapfile and add the line '/swapfile none swap sw 0 0' to /etc/fstab.
Why it's wrong here
mount is for regular filesystems, not swap areas; the kernel enables swap only via the swapon syscall. Running mount on /swapfile would fail or treat it as a filesystem image, leaving swap disabled. The fstab line is correct, but the immediate activation step is fundamentally the wrong tool.
- ✗
Run mkswap --activate /swapfile and add the line '/swapfile swap swap sw 0 0' to /etc/fstab.
Why it's wrong here
mkswap has no --activate option; activation is done with swapon. Although the fstab line format is plausible, the command to enable swap now is invalid, so the swap area remains inactive in the current session. The scenario already ran mkswap, so this option merely duplicates formatting and fails to activate.
Go deeper
Related to this question
About these practice questions
Courseiva writes every LFCS question from scratch — 406 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Linux Foundation exam blueprint
This LFCS practice question is part of Courseiva's free Linux Foundation certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LFCS exam.