Creating a swap partition

To perform this procedure, you need:
  • A host with one or more local disks, with at least one unused primary partition.
  • The password of the root account on the host or a user that is a member of the wheel group.
Perform this procedure to configure a primary partition on a local disk as swap space. Typically, configuring one swap partition or swap file on each local disk maximizes swap space performance.
  1. Log in to the target host as root, or as a user with superuser privileges.
  2. Identify one or more primary partitions for use as swap space.
    lsblk -p --output=NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT
  3. Create and enable swap space on each target primary partition.
    1. Disable swapping on all swap devices.
      swapoff -a
    2. Create swap space.
      Repeat the following command for each primary partition to use as swap space.
      Replace Device with the path of a primary partition:
      mkswap Device
    3. Update the file system table.
      Repeat the following command for each swap partition created in the previous substep.
      Replace Device with the path of a swap partition:
      echo "Device  swap  swap  defaults  0  0" >> /etc/fstab
    4. Enable swapping on all swap devices.
      swapon -a