Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
swapon DEVICE activates a swap partition, LV or file; swapon -a activates all swap lines from /etc/fstab. swapon --show lists active swap spaces with size, use and priority. swapoff moves the pages back to RAM and turns swap off — it needs enough free memory.
Zo schrijf je het
swapon [OPTION]... [DEVICE]...
swapon --show
swapoff [-va] [DEVICE]...Opties 18
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met sudo)
1Switch on a swap partition
swapon /dev/vdb2Active until reboot.
2Show active swap
swapon --show NAME TYPE SIZE USED PRIO /dev/dm-1 partition 2G 0B -2 /dev/vdb2 partition 1G 0B -3Lower PRIO is used later.
3Switch on everything from fstab
swapon -aTests your fstab swap lines.
4Turn swap off
swapoff /dev/vdb2Needs enough free RAM.
5Turn all swap off and on (empty it)
swapoff -a && swapon -aMoves swapped pages back to RAM. Check
free -hfirst.6Use a fast disk first
swapon -p 10 /dev/nvme0n1p3Higher priority = used first.
7Priority in fstab
grep swap /etc/fstab UUID=8f1b… none swap defaults,pri=10 0 0Kept after reboot.
8By UUID or label
swapon -U 8f1b2c3d-…; swapon -L swap2Without the device name.
9Discard on SSD
swapon -d /dev/nvme0n1p3Frees unused blocks on the SSD.
10Check the kernel view
cat /proc/swapsSame data as swapon -s.
Niets past bij dit filter.
Bestanden
/etc/fstab- Swap lines (type swap).
/proc/swaps- Active swap spaces.
Exitcodes
0 | Done. |
1 | Error. |
2 | Some swap spaces failed (with -a). |