zoukankan      html  css  js  c++  java
  • How can I see what is consuming space underneath a mounted partition?

    环境

    • Red Hat Enterprise Linux (RHEL) all versions

    问题

    • My partitions are arranged like this (example):
    / (/dev/sda1)
    --/var (/dev/sda2)
    --/usr (/dev/sda3)
    --/backups (/dev/sda4)
    
    • My root partition itself (/dev/sda1) is small, and is almost full.
    • There is nothing on any directory that might account for the occuppied space.
    • How can I see where is the consumed space, and free it by deleting files?

    决议

    The following can be used only to view that is consuming space underneath the mounted partitions. You will not be able to mount the root filesystem read-only on another location, if it is already mounted read-write on /. As such, please exercise extreme care when doing the following procedure, and ensure filesystem activity is kept at a minimum. Failure to do so can incur in filesystem corruption.

    1. Create an alternative directory where the root filesystem will be mounted:

      # mkdir /image
      
    2. Mount the root filesystem on said directory:

      # mount /dev/sda1 /image
      
    3. Execute du command inside that mounted filesystem:

      # cd /image
      # du -sh *
      
    4. To ensure data corruption does not occur, immediately unmount the root filesystem at /image:

      # cd /
      # umount /image
      

    Note that, based on the example above, there should not be any files inside /image/usr, /image/var and /image/backups. However, if there are (because files were written there while the partition was not mounted), the output from the du command will show the file sizes of all the top-level directories of the root filesystem, ignoring the mounted partitions (since they are mounted on the respective / childs, not on /image). Based on that output, you will be able to see if any files reside on top-level directories underneath the partitions mounted on them. Once you have this information, you can either:

    • Unmount the partition that resides on the offending directory (the one consuming space where it should not), and remove the files manually.
    • If it is not possible to unmount the partition, you will have to reboot your system into rescue mode (select "Skip" on step 5 of the mentioned guide), mount the root filesystem manually, and delete the files outlined as per the mentioned procedure.

    根源

    Due to how the Linux filesystem structure works, if you have a partition mounted on a directory (e.g. /backups), and a file getss written to that directory while the partition was not mounted, the space consumed by said file will account towards space used in its parent directory (in this case, /), instead of the partition that will be mounted there (/backups).

  • 相关阅读:
    jQuery Ajax 实例
    jQuery Ajax 实例
    mysql中使用MySqlParameter操作数据库
    mysql中使用MySqlParameter操作数据库
    MySQL limit 分页查询数据库
    html5新特性data_*自定义属性使用
    CSS中zoom和scale的区别
    Linux下nginx编译安装教程和编译参数详解
    nginx.conf配置
    linux下tar.gz、tar、bz2、zip等解压缩、压缩命令小结
  • 原文地址:https://www.cnblogs.com/augusite/p/12925604.html
Copyright © 2011-2022 走看看