Initialize the empty LV /dev/vgdata/lvswap as swap.
Enable it in a later step.
Which command is appropriate?
mkswap creates swap metadata. swapon is the separate operation that enables the initialized area.
Detailed explanation
swapon /dev/vgdata/lvswapIncorrect. swapon enables an already initialized swap area.
Incorrect. swapon enables an already initialized swap area.
mkfs.ext4 /dev/vgdata/lvswapIncorrect. This creates an ext4 filesystem instead of swap.
Incorrect. This creates an ext4 filesystem instead of swap.
mount /dev/vgdata/lvswap /swapIncorrect. Swap is not normally mounted as a regular filesystem.
Incorrect. Swap is not normally mounted as a regular filesystem.
mkswap /dev/vgdata/lvswapCorrect. mkswap initializes the target as swap.
Correct. mkswap initializes the target as swap.
Try it yourself
An example you can run in a temporary verification environment.
mkswap --help | sed -n '1,12p'Expected result
swap areaを設定するmkswapの使用法Key points
- mkswap initializes
- swapon enables
- Swap is not normally mounted
Notes
- Environment: util-linux mkswap / ヘルプ表示のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.