While seeing the manual for swapon command the priorty option is described as

  -p, --priority priority
              Specify the priority of the swap device.  priority is a value
              between -1 and 32767.  Higher numbers indicate higher
              priority.  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.  When no priority is defined, it
              defaults to -1.

Can someone explain what does priority of swap means. What does higher value and lower value of ths setting affect the system and what should be the optimal value for this in home computer? Edit: The man page for swapon(2) shows

They may have any non-negative value chosen by the caller

But in my system(debian 10 testing) the default priority value is -1


1 Answer 1


man 2 swapon describes priorities thus:

Each swap area has a priority, either high or low. The default priority is low. Within the low-priority areas, newer areas are even lower priority than older areas.

All priorities set with swapflags are high-priority, higher than default. They may have any nonnegative value chosen by the caller. Higher numbers mean higher priority.

Swap pages are allocated from areas in priority order, highest priority first. For areas with different priorities, a higher-priority area is exhausted before using a lower-priority area. If two or more areas have the same priority, and it is the highest priority available, pages are allocated on a round-robin basis between them.

The sentence you highlighted can’t be taken out of its context; it concerns high priorities, which the default priorities aren’t.

Swap priority only matters if you have multiple swap devices and a reason to prefer some of them to others. If you have a single swap device, it won’t make any difference. If you have multiple swap devices on separate disks, it can be worth changing the priorities so that they are used equally; otherwise, the first device added will be used, then the second device, and so on.

  • Context is in a separate man page in this case...
    – ricab
    May 4, 2023 at 10:02
  • @ricab what do you mean? The OP highlighted “They may have any non-negative value chosen by the caller”, quoting from man 2 swapon; the context I quote is from the same man page. May 4, 2023 at 10:48
  • Ah I see, I thought you meant the other quote - the one from man 8 swapon - but I realise that is not just one sentence. The man page for the command does not distinguish between priorities above or below -1. A little more context in that one would have been nice.
    – ricab
    May 10, 2023 at 16:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .