Linux command
mkswap 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Example
sudo mkswap /dev/sdXY
Example
sudo mkswap -c /dev/sdXY
Example
sudo mkswap -L swap_label /dev/sdXY
Example
sudo mkswap -U random /dev/sdXY
Example
sudo mkswap -s 4G -F /path/to/swapfile
说明
mkswap sets up a Linux swap area on a device or in a file. The device can be a disk partition or a regular file. After creation, use swapon to enable the swap area.
参数
- -c, --check
- Check the device for bad blocks before creating swap area
- -f, --force
- Force creation even if the device has a detected filesystem
- -L, --label LABEL
- Specify a label for the swap area (for use with swapon -L)
- -p, --pagesize SIZE
- Specify page size in bytes
- -U, --uuid UUID
- Specify UUID (clear, random, time, or specific UUID value)
- -v, --swapversion VERSION
- Specify swap area version (only version 1 supported)
- -e, --endianness ENDIAN
- Specify endianness (native or little)
- -o, --offset OFFSET
- Offset for swap header in device
- -s, --size SIZE
- Size of swap file (with -F)
- -F, --file
- Create swap file instead of setting up existing file
- --verbose
- Print verbose messages
FAQ
What is the mkswap command used for?
mkswap sets up a Linux swap area on a device or in a file. The device can be a disk partition or a regular file. After creation, use swapon to enable the swap area.
How do I run a basic mkswap example?
Run `sudo mkswap /dev/sdXY` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -c, --check do in mkswap?
Check the device for bad blocks before creating swap area