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:
-
Open
/etc/fstab: Use a text editor with superuser privileges to edit the file. For example, usingnano:sudo nano /etc/fstab -
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 -
Add Priority Option: Modify the line to include the
pri=<priority>option. For example, to set the priority to10:/dev/sdX none swap sw,pri=10 0 0 -
Save and Exit: Save the changes and exit the text editor (in
nano, you can do this by pressingCTRL + X, thenY, andEnter). -
Reboot or Remount: You can either reboot your system or remount the swap to apply the changes:
sudo swapoff -a sudo swapon -a -
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!
