Linux set swap swap partition steps

  
                

Many people do not understand the swap swap partition of Linux, do not know what is the swap swap partition, the following small series will give you a simple introduction to what is the swap partition and swap partition settings, want to set the swap partition Friends may wish to understand.

First, what is the swap partition

swap but seen as part of memory, but it's carved out from the hard disk, it's like virtual memory in windows, it The role is to cache data, when it is divided, the size is set to twice the size of your physical memory.

Second, set the swap swap partition

Recommended rules for the size of the swap partition

When the memory is less than 4GB, it is recommended to be no less than 2GB of swap space;

Memory 4GB~16GB, recommended not less than 4GB swap space;

Memory 16GB~64GB, recommended not less than 8GB swap space;

Memory 64GB~256GB, recommended not less than 16GB of swap space.

1. Log in to SSH as root and type the following command to create a 512M swap file (1024 * 512MB = 524288).

dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

2, create a Linux swap file

mkswap /swapfile1

3. Activate the /swapfile1 swap file immediately.

swapon /swapfile1

4. Set the system to activate the swap file. Edit the /etc/fstab file and add the second line of code below.

vi /etc/fstab

/swapfile1 swap swap defaults 0 0

5. Restart the system and use free -m to view the swap size.

Third, the Linux view of the swap command

You can use the "ld /cat /proc /swaps & rdquo;, "swapon - s" and "free" and other orders to view the Swap partition.

[root@jay-linux ~]# swapon -s

Filename Type Size Used Priority

/dev/sda3 partition 2096120 840 -1

[root@jay-linux ~]# cat /proc/swaps

Filename Type Size Used Priority

/dev/sda3 partition 2096120 840 -1

[root@jay -linux ~]# free -m

total used free shared buffers cached

Mem: 7872 7280 592 0 429 5964

-/+ buffers/cache: 886 6986< Br>

Swap: 2046 0 2046

According to the above example, I should actually allocate 4GB of Swap space, here is 2GB (may not meet Redhat's recommended value, because this machine uses memory The amount is not too big, almost no use of Swap). Previous123Next page Total 3 pages

Copyright © Windows knowledge All Rights Reserved