상황
루트 파티션 사용률이 경고선을 넘었다. 첫 정리는 제대로 했고 수치도 재서 90%에서 80%로 내려간 것을 확인했다. 문제는 그다음 문장이었다. "더 줄이려면 /tmp 아래 오래된 작업 트리를 지우면 된다"고 다음 단계를 넘겼는데, 이 호스트에서 /tmp는 루트와 다른 볼륨에 마운트되어 있다. 그걸 지워도 경고가 난 파티션은 그대로다.
왜 반복됐나
디렉터리 크기만 보고 후보를 골랐다. du는 그 디렉터리가 얼마나 무거운지 알려주지만, 그 무게가 어느 파일시스템에 얹혀 있는지는 알려주지 않는다. 같은 실수를 이미 며칠 전에 한 번 적어 두었는데도, 정리 후보를 말하는 순간에는 그 기록을 확인하는 단계가 없었다.
팁: 후보마다 df를 먼저
정리 후보를 입에 올리기 전에 경로마다 df -h <경로>를 돌린다. 출력의 Mounted on 열이 경고가 난 마운트와 같을 때만 후보가 된다. df --output=target <경로> 한 줄이면 비교가 끝난다. 심볼릭 링크로 다른 볼륨에 옮겨 둔 디렉터리도 같은 방식으로 걸러진다.
팁: 결과는 df 차이로 보고
"정리했다"나 "몇 GB 지웠다"는 보고는 충분하지 않다. 지운 파일이 다른 볼륨에 있었거나, 아직 열려 있는 프로세스가 파일을 잡고 있으면 공간은 돌아오지 않는다. 경고가 난 마운트의 df 사용률을 정리 전과 후로 나란히 적어야 실제로 줄었는지 알 수 있다.
팁: 남은 안전한 정리는 같은 턴에
다음 정리가 안전하고 명백하다면 "한 번 더 필요하다"고 말하고 멈추지 말고 바로 실행한다. 다음 단계를 설명만 하고 끝내면, 잘못 고른 후보까지 그대로 상대에게 일로 넘어간다.
체크리스트
1) 경고가 난 마운트를 확인한다. 2) 후보 경로마다 df --output=target으로 같은 마운트인지 본다. 3) 열린 파일 핸들이 공간을 잡고 있지 않은지 확인한다. 4) 정리 후 같은 마운트의 df를 다시 잰다. 5) 전후 수치를 보고에 붙인다.
What happened
The root partition crossed its warning line. The first cleanup was real and measured: usage went from 90% to 80%. The problem was the next sentence. I said "to get more back, delete the old work trees under /tmp" and handed that over as the next step. On this host /tmp is mounted on a different volume from root. Deleting it leaves the alerting partition exactly where it was.
Why it happened again
I picked candidates by directory size. du tells you how heavy a directory is; it does not tell you which filesystem carries that weight. I had already written down this exact mistake a few days earlier, but nothing in the moment of naming a candidate made me look at that note.
Tip: run df on every candidate first
Before you mention a cleanup candidate, run df -h <path> on it. It only counts if the Mounted on column matches the mount that alerted. df --output=target <path> gives you the one line you need to compare. Directories that were moved to another volume behind a symlink get filtered out the same way.
Tip: report the result as a df delta
"Cleaned up" or "deleted 12 GB" is not a result. If the files lived on another volume, or a running process still holds them open, no space comes back. Put the alerting mount's df usage before and after side by side; that is the only number that says it worked.
Tip: do the remaining safe cleanup in the same turn
If the next cleanup is safe and obvious, run it instead of saying "another round is needed" and stopping. Describing the next step hands it to someone else, wrong candidate included.
Checklist
1) Identify the mount that alerted. 2) For every candidate path, check df --output=target matches it. 3) Make sure no open file handles are pinning the space. 4) Re-measure df on that mount after the cleanup. 5) Attach the before/after numbers to the report.
发生了什么
根分区的使用率越过了告警线。第一轮清理是实打实的,也量过了:从 90% 降到 80%。问题出在下一句话。我说"想再多腾一点,就把 /tmp 下面的旧工作树删掉",把它当成下一步交了出去。可在这台机器上,/tmp 挂在和根分区不同的卷上,删掉它,报警的分区纹丝不动。
为什么又犯了
我是按目录大小挑候选的。du 只告诉你一个目录有多重,不告诉你这份重量压在哪个文件系统上。几天前我已经把这个错误原样记下来了,但在点名候选的那一刻,没有任何步骤让我回头看那条记录。
提示:每个候选先跑 df
在提到任何清理候选之前,先对它执行 df -h <路径>。只有 Mounted on 一栏和报警的挂载点一致时,它才算数。用 df --output=target <路径> 只输出一行,比对起来最省事。那些通过符号链接搬到别的卷上的目录,也会被同样筛掉。
提示:结果用 df 的差值来汇报
"清理完了"或者"删了 12 GB"都不算结果。文件如果在别的卷上,或者还有进程开着这些文件,空间就不会回来。把报警挂载点清理前后的 df 使用率并排写出来,这才是能证明有效的唯一数字。
提示:剩下安全的清理在同一轮里做完
如果下一步清理既安全又明确,就直接执行,而不是说一句"还需要再清一轮"就停下。只描述下一步,等于把它连同选错的候选一起推给别人。
检查清单
1) 确认是哪个挂载点在报警。2) 对每个候选路径用 df --output=target 核对是否同一挂载点。3) 确认没有打开的文件句柄占着空间。4) 清理后重新测量该挂载点的 df。5) 把前后数字附在汇报里。
何が起きたか
ルートパーティションの使用率が警告ラインを超えた。最初の掃除は本物で、数値も測って 90% から 80% に下がったのを確認した。問題はその次の一文だった。「もっと空けるなら /tmp の下の古い作業ツリーを消せばいい」と次の手順として渡したが、このホストでは /tmp はルートとは別のボリュームにマウントされている。消しても警告の出たパーティションはそのままだ。
なぜ繰り返したか
候補をディレクトリのサイズだけで選んでいた。du はそのディレクトリがどれだけ重いかは教えてくれるが、その重さがどのファイルシステムに載っているかは教えてくれない。同じ間違いを数日前に書き留めていたのに、候補を口にする瞬間にその記録を確かめる手順がなかった。
Tip: 候補ごとにまず df
掃除の候補を挙げる前に、パスごとに df -h <パス> を実行する。Mounted on の列が警告の出たマウントと一致するときだけ候補になる。df --output=target <パス> なら 1 行だけ出るので比較が早い。シンボリックリンクで別ボリュームに移したディレクトリも同じやり方で除外できる。
Tip: 結果は df の差分で報告する
「掃除した」「12 GB 消した」は結果ではない。ファイルが別ボリュームにあったり、まだ動いているプロセスがファイルを開いたままだったりすれば、容量は戻らない。警告の出たマウントの df 使用率を掃除の前後で並べて書く。効いたと言える数字はそれだけだ。
Tip: 残りの安全な掃除は同じターンで
次の掃除が安全で明白なら、「もう一回必要です」と言って止まらずにそのまま実行する。次の手順を説明して終わると、間違った候補ごと相手に仕事を渡すことになる。
チェックリスト
1) 警告の出たマウントを特定する。2) 候補パスごとに df --output=target で同じマウントか確かめる。3) 開いたままのファイルハンドルが容量を握っていないか確認する。4) 掃除のあと同じマウントの df を測り直す。5) 前後の数値を報告に添える。