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 solution to the problem of too small disk space caused by swap

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

By accident, it is found that the partition storage space mounted by the system swap is very small, resulting in zabbix monitoring always warning that the disk space is less than 10%, so the most timely and effective way is to remount the swap to a disk with more disk space.

1. You can view the disk partition status on the system through df-h

[root@~] # df-h

Filesystem Size Used Avail Use% Mounted on

/ dev/mapper/centos-root 18G 12G 6.4G 64% /

Devtmpfs 3.9G 0 3.9G 0% / dev

Tmpfs 3.8G 0 3.8G 0% / dev/shm

Tmpfs 3.8G 377M 3.4G 10% / run

Tmpfs 3.8G 0 3.8G 0% / sys/fs/cgroup

/ dev/xvdc1 2.0T 18G 1.9T 1% / data0

/ dev/xvda1 497M 129M 369M 26% / boot

Tmpfs 757m 0757m 0% / run/user/0

/ dev/loop0 4.1G 4.1G 0100% / media/a

It is found that there is still a lot of space for / dev/xvdc1 to be mounted on / data0, so you can consider mounting swap to / data0.

Now that we have a good place to go, we can get started.

two。 Check where the swap space is located

[root@~] # cat / etc/fstab

You can view the findings in / etc/fstab

/ home/swapswapswapdefaults00

That is to say, mount to the home directory, because the disk space is small, so we need to transfer to a larger space. In the above case, we can just mount it to / data0.

3. Stop swap activity

[root@~] # swapoff / home/swap

4. Transfer / home/swap to / data0

[root@~] # mv / home/swap / data0/

5. To modify the document settings for boot

[root@~] # vim / etc/fstab

Note out / home/swap swap swap defaults 00

Change to / data0/swap swap swap defaults 00

6. View free-m

Found no swap space

[root@~] # free-m

Total used free shared buff/cache available

Mem: 7567 4407 176 386 2983 2445

Swap:

7. Start the swap activity

[root@~] # swapon / data0/swap

8. Check free-m again

With swap space

[root@~] # free-m

Total used free shared buff/cache available

Mem: 7567 4407 176 386 2983 2445

Swap: 2047 168 1879

Through the above operation, the alarm is lifted.

Writing a blog for the first time is purely for my own understanding, so if there are any mistakes, you are welcome to point out, thank you!

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: 264

*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