How to set swap priority in Linux

How to set swap priority in Linux? Can I use 2 swap partition at the same time?

asked Jan 24, 2013 by anonymous

1 Answer

 
Best answer

You can set the priority of swap in Linux by swapon.

For example, to set /dev/sdc1's priority to 0:

# swapoff /dev/sdc1; swapon -p 0 /dev/sdc1

You can also put one entry into the /etc/fstab to make it take effect each time Linux reboots:

/dev/sdc1 swap swap pri=0 0 0

You can set 2 swap partions to have the same priority, pages are allocated on a round-robin basis between them.

Priority

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 non-negative
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.

As of Linux 1.3.6, the kernel usually follows these rules, but there
are exceptions.

From swapon manual.

answered Jan 24, 2013 by anonymous
selected Jan 24, 2013 by SA

Please log in or register to answer this question.

Related questions

0 answers
1 answer
asked Jan 24, 2013 by anonymous
1 answer
asked Jan 21, 2013 by anonymous
1 answer
1 answer
1 answer
Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...