What if the swap partition is too small?

Source: Internet
Author: User
Go What to do if the swap partition is too small. [Oracle@flynet mail]$ Su-root
Password:
[Root@flynet ~]# Swapon-s
Filename Type Size Used Priority
/DEV/SDA2 Partition 409648 0-1
[Root@flynet ~]# Df-h
FileSystem Size Used Avail use% mounted on
/dev/sda3 268G 49G 205G 20%/
/DEV/SDA1 99M 13M 81M 14%/boot
None 2.0G 0 2.0G 0%/dev/shm
[Root@flynet ~]# Free-m
Total used free shared buffers Cached
mem:3946 888 3058 0 32 660
-/+ buffers/cache:195 3751
SWAP:400 0 400
First step: Create a new blank file:
[Root@flynet ~]# dd If=/dev/zero of=/var/swapfile bs=1024 count=7979008
7979008+0 Records in
7979008+0 Records out
Step Two: Then format the swap format:
[Root@flynet ~]# Mkswap/var/swapfile
Setting up Swapspace version 1, size = 8170500 KB
Step three: Load the swap file:
[Root@flynet ~]# Swapon/var/swapfile
Fourth Step: Edit/etc/fstab, add the following:
[Root@flynet ~]# Vi/etc/fstab
# this, edited by Fstab-sync-see ' Mans Fstab-sync ' for details
label=//ext3 Defaults 1 1
Label=/boot/boot ext3 Defaults 1 2
None/dev/pts devpts gid=5,mode=620 0 0
NONE/DEV/SHM TMPFS Defaults 0 0
NONE/PROC proc Defaults 0 0
None/sys Sysfs Defaults 0 0
Label=swap-sda2 Swap Defaults 0 0
/var/swapfile None swap SW 0 0
/dev/hda/media/cdrom Auto Pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,man Aged 0 0
~
~
~
"/etc/fstab" 10L, 803C written

To see what happened after the change:
[Root@flynet ~]# Swapon-s
Filename Type Size Used Priority
/DEV/SDA2 Partition 409648 69684-1
/var/swapfile file 7979000 0-2
[Oracle@flynet mail]$ Free-m
Total used free shared buffers Cached
mem:3946 3906 40 0 11 3610
-/+ buffers/cache:284 3662
swap:8192 67 8124
[Oracle@flynet mail]$ Df-h
FileSystem Size Used Avail use% mounted on
/dev/sda3 268G 57G 198G 23%/
/DEV/SDA1 99M 13M 81M 14%/boot
None 2.0G 0 2.0G 0%/dev/shm

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.