Prepare the empty test partition /dev/sdb2 as Linux swap.
Create the header only; do not activate swap yet.
Which command is appropriate?
mkswap DEVICE initializes swap metadata. Activation is a separate step using swapon or an /etc/fstab entry.
Detailed explanation
swapon /dev/sdb2Incorrect. swapon activates an already initialized swap area.
Incorrect. swapon activates an already initialized swap area.
mkfs.swap /dev/sdb2Incorrect. mkfs.swap is not the standard command.
Incorrect. mkfs.swap is not the standard command.
mkfs.ext4 /dev/sdb2Incorrect. mkfs.ext4 creates a filesystem rather than swap.
Incorrect. mkfs.ext4 creates a filesystem rather than swap.
mkswap /dev/sdb2Correct. mkswap /dev/sdb2 creates the swap header without activating it.
Correct. mkswap /dev/sdb2 creates the swap header without activating it.
Try it yourself
An example you can run in a temporary verification environment.
mkswap --helpExpected result
swap領域作成の使用法。デバイス変更は行わないKey points
- mkswap initializes
- swapon activates
- A device or file can be used
Notes
- Environment: util-linux mkswap 2.39以降
- 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.