Resize Linux Swap Partition: Simple Guide
To adjust the size of the swap partition in a Linux system, you can follow these steps:
- Disable the swap partition by using the “sudo swapoff -a” command.
- Use the command ‘sudo fdisk -l’ to check the current partition status of the system and locate the device name for the swap partition (usually represented in the form of /dev/sdXN, where X is the hard drive number and N is the partition number).
- Use the command “sudo mkswap /dev/sdXN” to format a swap partition as a swap file system.
- Re-enable the swap partition by using the command “sudo swapon /dev/sdXN”.
- Open the fstab file using the command ‘sudo vi /etc/fstab’, edit the file, and update the UUID or device name of the swap partition to the new swap partition.
- Save and exit the fstab file.
- Restart the system to verify if the size of the swap partition has been successfully adjusted.
Please note that before performing the above operations, it is important to backup important data and ensure that you have sufficient understanding and experience in operating Linux systems.