LPIC-2 Exam 201 (Linux Engineer) — Question 40
Due to extreme system use, a Linux system requires some additional swap space. To initialize 5 GB of additional swap space, which combination of commands should be used?
Answer options
- A. dd if=/dev/zero of=/tmp/swapfile bs=1024 count=5120000; mkswap /tmp/swapfile; mount /tmp/swapfile
- B. dd if=/dev/zero of=/tmp/swapfile bs=1024 count=5120000; swapon /tmp/swapfile
- C. dd if=/dev/zero of=/tmp/swapfile bs=1024 count=5120000; mkswap /tmp/swapfile; swapon /tmp/swapfile
- D. touch -5G /tmp/swapfile; swapon /tmp/swapfile
- E. mkswap /tmp/swapfile 512000; swapon /tmp/swapfile
Correct answer: C
Explanation
The correct answer, C, properly creates a swap file, initializes it with mkswap, and then activates it with swapon. Option A incorrectly attempts to mount the swap file instead of activating it. Option B skips the initialization step with mkswap, rendering the swap space unusable. Option D incorrectly uses the touch command, which does not create a valid swap file, and option E does not allocate sufficient space for 5 GB.