Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of adding swap Partition File in Centos

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how Centos adds swap partition files". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's take you to learn how to add swap partition files in Centos.

Steps to add swap partition files in Linux:

1. Check the current partition situation (use free -m or cat /proc/swaps):

[root@db2 root]# free -m

total used free shared buffers cached

Mem: 1006 84 922 0 11 38

-/+ buffers/cache: 35 971

Swap: 0 0 0

[root@db2 root]#

2, increase the exchange partition file and size:

Check that there is no swap, the following needs to be added:

Determine the size of the new swap file and multiply the size by 1024 to determine the block size. For example, for a swap file of 64MB with a block size of 65536, type the following command as root at the shell prompt, where count equals the desired block size.

[root@db2 root]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000

1024000+0 records in

1024000+0 records out

[root@db2 root]#

Use the following command to set up the swap file:

[root@db2 root]# mkswap /home/swap

Setting up swapspace version 1, size = 1023996 KiB

[root@db2 root]#

3. Enable swapping partition files:

To enable swapping files immediately rather than automatically at boot time, use the following command:

[root@db2 root]# swapon /home/swap

Check the added exchange:

[root@db2 root]# free -m

total used free shared buffers cached

Mem: 1006 994 12 0 4 929

-/+ buffers/cache: 60 946

Swap: 999 0 999

[root@db2 root]#

To enable it at boot time, edit the/etc/fstab file to include the following line (/home/swap swap defaults 0 0):

[root@db2 root]# vi /etc/fstab

LABEL=/ / ext3 defaults 1 1

LABEL=/boot /boot ext2 defaults 1 2 /home/swap swap swap defaults 0 0

none /dev/pts devpts gid=5,mode=620 0 0

none /proc proc defaults 0 0

none /dev/shm tmpfs defaults 0 0

LABEL=/usr /usr ext3 defaults 1 2

/dev/sda5 swap swap defaults 0 0

/dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0 0

/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0

/home/swap swap swap defaults 0 0

The next time the system boots, it enables the newly created swap file

Check again after adding:

[root@db2 oracledb]# free -m

total used free shared buffers cached

Mem: 1006 979 27 0 6 917

-/+ buffers/cache: 54 952

Swap: 999 0 999

[root@db2 oracledb]#

At this point, I believe that we have a deeper understanding of "Centos increase swap partition file method," may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report