Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
mkswap writes a swap signature (with a UUID and optional label). Then swapon switches it on. For a swap file, the file must exist first, be owned by root with mode 600, and have no holes.
Zo schrijf je het
mkswap [OPTION]... DEVICE [SIZE]Opties 14
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met sudo)
1Swap on a partition
mkswap /dev/vdb2 Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes) no label, UUID=8f1b2c3d-…Then
swapon /dev/vdb2.2With a label
mkswap -L swap2 /dev/vdb2fstab can use LABEL=swap2.
3Swap on a logical volume
lvcreate -n lvswap -L 2G rhel mkswap /dev/rhel/lvswapEasy to grow later.
4A swap file
1 GiB file without holes.
5Create the swap file in one step (newer util-linux)
mkswap -F -s 1G /swapfileMakes the file with the right mode.
6Use it and make it permanent
Check with
swapon --show.7Get the UUID for fstab
blkid -s UUID -o value /dev/vdb2Use UUID= in fstab, not the device name.
8Change the swap label later
swaplabel -L swap2 /dev/vdb2Without recreating.
9Check for bad blocks first
mkswap -c /dev/vdb2Slower; for old disks.
10Overwrite a device that looks in use
mkswap -f /dev/vdb2Only when you are sure.
Niets past bij dit filter.
Let op
- mkswap deletes the old content of the device.
- A swap file with mode other than 600 lets users read memory pages: security risk.
Exitcodes
0 | Done. |
1 | Error. |