0

One of our servers has a directory, disk2, which is 95% full. However, when I run commands to determine where the majority of the space is being used, it shows it's int /disk2/backups - which is apparently mounted on a different filesystem on different, larger device, and which is only 31% full. Here's the output of the DU command for those two devices:

Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/xvdb       51475068 46084284   2752960  95% /disk2
/dev/xvdf      154687468 45454904 101352500  31% /disk2/backups

Having the /dev/xvdb at 95% makes me nervous, as it's a production server. I think it's been growing because I didn't notice it before. Cleaning up the backups has solved the issue before, but I think it's on a different device this time.

I'm having trouble figuring out where the major space usages is, partially because the backups keep showing up as the largest files when I run it metrics on /disk2. When I drill down into disk2 directories not in /backups, there doesn't seem to be anything huge.

Also, the heading put out by the du states "1 k blocks". Does this mean that the numbers should be multiplied by 1k? Does it apply to the used available column? I'm thinking it must mean bytes because the first volume is 50G and the second is 150G.

4

1 回答 1

1

Normally, I would use

 cd /disk2
 du -sm * | sort -n

to have the largest dirs/files show up at the bottom.

Because the backups dir might take a long to time scan for no extra value, I would try

  cd /disk2
  du -sm !(backups) | sort -n

The !(backups) is a shell glob that works like *, except in this case it will exclude backups from the list returned.

IMHO, the !(target) syntax is not exactly intuitive. For example if you do !(backups)*, then you get all files again, and backups would be scanned. Just a warning.

Maybe another reader can post a link to a tutorial for using advanced shell globs.

IHTH

于 2015-11-11T23:25:53.490 回答