Linux to increase the virtual memory

Create a swap partition

Background: The use is lowest with Ali cloud version of the server, using the docker to build micro-related service application, start the application before the discovery is always inexplicable was killed. Since this hung up, um, really press the gourd dipper underway ah. Finally, use the free command looked at memory usage. . Themselves scared. Memory is quickly exhausted, and swap is 0, and the windows of thinking about whether this is a pagefile mean, this is it in linux default is 0, not enabled. I do not know, but the swap file next step how to create the first record of it.

1. Create a file to a swap partition: 1GB swap partition size increases, the command written as follows, where the count is equal to a desired number of blocks (bs * count = file size).

# dd if=/dev/zero of=/root/swapfile bs=1M count=1024

2. formatted as a swap file:

# mkswap /root/swapfile #建立swap的文件系统

2.1 modify the file permissions

chmod 775 swapfile #修改权限

3. Enable the swap file:

# swapon /root/swapfile #启用swap文件

4. Enable the system to boot from the added line in the file / etc / fstab of:

/root/swapfile swap swap defaults 0 0

Screenshot after the opening as follows:
blob.jpg

New and used swap increased command is: mkswap, swapon, etc., and want to close it off with a swap "swapon / dev / sdb2" such an order can be

Guess you like

Origin www.cnblogs.com/falcon-fei/p/11060149.html
Recommended