Linux Swap partition creation and management

Source: Internet
Author: User

Swap partition creation and management 1. View Swap partitions
[[email protected] ~]# free -h                         total       used       free     shared    buffers     cachedMem:          2.0G       1.0G       944M       1.5M       265M       341M-/+ buffers/cache:       454M       1.5GSwap:         4.0G         0B       4.0G           #swap分区大小[[email protected] ~]# fdisk -lDisk /dev/sda: 53.7 GB, 53687091200 bytes255 heads, 63 sectors/track, 6527 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0004c723     Device Boot      Start         End      Blocks   Id  System/dev/sda1   *           1          26      204800   83  LinuxPartition 1 does not end on cylinder boundary./dev/sda2              26         548     4194304   82  Linux swap / Solaris   #swap挂载地方Partition 2 does not end on cylinder boundary./dev/sda3             548        6528    48028672   83  Linux
2. Turn off swap
[[email protected] ~]# swapoff /dev/sda2[[email protected] ~]# free -h                         total       used       free     shared    buffers     cachedMem:          2.0G       1.1G       923M       1.5M       265M       341M-/+ buffers/cache:       475M       1.5GSwap:           0B         0B         0B[[email protected] ~]# swapon /dev/sda2 [[email protected] ~]# free -h                         total       used       free     shared    buffers     cachedMem:          2.0G       1.0G       944M       1.5M       265M       341M-/+ buffers/cache:       455M       1.5GSwap:         4.0G         0B       4.0G
3.swap Partition expansion
[[email protected] ~]# dd if=/dev/zero of=/opt/swapfile bs=1M count=1024      #创建一个swap分区1024+0 records in1024+0 records out1073741824 bytes (1.1 GB) copied, 19.2751 s, 55.7 MB/s[[email protected] ~]# mkswap /opt/swapfile                #格式化成swap格式mkswap: /opt/swapfile: warning: don‘t erase bootbits sectors                on whole disk. Use -f to force.Setting up swapspace version 1, size = 1048572 KiBno label, UUID=565ba456-ae47-4749-a7f7-1cd26f37bdbd[[email protected] ~]# swapon /opt/swapfile               #启用该swap分区,并会自动合并到原来的swap分区上[[email protected] ~]# free -h                         total       used       free     shared    buffers     cachedMem:          2.0G       1.9G       101M       1.5M       264M       1.1G-/+ buffers/cache:       466M       1.5GSwap:         5.0G         0B       5.0G

Linux Swap partition creation and management

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.