Linux System Troubleshooting 3--I/O Chapter

Source: Internet
Author: User
Tags syslog disk usage

When a disk cannot be written, the following are generally possible:

    • File system Read-only
    • Disk is full
    • I-node is out of use

First, a read-only file system is encountered

A file system that is automatically set to read-only may be a mechanism for system self-protection, so it is necessary to realize what causes the file system to be read-only. If you want to change the read-only property of the file system, mount the destination partition again.

Example 1. Re-mount Change read/write properties of the/home partition

Mount -o remount, rw/home

The-o option is followed by the two Mount Command's proprietary option, remount refers to re-mount the specified file system, RW specifies the read and write properties when re-mount, the command does not change the mount point, only changes the read and write properties of the specified partition.

Second, disk full

Disk usage, remaining space, etc. can be viewed using the DF command,

Example 2. View all partitions and usage that are currently mounted

1#DF-h2Filesystem Size used Avail use%mounted on3/dev/sda2 133G8.6G 118G7% /4None4.0K0  4.0K0%/sys/fs/Cgroup5Udev5.9G4.0K5.9G1% /Dev6Tmpfs1.2G 868K1.2G1% /Run7None5.0M     0  5.0M   0%/run/Lock8None5.9G0  5.9G0%/run/SHM9None 100M0100M0%/run/UserTen/DEV/SDA1 93M3.4M90M4%/boot/efi

-h is automatically displayed in a suitable reading unit, and the disk space for this example is clearly sufficient.

Sometimes found that the DF results in the use of space "used" and the capacity of "size" there is a certain gap, but the free space "Avail" but there is little, while the use of "used%" high, even up to 100%. This is not surprising, because Linux in order to avoid the full use of the system storage space caused by the root user can not log in, for the root user to retain a block of reserved chunks for high disk usage when the root user login system to complete the necessary cleanup operations. Only the root user can write data in these reserved blocks, and you can view the size of the reserved block using the TUNE2FS tool.

Example 3. viewing system reserved Blocks using TUNE2FS

1# tune2fs-l/dev/sda2 |grep-I."Block"2Block Count:354004483Reserved Block Count:17700224Free Blocks:331839195First Block:06Block Size:40967Reserved GDT Blocks:10158Blocks per Group:327689Inode blocks per group: +TenFlex Block Group size: - OneReserved Blocks UID:0(user root) AReserved blocks GID:0(group Root) -Journal Backup:inode Blocks

Where line 3rd shows the number of system reserved blocks, the 6th line shows the size of each block (4KB), which multiplies the total size of the reserved chunks;

11th, Line 12 shows the number of users and user groups that can write to reserved chunks, which is root;

Just to see how a file system is occupied, how do you know the space usage of the relevant directory in this filesystem? The du command can view the size of all directories on the file system.

Example 4. Use Du to view the space occupied by a directory

1 # CD/2dusort -n >/tmp/dir_space

Using tail to view the saved/tmp/dir_space file, you can see the largest 10 directories under the root file system:

1 674236./var/Log2 904232./usr/Lib3 1372776./var/lib/glance/Images4 1372868./var/lib/Glance5 1523512./var/lib/MongoDB6 2082052./usr7 4003024./var/Lib8 4878944./var9 8798036    .Ten 8798036Total

Here you can see the/var/log directory is very large, because the/var/log/directory is a number of log files, log files are often the source of occupation system space, you can release the log file space to obtain storage space:

1#ls-lhs/var/log/syslog.12 1.3M-rw-r-----1Syslog ADM1.3MThe A  .: theSyslog.13# bash-c">/var/log/syslog.1"4#ls-lhs/var/log/syslog.15 0-rw-r-----1Syslog ADM0The A  the: -Syslog.1

This example truncates the Syslog file after the volume, in effect deleting the contents of the specified log file. Of course, you can also delete the corresponding log files directly.

Three, I node insufficient

When DF shows sufficient disk space, but the file system has an error indicating that it is full and cannot write, it needs to check if the I node is exhausted.

Create a new file in the system will get a unique I node, once the I node is exhausted, you can no longer create a new file, which can occur when the system creates a large number of files, use the Df-i command to view the use of the I node.

Example 5. Viewing the usage of the I node

1#DF-I2Filesystem inodes iused IFree iuse%mounted on3/dev/sda28855552 219633 8635919    3% /4None1532516      2 1532514    1%/sys/fs/Cgroup5Udev1529802    463 1529339    1% /Dev6Tmpfs1532516    523 1531993    1% /Run7None1532516      A 1532504    1%/run/Lock8None1532516      1 1532515    1%/run/SHM9None1532516      3 1532513    1%/run/UserTen/dev/sda10      0       0-/boot/efi

You can see that the I nodes of the current file system are sufficient.

The following options are available when the I node is exhausted:

1. Delete a large number of files

2. Move a large number of files to another file system;

3. Compress a large number of files into one file;

4. Back up all the files in the current file system, reformat the previous hard drive, get more I nodes, and copy the files back.

  

Linux System Troubleshooting 3--I/O Chapter

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.