Adding swap space in Linux

Source: Internet
Author: User
Linux has added swap space-Linux Enterprise Application-Linux server application information. For details, refer to the following section. Today, I suddenly found that the proxy server is unavailable. I went up and checked the squid port to Stop listening and view the log. The following error occurs:

Localhost kernel: Out of Memory: Killed process 785 (squid ).

There was no valuable result when google made a pass on the Internet. Let's look at it for another reason. Is the linux swap used up? The memory is not enough, so it's a big shock, there is only 8 M swap space. I guess I did not accidentally make a mistake!

It is impossible to add a swap partition, and the disk space has already been allocated. Add the swap file.

Generate M file

# Dd if =/dev/zero of = swapfile bs = 1024 count = 1317000

Create as a swap file

# Mkswap swapfile

Make swap effective

# Swapon swapfile

View swap

# Swapon-s

Filename Type Size Used Priority

/Dev/sda3 partition 8024 2504-3

/Var/swapfile file 1316992 0-4

Added to the fstab file to enable automatic startup during system boot.

# Vi/etc/fstab

/Var/swapfile swap defaults 0 0

Start squid and run the top command.

Swap: 1325016 K av, 2504 K used, 1322512 K free

# Netstat-ln

Tcp 0 0 202. xxx: 3128 0.0.0.0: * LISTEN

Success!

The process is simple, but I made such a big mistake when installing the system.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.