how to decrease the Priority to 1 in place of 2 as described below?

   swapon -s
   Filename                                Type            Size    Used    Priority
   dev/cciss/c0d0p6                       partition       8385888 0       -2
  • Why would you want to do that? – coredump Mar 12 '11 at 23:20
  • the other linux machine have one and not two – klod Mar 13 '11 at 0:07

You can use -p on swapon, as said in the man page.

  -p, --priority priority
              Specify the priority of the swap device.  priority is a value between 0 and 32767. Higher numbers indicate higher  prior‐
              ity.  See  swapon(2)  for  a full description of swap priorities. Add pri=value to the option field of /etc/fstab for use
              with swapon -a.

But you only have priority if you have more than one swap space. The first space gets -1, the second -2, and so on. It makes little sense to have multiple swap spaces at the same priority (unless you want to make a round-robin allocation of swap space), just make sure to put your faster space as the lowest priority.


The priority you are seeing is negative. If you do not specify a priority, the first swap device you add since boot has priority -1. The second swap device you add since boot has priority -2, and so on (see the enable_swap_info function in the Linux kernel). So the priority being -2 only means this is the second time since you booted that server that you added a swap device without explicitly specifying a priority. If you specified a priority, it would be non-negative.

The only thing this priority affects is the order in which swap devices are used (higher priority devices are searched first). If you only have one swap device, it does not make any difference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.