Swap files without swap partitioning

Source: Internet
Author: User
Article title: swap files without swap partitioning. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
When installing linux, the system generally requires dividing a partition as a swap partition. However, the computer memory is usually very large, and there will be fewer and fewer opportunities for system file exchange. For me, I have installed redhat linux V7.3 with a memory of 256 MB. when running the system, I cat/proc/swaps, but I have not used swap partitions, therefore, we recommend that you only create swap files when the memory is relatively large.

In the redhat linux V7.3 system, there are two ways to create a swap file. The easiest way is not to create a swap partition during installation. during the second installation, a message is prompted to create a swap file, you only need to input xxxM memory.

However, I suggest another method that is cumbersome. if you are interested, take a look.

1. log on to the system (I am not talking about this. how can I do this without going in)
2. create a file with any name. However, we generally call it SWAP. Place the file wherever it is. now suppose it is placed in/. The size is any value and set it to 256 M. The method for creating this file is as follows:

Dd if =/dev/zero of =/SWAP bs = 1024 count = 262144

(256 M = 256*1024 * bs)

3. sync. Write the file back to the disk.
4. mkswap/SWAP. Use SWAP as the SWAP file.
5. swapon/SWAP. Activate the swap file.
At this point, I believe that the file exchange is already working. Run cat/proc/swaps.

In addition, to change the SWAP file size, you must first swapoff/SWAP and then perform the preceding steps.
Add a/SWAP swap row to/etc/fstab
This ensures that the swap file is activated when the system starts.
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.