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

Docker image causes centos-root root partition capacity to be full

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

When the virtual machine server has been running Docker for a long time, it is found that the file of Docker is getting larger and larger, and one day it is found that the database on this machine cannot be accessed. Restart the database and other logs to indicate that there is insufficient space and check the disk space:

Root partition is fully loaded, ah, there is still a lot of space some time ago, check what large file content takes up the space.

Find /-xdev-size + 100m-exec ls-l {}\

The recently used docker is getting bigger and bigger, so that the disk is full.

Then either clean up the docker or expand the disk.

Do both, first simply clean up the docker, maybe you can clean up some space.

First docker images-a to see if there are too many images, some of which are such images.

# remove all untagged images.

Docker rmi $(docker images-aq-f "dangling=true")

The contents of the container are also in the storage layer. You can docker ps-a to see if there are many previous containers that have not been deleted, and you can delete them by docker rm $(docker ps-aq-f "dangling=true").

Garbage collection

Docker run-- rm-v / var/run/docker.sock:/var/run/docker.sock-v / etc:/etc:ro spotify/docker-gc

Some containers are obviously stop, but they still occupy some resources.

Docker rm-f $(docker ps-a | grep Exit | awk'{print $1}')

Use the docker native command to clean up first.

Docker system prune-a

Note:

This may erase the images, so use it with caution.

After the above docker processing, the disk capacity is expanded below.

Extended root partition VMware allocates space

Select Virtual Machine-> Virtual Machine Settings-> add = "hard disk-> add 15g. You can see that hard disk 1 in the first picture is SCSI (0:0). The newly added hard disk 2 is SCSI (0:1).

Let's take a look at the existing disks:

# fdisk-l

Partition the new disk:

# fdisk / dev/sdb

In the interactive mode of fdisk, enter:

N-- create new partition p-- create primary partition-- default partition number-- default starting sector location. -- end sector location by default. W-write to the partition table

This divides the entire disk into an area.

Take another look at the existing disks:

# fdisk-l

A new partition has been added:

Use the new partition for the extension / root

First, take a look at the volume grouping:

# vgdisplay-v

You can see that the current volume grouping is named "centos_h42".

Create a physical volume for the previously added partition:

# pvcreate / dev/sdb1

View the results:

# pvdisplay

Expand the volume grouping. "centos_h42" is the volume grouping name found by the vgdisplay command:

# vgextend centos_h42 / dev/sdb1

Indicates a successful expansion.

Take a look at the logical volume:

# lvdisplay

You can see that / dev/centos_h42/root 's current LV Size is 17.47GiB.

The logical volume / dev/centos_h42/root is extended below:

# lvextend-L + 15g / dev/centos_h42/root

Note: + 15G is our newly added partition size.

After the extension, perform one more step to expand the file system:

# xfs_growfs / dev/centos_h42/root

Expansion complete.

Because you install the xfs partition used for CentOS, use the command xfs_growfs to expand the file system size. Otherwise, use the resize2fs command.

View the results:

# df-Th

/ root has been expanded to 33GiB:

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

Internet Technology

Wechat

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

12
Report