How to create a swap file

Source: Internet
Author: User

From the installation of the system has been exposed to this swap, the front also said it is similar to Windows virtual memory, partition when the general size of memory twice times, if your memory more than 4G, then you divide 8G seems to be unnecessary. 4 G is enough for daily exchange. However, there is also a case where virtual memory is not enough. If you do, do you want to re-split the disk? Of course not! Then we'll add a virtual disk.

The basic idea is to create a swapfile, format the swap format, and enable the virtual disk

#dd If=/dev/zero of=/tmp/newdisk bs=40k count=102400

Using DD to create a 4G file/tmp/newdisk out, where if represents the file from which to read,/dev/zero is a Linux-specific 0 generator, of which the output to which file, BS is the block size, count defines how many blocks.


Mkswap This command is specially formatted for the swap format of the partition

#swapon/tmp/newdisk enable the virtual disk

Using the free command to view system memory and virtual memory usage, the-M option is viewed as M. You can see the current system. And Swapon is to enable our new swap file, enable and then use the free view found more than 400M.


We can also close the enabled swap file with Swapoff.

Easy to use, artifact Ah

How to create a swap file

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: 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.