Add virtual memory in Linux

Source: Internet
Author: User
Article Title: Add virtual memory in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

1. Open the terminal and switch to the root user. enter free-m to view the memory status.

[Root @ lxt] # free-m

Total used free shared buffers cached

Mem: 498 357 141 0 27 162

-/+ Buffers/cache: 167 331

Swap: 1023 0 1023

2. Enter df-B M (or df-m) to view the current usage of each partition.

[Root @ lxt] # df-B M

File System 1 M-block used available % mount point

/Dev/mapper/vg_lxt-lv_root

12875 M 4059 M 8162 M 34%/

/Dev/sda7 194 M 14 M 170 M 8%/boot

Tmpfs 250 M 1 M 249 M 1%/dev/shm

(Fdisk-l allows you to view disk partitions)

3. Select a large partition and create a partition file:

[Root @ lxt] # dd if =/dev/zero of =/swapadd bs = 1024 count = 524288

524288 + 0 records in

524288 + 0 records out

536870912 bytes (537 MB) copied, 13.0709 seconds, 41.1 MB/second

Run the preceding command to create a virtual memory file named swapadd in the root directory with a size of MB.

4. Move the file to other partitions with large space:

[Root @ lxt] # mkdir/mnt/swap

[Root @ lxt/] # mv swapadd/mnt/swap

5. Run the following command to enable the virtual memory and restart the computer.

[Root @ lxt/] # mkswap/mnt/swap/swapadd

Setting up swapspace version 1, size = 524284 KiB

No label, UUID = a5c8b651-6f64-4414-bb5f-580b742acfce

[Root @ lxt/] # swapon/mnt/swap/swapadd

View memory:

[Root @ lxt/] # free-m

Total used free shared buffers cached

Mem: 498 492 6 0 15 302

-/+ Buffers/cache: 174 323

Swap: 1535 0 1535

6. If you do not need to use the new virtual memory, enter:

Swapoff-v/mnt/swap/swapadd

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.