6

I see a number of explanations referring to resizing swap partitions; however, I cannot find one that explains how to "resize" an existing swap file.

My existing /swapfile1 is 512 MB.

I want to increase it to 1 GB.

Is it simpler to create a new swap file and delete this one following instructions here How to increase swap space on RHEL7

adam
  • 161

1 Answers1

8

Actually yes, it's simpler to delete the swap file and create a new one.

  1. Deactivate the swap

    swapoff /swapfile1
    
  2. Delete the swap file and create a new one

    rm -f /swapfile1 && dd if=/dev/zero of=/swapfile1 bs=1024 count=1024000 
    
  3. Set up the swap file

    mkswap /swapfile1
    
  4. Reactivate the swap

    swapon /swapfile1
    
dr_
  • 29,602