Skip to main content
added 113 characters in body
Source Link
Chris Davies
  • 128.4k
  • 16
  • 179
  • 324

1. Without systemd

You can disable swap with swapoff -a. If swap is being used it is not an instantaneous action (see man swapoff).

If you have defined swap in /etc/fstab you can use swapon -a to activate all known swap files and partitions. If none is defined there you need to declare the swap space that you want to use, for example swapon /var/swap.

There is no need to recreate it each time you want to use it

2. With systemd

The new method for activating swap is through a systemd service, run at boot. You can see its status, for example,

systemctl status dphys-swapfile     # What happened last time it ran
systemctl restart dphys-swapfile    # Recompute the swapfile space and reactivate it

In turn, systemd calls the dphys-swapfile command (see man dphys-swapfile), which computes a reasonably sized swapfile partition and activates it, or deactivates it, as required.

For example,

dphys-swapfile swapoff    # Stop using the swapfile
dphys-swapfile setup      # (Re-)compute an optimal swap space as /var/swap
dphys-swapfile swapon     # Start using the computed swapfile

In the systemd and dphys-swapfile world, swapspace defaults to the file /var/swap rather than a partition

1. Without systemd

You can disable swap with swapoff -a. If swap is being used it is not an instantaneous action (see man swapoff).

If you have defined swap in /etc/fstab you can use swapon -a to activate all known swap files and partitions. If none is defined there you need to declare the swap space that you want to use, for example swapon /var/swap.

There is no need to recreate it each time you want to use it

2. With systemd

The new method for activating swap is through a systemd service, run at boot. You can see its status, for example,

systemctl status dphys-swapfile     # What happened last time it ran
systemctl restart dphys-swapfile    # Recompute the swapfile space and reactivate it

In turn, systemd calls the dphys-swapfile command (see man dphys-swapfile), which computes a reasonably sized swapfile partition and activates it, or deactivates it, as required.

For example,

dphys-swapfile swapoff    # Stop using the swapfile
dphys-swapfile setup      # (Re-)compute an optimal swap space as /var/swap
dphys-swapfile swapon     # Start using the computed swapfile

1. Without systemd

You can disable swap with swapoff -a. If swap is being used it is not an instantaneous action (see man swapoff).

If you have defined swap in /etc/fstab you can use swapon -a to activate all known swap files and partitions. If none is defined there you need to declare the swap space that you want to use, for example swapon /var/swap.

There is no need to recreate it each time you want to use it

2. With systemd

The new method for activating swap is through a systemd service, run at boot. You can see its status, for example,

systemctl status dphys-swapfile     # What happened last time it ran
systemctl restart dphys-swapfile    # Recompute the swapfile space and reactivate it

In turn, systemd calls the dphys-swapfile command (see man dphys-swapfile), which computes a reasonably sized swapfile partition and activates it, or deactivates it, as required.

For example,

dphys-swapfile swapoff    # Stop using the swapfile
dphys-swapfile setup      # (Re-)compute an optimal swap space as /var/swap
dphys-swapfile swapon     # Start using the computed swapfile

In the systemd and dphys-swapfile world, swapspace defaults to the file /var/swap rather than a partition

Include reference to the systemd way of doing things
Source Link
Chris Davies
  • 128.4k
  • 16
  • 179
  • 324

1. Without systemd

You can surnamedisable swap with swapoff -a. If swap is being used it is not an instantaneous action (see man swapoff).

If you have defined swap in /etc/fstab you can use swapon -a to activate all known swap files and partitions. If none is defined there - which is the normal situation for a systemd system - you need to declare the swap space that you want to use, for example swapon /var/swap.

There is no need to recreate it each time you want to use it

2. With systemd

The new method for activating swap is through a systemd service, run at boot. You can see its status, for example,

systemctl status dphys-swapfile     # What happened last time it ran
systemctl restart dphys-swapfile    # Recompute the swapfile space and reactivate it

In turn, systemd calls the dphys-swapfile command (see man dphys-swapfile), which computes a reasonably sized swapfile partition and activates it, or deactivates it, as required.

For example,

dphys-swapfile swapoff    # Stop using the swapfile
dphys-swapfile setup      # (Re-)compute an optimal swap space as /var/swap
dphys-swapfile swapon     # Start using the computed swapfile

You can surname swap with swapoff -a. If swap is being used it is not an instantaneous action.

If you have defined swap in /etc/fstab you can use swapon -a to activate all known swap files and partitions. If none is defined there - which is the normal situation for a systemd system - you need to declare the swap space that you want to use, swapon /var/swap.

There is no need to recreate it each time you want to use it

1. Without systemd

You can disable swap with swapoff -a. If swap is being used it is not an instantaneous action (see man swapoff).

If you have defined swap in /etc/fstab you can use swapon -a to activate all known swap files and partitions. If none is defined there you need to declare the swap space that you want to use, for example swapon /var/swap.

There is no need to recreate it each time you want to use it

2. With systemd

The new method for activating swap is through a systemd service, run at boot. You can see its status, for example,

systemctl status dphys-swapfile     # What happened last time it ran
systemctl restart dphys-swapfile    # Recompute the swapfile space and reactivate it

In turn, systemd calls the dphys-swapfile command (see man dphys-swapfile), which computes a reasonably sized swapfile partition and activates it, or deactivates it, as required.

For example,

dphys-swapfile swapoff    # Stop using the swapfile
dphys-swapfile setup      # (Re-)compute an optimal swap space as /var/swap
dphys-swapfile swapon     # Start using the computed swapfile
Source Link
Chris Davies
  • 128.4k
  • 16
  • 179
  • 324

You can surname swap with swapoff -a. If swap is being used it is not an instantaneous action.

If you have defined swap in /etc/fstab you can use swapon -a to activate all known swap files and partitions. If none is defined there - which is the normal situation for a systemd system - you need to declare the swap space that you want to use, swapon /var/swap.

There is no need to recreate it each time you want to use it