How to change swap priority?

To change the swap priority of a swap device in Linux, follow these steps:

Steps to Change Swap Priority:

  1. Identify Current Swap Devices: Check your current swap devices and their priorities using:

    swapon --show
    
  2. Turn Off the Swap Device: If the swap device is currently active, you need to turn it off:

    sudo swapoff /dev/sdX
    

    Replace /dev/sdX with the actual swap device (e.g., /dev/sda2).

  3. Turn On the Swap Device with New Priority: Use the swapon command to turn it back on with the desired priority:

    sudo swapon -p <new_priority> /dev/sdX
    

    Replace <new_priority> with the desired priority value and /dev/sdX with your swap device.

  4. Verify the Changes: Check the swap priorities again to confirm the change:

    swapon --show
    

Example:

To change the priority of /dev/sda2 to 10:

sudo swapoff /dev/sda2
sudo swapon -p 10 /dev/sda2

If you have any more questions or need further assistance, feel free to ask!

0 Comments

no data
Be the first to share your comment!