How to add a swap partition to CentOS6.5

Source: Internet
Author: User

When adding Zabbix monitoring to the server, it was found that the server had an error "Lack of free swap space on localhost", by looking to know that when installing the server forgot to divide the swap partition. To reduce the error, now directly divide the swap partition, the following steps:


1, create a swap partition with the DD command

[[email protected] home]# dd If=/dev/zero of=/home/swap bs=1024 count=81920008192000+0 Records in8192000+0 Records out838 8608000 bytes (8.4 GB) copied, 33.5006 s, MB/s

This creates a/home/swap file with a partition size of 8G and then formats the partition file.


2. Format the/home/swap file.

[Email protected] home]# mkswap/home/swap mkswap:/home/swap:warning:don ' t erase bootbits sectors on whole disk . Use-f to force. Setting up Swapspace version 1, size = 8191996 kibno label, UUID=4AE031DD-EEFE-43BA-8FB0-C09719D896B6


Span style= "line-height:0px;" > 3, swapon with/home/command Swap files divided into swap partitions

[[email protected] home]# swapon /home/swap [[email protected] home]#  free -m             total        used       free      shared    buffers     cachedmem:           7872       7730         142          0          70       6394-/+ buffers/cache:        1264       6608Swap:          7999          0        7999 


4. Modify the /etc/fstab file to add/home/swap swap default 00, which can be mounted automatically even if restarted.

[[Email protected] home]# vi /etc/fstab ## /etc/fstab# created by  anaconda on tue jan 26 21:10:02 2016## accessible filesystems,  by reference, are maintained under  '/dev/disk ' # see man pages  fstab (5),  findfs (8),  mount (8)  and/or blkid (8)  for more info#uuid= f8cb78d5-8419-4bcf-8684-9e8a94480f22 /                        ext4    defaults         1 1uuid=9e4bacd3-490c-4e87-a5e0-fec240a3e229 /usr                      xfs     defaults        1  2tmpfs                   /dev/shm                 tmpfs    defaults        0 0devpts                   /dev/pts                 devpts  gid=5,mode=620   0 0sysfs                    /sys                     sysfs   defaults         0 0proc                     /proc                    proc    defaults        0 0  /home/swap             swap                     swap     default         0 0 "/etc/fstab"  16l, 788c written




Note: Calculation formula for count: count=size*1024 (SIZE in megabytes)

This article is from the "Breght Moon" blog, make sure to keep this source http://liqingbiao.blog.51cto.com/3044896/1740320

How to add a swap partition to CentOS6.5

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.