How to set swap priority?

To set the swap priority in Linux, you can use the swapon command with the -p option. The priority determines the order in which swap spaces are used; lower numbers indicate higher priority.

Steps to Set Swap Priority:

  1. Identify Swap Devices: First, check your current swap devices using:

    swapon --show
    
  2. Turn Off Swap: If you need to change the priority of an active swap device, turn it off:

    sudo swapoff /dev/sdX
    

    Replace /dev/sdX with your swap device.

  3. Set Swap Priority: Use the swapon command to set the priority:

    sudo swapon -p <priority> /dev/sdX
    

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

  4. Verify Changes: Check the swap priorities again:

    swapon --show
    

Example:

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

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

Feel free to ask if you need more information!

0 Comments

no data
Be the first to share your comment!