Set up permanent swap swap space under Ubuntu System (reprint)

Source: Internet
Author: User

Http://blog.sina.com.cn/s/blog_6e4388910100tsk7.html

Swap is generally in a proprietary swap area, which may be because you are prompted to create a swap area when you install it . But virtually any file can be used as a swap ( swap device ), either as a partition or as a simple file. However, in order to better experience the effect and speed of induction, it is recommended to use a large amount of memory instead of relying on swap. You can add a swap file to increase the swap

A total of four steps

1) Create a file of your pre-set size.

2) format the file as swap ( swap device ).

3) Add the swap to the existing system.

4) make a permanent change in the system.

 

Example: To add a 512M swap

Create a 512M file

We will create a swap file on the/mnt/512mb.swap .

sudo dd if=/dev/zero of=/mnt/512mb.swap bs=1m count=512

The count=512 in the code means that we are going to create a file that contains a bs=1m (bs = block size chunk ; 1M=1mebibyte one megabyte =1048576 bytes bytes ) of the chunk. Be careful not to use the dd of=/mnt/512mb.swap bs=1m seek=512 count=0 this command. Although the file will grow to 512Mb immediately, it is vulnerable and may be unusable.

 

Format the file so that it becomes swap ( swap device ):

sudo mkswap/mnt/512mb.swap

Immediately activate swap to the existing system :

sudo swapon/mnt/512mb.swap

Now the new swap can be seen through the "cat/proc/meminfo" command.

Make a permanent change :

 

Edit /etc/fstab file :

Gksudo Gedit/etc/fstab

 

Add the following line to the end of the file :

/mnt/512mb.swap None swap SW 0 0

 

Save and restart.

Set up permanent swap swap space under Ubuntu System (reprint)

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.