Creating a Swap Partition
-
Create the swap partition by using either fdisk or parted.
-
If using fdisk, create the partition as discussed in Creating Partitions. Then use t to change the partition type from the default to
82 Linux swap / So
. -
If using parted, specify
linux-swap
at theFile system type?
prompt as shown in Partitioning Disks by Using parted.
-
-
Initialize the partition as a swap partition.
For example, if the partition is
/dev/sda2
, use the following command:sudo mkswap /dev/sda2
-
Enable swapping to the swap partition.
sudo swapon /dev/sda2
-
Add an entry to
/etc/fstab
for the swap partition so that the system uses it following the next reboot, for example:/dev/sda2 swap swap defaults 0 0