Resize Swap Partition in Ubuntu

To adjust the size of the swap partition on Ubuntu, you need to follow these steps:

  1. Make sure you have enough available space to adjust the size of the swap partition. You can use the command free -h to check the current swap usage and available space.
  2. Disable the swap partition: Firstly, you need to disable the swap partition. You can do this by using the command sudo swapoff -a.
  3. Remove the old swap partition: You need to delete the old swap partition. You can use partition tools like GParted or fdisk to delete the swap partition.
  4. Create a new swap partition: You can use partitioning tools like GParted or fdisk to create a new swap partition. Make sure to set the partition type as swap.
  5. Format the new swap partition: format the new swap partition using the command sudo mkswap /dev/sdX (replace /dev/sdX with your new swap partition).
  6. Enable the new swap partition: Use the command sudo swapon /dev/sdX to enable the new swap partition.
  7. Update the fstab file: You must update the /etc/fstab file so that the system can automatically mount the new swap partition at startup. Make sure to add the entry for the new swap partition in the fstab file.

After completing the above steps, the size of the swap partition on your Ubuntu system will be adjusted to the new size.

bannerAds