Linux disk space usage issues

Source: Internet
Author: User
Tags system log disk usage

Linux disk space Full processing method

There may be two situations in which there is space under Linux

You can use the command

Df-h View disk space consumption, actually look up the disk block occupied by the file (block)

Df-i viewing the footprint of an index node (inodes)

One of the disk blocks and index nodes is full, causing the file to be created and the disk space full.

So please note that there is room for viewing the disk, but the creation of the file indicates that the space is full, possibly the Inodes node is full

by command: Find/-size +100m |xargs LS-LH

List files larger than 100M in the system

Du-h--max-depth=1

To view the size of a folder in the current directory

Can be tested in two ways, sometimes, occupy a lot of space is actually a system log or business attachments and other small files ,

So depending on the size of the file to find the "directory" or file that is not necessarily able to identify the hard disk space, it is recommended to use the second

Large log file

Web Access log, it is recommended to do a scheduled task log cutting, in days to do a compressed backup (can be implemented through scripting), to keep a certain time for viewing, there is a need to do log analysis.

For example, in the case of a one-click installation package, the/alidata/log/directory is a log file that checks to see if the file size is full disk usage, and generally, the Access directory file is the log of the error. If the disk is slow, these logs are not important, then you can do the emptying process, Method 1, can be deleted RM, 2 echo "" >access.log

Large number of small files caused

Due to business requirements, generating a large number of small files, you need to consider new additions to the disk or the use of OSS storage services

DF Command Results display Size not equal to Avail + used

[Email protected] log]# df-h
Filesystem Size used Avail use% mounted on
/dev/cciss/c0d0p1 9.7G 538M 8.7G 6%/
/DEV/CCISS/C0D0P6 503G 35G 442G 8%/opt
/DEV/CCISS/C0D0P5 9.7G 158M 9.1G 2%/Home
/DEV/CCISS/C0D0P3 9.7G 2.5G 6.8G 28%/usr
/DEV/CCISS/C0D0P2 9.7G 1.1G 8.2G 12%/var
Tmpfs 127G 36G 91G 28%/DEV/SHM
/dev/sddlmaa1 493G 531M 467G 1%/etl_loader
[[email protected] log]# DF
Filesystem 1k-blocks used Available use% mounted on
/dev/cciss/c0d0p1 10153988 550000 9079872 6%/
/DEV/CCISS/C0D0P6 526902720 36508388 463197496 8%/opt
/DEV/CCISS/C0D0P5 10153988 161052 9468820 2%/Home
/DEV/CCISS/C0D0P3 10154020 2604320 7025580 28%/usr
/DEV/CCISS/C0D0P2 10154020 1066128 8563772 12%/var
Tmpfs 132135932 36923100 95212832 28%/DEV/SHM
/dev/sddlmaa1 516054864 543296 489297508 1%/etl_loader Why Df-h's result display, Avail + used is not equal to the value of the Size column (except TMPFS), have you noticed? !
Taking/dev/sddlmaa as an example, firstuse Fdisk to checkLook at the size of the disk:
[Email protected] log]# fdisk-l/dev/sddlmaadisk/dev/sddlmaa:536.8 GB, 536870912000 bytes
255 heads, Sectors/track, 65270 cylinders
Units = Cylinders of 16065 * 8225280 bytes Device Boot Start End Blocks Id System
/dev/sddlmaa1 1 65270 524281243+ Linux [[email protected] log]# expr 536870912000/1048576/1 024
More than 500 can be seen/dev/sddlmaa size of 500GB, but df-h show the result is 493G, who moved my 7GB space?!
Guess, file system metadata (Inode), reserve space, or something else? The following we use the TUNE2FS command to view/dev/sddlmaa's superblock information, to see where 7GB space?
[Email protected] log]# tune2fs-l/DEV/SDDLMAA1
TUNE2FS 1.39 (29-may-2006)
Filesystem Volume Name:
Last mounted on:
Filesystem Uuid:b60c1597-b8df-4573-939f-9b9b7cbb27e8
Filesystem Magic number:0xef53
Filesystem Revision #: 1 (dynamic)
Filesystem features:has_journal resize_inode dir_index filetype needs_recovery sparse_super large_file
Default mount options: (None)
Filesystem State:clean
Errors behavior.: Continue
Filesystem OS Type:linux
Inode count:65536000
Block count:131070310
Reserved Block count:6553515
Free blocks:128903916
Free inodes:65535216
First block:0
Block size:4096
Fragment size:4096
Reserved GDT blocks:992
Blocks per group:32768
Fragments per group:32768
Inodes per group:16384
Inode blocks per group:512
Filesystem created:tue Sep 27 13:44:47 2011
Last Mount Time:fri 11 05:43:36 2012
Last write Time:fri 11 05:43:36 2012
Mount Count:7
Maximum Mount Count:35
Last Checked:tue Sep 27 13:44:47 2011
Check interval:15552000 (6 months)
Next Check After:sun Mar 25 13:44:47 2012
Reserved blocks uid:0 (user root)
Reserved blocks gid:0 (group root)
First Inode:11
Inode size:128
Journal Inode:8
Default Directory Hash:tea
Directory Hash seed:04e7940a-f2d4-4ea0-b0a4-78134302d050
Journal Backup:inode Blocks According to the results of TUNE2FS, the size of the inode space is as follows:
[[email protected] log]# expr 65536000 \* 128/1048576/1024
7
Just 7GB, this verifies our previous guess! So our 7GB space is back, back to the chase also take/dev/sddlmaa as an example, size-avail-used= 516054864-543296-489297508 (KB)
[Email protected] log]# echo "516054864-543296-489297508" |BC
26214060
Where is the space for so much 26214060KB? The system is hidden, reserved? If yes, what do these spaces do and can be released?
What does the reserved space (Reserved block) do? Can this space be adjusted (Reference command: tune2fs-m 0)?
Reserved space features:
1. Reduce Linux file system fragmentation;
2. When there is no space left on the disk partition, the root user can log in or record the system.
File system Reserved Block Count is supposed to reduce Linux file system defragmentation,
To allow root user login-maintenance or to allow the Linux system logging facility to function properly
In case file system running low of free disk space. Typically, the reserved space size is (disk size-inode size) * 5% Depending on the results of TUNE2FS, the reserved space size is as follows:
[[email protected] log]# expr 6553515 \* 4
26214060 (KB)
This value is exactly equal to the size-avail-used above.
Summary, DF command results display Size Not equal to Avail + used, actually Avail + used = 0.95 * Size, remaining 0.05 reserved space.
This size is a disk that can store data, and the actual bare disk size refers to the bytes in Fdisk-l. By the way, we've explained fdisk-l that the disk size is inconsistent with df-h results, remember?
The reasons are as follows:
1. Fdisk-l is usually counted as 1KB in 1000bytes, so the size GB shown is larger than the df-h result.
2. DF Displays the size column, which is the magnitude of the culling inode (what is the inode?)

Linux disk space usage issues

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.