How to make swap priority permanent?

To make swap priority permanent in Linux, you need to edit the /etc/fstab file, which is used to configure filesystems and swap devices at boot time. Here’s how to do it:

Steps to Make Swap Priority Permanent:

  1. Open /etc/fstab: Use a text editor with superuser privileges to edit the file. For example, using nano:

    sudo nano /etc/fstab
  2. Locate the Swap Entry: Find the line that corresponds to your swap device. It will look something like this:

    /dev/sdX none swap sw 0 0
  3. Add Priority Option: Modify the line to include the pri=<priority> option. For example, to set the priority to 10:

    /dev/sdX none swap sw,pri=10 0 0
  4. Save and Exit: Save the changes and exit the text editor (in nano, you can do this by pressing CTRL + X, then Y, and Enter).

  5. Reboot or Remount: You can either reboot your system or remount the swap to apply the changes:

    sudo swapoff -a
    sudo swapon -a
  6. Verify Changes: Check the swap priorities again to confirm that the changes are permanent:

    swapon --show

Example Entry:

If your swap device is /dev/sda2 and you want to set its priority to 10, the entry in /etc/fstab would look like:

/dev/sda2 none swap sw,pri=10 0 0

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!