Extending a swap partition for Linux

Source: Internet
Author: User
Tags uuid

1. View current swap partition usage

[Email protected] ~]# swapon-s

Filename Type Size used priority

/DEV/SDA2 Partition 10485752 111296-1

2. Create a file to expand the swap partition

[[email protected] ~]# DD </dev/zero >/opt/swapfile1 bs=1m count=200

200+0 Records in

200+0 Records out

209715200 bytes (+ MB) copied, 0.492404 s, 426 MB/s

[Email protected] ~]#

3. Swap tags for files created in the second step, not formatted

[Email protected] ~]# Mkswap/opt/swapfile1

Setting up Swapspace version 1, size = 204796 KiB

No label, uuid=c6df54bc-d54b-4e54-a5d6-38d88adb512f --Used to create a boot auto mount, or you can use the full path

[Email protected] ~]#

4. Add file as swap partition, use now

[Email protected] ~]# Swapon/opt/swapfile1

5, check the current swap partition usage, found a more partition file

[Email protected] ~]# swapon-s

Filename Type Size used priority

/DEV/SDA2 Partition 10485752 111276-1

/opt/swapfile1 file 204792 0-2

[Email protected] ~]#

6, edit the/etc/fstab file, set the created swap partition file to boot automatically mount

[Email protected] ~]# Vim/etc/fstab

Add a row of red (according to the rules of the black line) as follows:

Uuid=51fb56d9-0986-4f8c-b61c-4fd3047ebafa swap swap defaults 0 0

uuid=c6df54bc-d54b-4e54-a5d6-38d88adb512f swap swap defaults 0 0

[[Email Protected]host ~]#

7. View current memory situation

[Email protected] ~]# free-m

Total used free shared buffers Cached

mem:1877 1780 97 0 14 884

-/+ buffers/cache:881 996

swap:10439 108 10331

The swap partition extension is complete.

Extending a swap partition for Linux

Related Article

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.