EST. 2026 — Notes from real server work SYSADMIN · SECURITY · AI · DIRECTADMIN Issue 01
THE SYSADMIN ALMANAC
Home / Linux / A 2 TB Disk Nearly Full, with My Own Data Taking Up Less Than Half
Linux

A 2 TB Disk Nearly Full, with My Own Data Taking Up Less Than Half

by Ton-Or ·4 Dec 2026·12 min read
A 2 TB Disk Nearly Full, with My Own Data Taking Up Less Than Half

A developer's disk often fills up because of what tools leave behind. Deleting safely is not about having the nerve to click the button, but about proving first that what I am about to delete really has a copy elsewhere.

1-minute summary

Symptom / problem
A 2 TB disk is nearly full although less than half of it is your own data.
Who should read
Developers whose disk is full and who do not know what is using the space.
Fix in short
Scan metadata first, then remove debug symbols, SDK copies, logs and caches based on real state without touching open files, recovering 63.08 GB, and delete duplicates only after a full-file SHA-256 match.
Jump to steps

My work laptop has a single 2 TB NVMe drive, partitioned into C: at 974.8 GB and D: at 885.4 GB. One day I noticed C: was 71% full, with 285.5 GB free, while D: was half used, and wondered what was taking up so much space. My first guess was personal photos and videos, which was wrong. Once I scanned the drives, almost all the big space consumers turned out to be leftovers from development tools. I decided to write down how I scanned them, how I decided what could be deleted, and how I removed duplicates with enough confidence to actually delete them.

I have removed all folder names, application names, and usernames from this article, leaving only categories of what I found. The sizes and file counts are real.

Scan metadata only across both drives first

For the first step, I did not open a single file. I used Python's os.scandir to walk both drives, reading only sizes, modification times, and extensions, and let it run in the background. scandir gets this information while listing entries, without needing a separate stat call for each file. With millions of files, that makes a big difference.

import os
from collections import defaultdict

RESERVED = ({"CON", "PRN", "AUX", "NUL"}
            | {"COM%d" % i for i in range(1, 10)}
            | {"LPT%d" % i for i in range(1, 10)})

def is_reserved(name):
    """ชื่ออุปกรณ์ของ Windows เช่น nul, con.txt เปิดแล้วไม่ได้ไฟล์ ได้อุปกรณ์"""
    return name.split(".")[0].upper() in RESERVED

def walk(root):
    stack = [root]
    while stack:
        d = stack.pop()
        try:
            it = os.scandir(d)
        except OSError:
            continue                      # ไม่มีสิทธิ์เข้า ข้ามไป
        with it:
            for e in it:
                if is_reserved(e.name):
                    continue
                try:
                    if e.is_dir(follow_symlinks=False):
                        stack.append(e.path)
                    elif e.is_file(follow_symlinks=False):
                        yield e
                except OSError:
                    continue

def scan(root):
    by_ext = defaultdict(lambda: [0, 0])  # นามสกุล -> [ไบต์รวม, จำนวนไฟล์]
    for e in walk(root):
        try:
            size = e.stat(follow_symlinks=False).st_size
        except OSError:
            continue
        ext = os.path.splitext(e.name)[1].lower() or "(ไม่มีนามสกุล)"
        by_ext[ext][0] += size
        by_ext[ext][1] += 1
    return by_ext

if __name__ == "__main__":
    rows = sorted(scan("D:\\").items(), key=lambda kv: -kv[1][0])
    for ext, (size, n) in rows[:30]:
        print("%-18s %10.2f GB %9d ไฟล์" % (ext, size / 2**30, n))
4.48 millionFiles scanned
1.15 TBUsed out of 1.86 TB
726.52 GBC: 3,835,466 files
446.20 GBD: 643,930 files

The space consumers on C: that were not my own data ranked as follows.

Item Size Notes
User profile 311.91 GB Includes caches from all tools
GUI framework, 3 versions 98.34 GB 60.69 + 25.22 + 12.43
Application A, 3 installations Around 48 GB Maintains its own historical data cache
pagefile 36.00 GB System file
WinSxS 18.95 GB System files
IDE 13.38 GB
hiberfil 12.68 GB System file
GPU toolkit 12.28 GB

Three versions of the same framework took up 98.34 GB because each version came with a full set of source code and built libraries. During installation, nothing told me the older versions were still there.

Break down the 379.99 GB other category by extension

After a rough grouping, 379.99 GB did not fit any category. I broke this down further by extension, which revealed what it actually contained.

other: 379.99 GB by file typeNo extension64.47 GB.pdb62.42 GBApp A cache44.71 GBsplit archive38.82 GB.lib25.57 GB.debug18.03 GBAgent .jsonl15.25 GBPartial downloads10.81 GBOld tree: verify before deletingHash both treesFull-file SHA-256Old tree only5 files 11.60 MBcopy + verifyTarget hash matchesReindexUnique left = 0Delete 521 filesGuard passed
The upper bars show file types consuming space in the other category (the red bar is debug symbols). The lower section shows the full sequence that must pass before deleting the old tree of 521 files.
Type Size File count What it is
No extension 64.47 GB 744,798 git objects, conda, npm, and browser caches
.pdb 62.42 GB 2,614 Debug symbols
Application A cache 44.71 GB 4,405 Historical data cached by the application itself
split archive .001-.004 38.82 GB 26 Split compressed archives
.lib 25.57 GB 10,058 SDK static libraries
.debug 18.03 GB 813 Another debug symbol format
.jsonl 15.25 GB 37,070 Session logs from several AI coding agents
Leftover download manager files 10.81 GB 19

What I had never considered was the .jsonl conversation logs from AI coding agents, which had accumulated to 15.25 GB across 37,070 files. These files grow with the number of sessions, and none of the agents cleans them up automatically. I previously wrote about the structure of these session files in the article on repairing session files. Meanwhile, .pdb and .debug together exceeded 80 GB, containing data that anyone who does not debug down into the engine would rarely use.

Look at file counts alongside sizes

The 38.82 GB of split archives contained just 26 files. I could decide within a minute whether to keep or move them. The 64.47 GB with no extension, on the other hand, was spread across 744,798 files. Going through them individually was not an option; they needed to be managed through commands provided by the tools that created them. Similar sizes, but different ways to handle them.

Delete based on the machine's actual state, not a list

I intended to delete everything on my shortlist, but checking the machine's state before starting meant adjusting the plan. I actually deleted three groups of items.

# ที่ว่างก่อนลงมือ
Get-PSDrive C, D | Format-Table Name, @{n='FreeGB';e={[math]::Round($_.Free/1GB, 2)}}

# โปรแกรม A ชุดไหนกำลังรันอยู่ ชุดนั้นห้ามแตะ cache
Get-Process | Where-Object Path -like '*ProgramA*' | Format-Table Id, Path

# cache ของ conda: ให้ conda ลบเอง ไม่ลบโฟลเดอร์ด้วยมือ
conda clean -a --dry-run
conda clean -a -y
What I deleted Space recovered Details
Web engine debug symbols 29.75 GB 5 files across multiple versions and architectures
Application A cache from an installation that was not running 18.52 GB 2,606 files
Application A cache in AppData 5.44 GB 460 files
conda clean -a 8.74 GB 759 tarballs at 4.08 GB + 87 packages at 4.09 GB + index cache

C: free space went from 285.5 to 348.58 GB, an increase of 63.08 GB, and usage dropped from 71% to 64%. After conda clean, the pkgs folder still held 8.89 GB that could not and should not be deleted, because the environments in use pointed to these files through hardlinks. Deleting them here would not recover space.

There were two items on the list that I skipped.

Skipped 20.60 GB

Cache from applications that were running

Another 2 installations of Application A were running at the time. Deleting files underneath a process that is writing to them risks corrupting its data. I would wait until the applications were closed, then return to delete them. Recovering 20.60 GB was not worth having to repair the data.

Skipped 13 files

Leftover download manager files of 0 byte

The names looked like junk, but their sizes were zero. They were queued downloads that had not started yet. Deleting them would not recover a single byte, but would break the queue. The files actually consuming space were already in the Recycle Bin.

Recheck the deletion list when it is time to act

The shortlist came from scan results, which were a snapshot at the time of the scan. Before actually deleting anything, I needed to ask two questions again: does any process have these files open, and what are their actual sizes? Zero-size files with names that look like junk are the most common trap.

A drive map in one file

For the decisions that needed human judgment, I did not want to read thousands of lines of filenames, so I generated a single .hta file from the scan results. It had four tabs: a tree of 874 folders, 7 levels deep (only those at least 50 MB), with names that opened the folder in Explorer when clicked; 197 files at least 200 MB (opened with explorer /select); 113 files at least 100 MB that had not been modified for over 1 year; and 44 groups with matching names and sizes.

The trap with .hta was that opening it through explorer did nothing, because the association on my machine pointed to the version in SysWOW64. I had to invoke mshta.exe directly.

& "$env:SystemRoot\System32\mshta.exe" "$PWD\drive_map.hta"

Duplicate files: matching sizes are not enough; hash the full file with SHA-256

The last tab of the map pointed to PDFs: 2,712 files totaling 18.17 GB. I first selected groups with matching sizes, because files with different sizes cannot be duplicates, so there is no need to waste time hashing them. I then verified the remaining groups with SHA-256 over each entire file. Matching sizes alone cannot be trusted, and matching names are even less reliable.

import hashlib, os, sys
from collections import defaultdict

def sha256(path, buf=1 << 20):
    h = hashlib.sha256()
    with open(path, "rb") as f:
        while True:
            chunk = f.read(buf)
            if not chunk:
                break
            h.update(chunk)
    return h.hexdigest()

def find_dupes(paths, exclude=()):
    by_size = defaultdict(list)
    for p in paths:
        if any(p.lower().startswith(x.lower()) for x in exclude):
            continue                       # ชุดที่ห้ามแตะ แม้เนื้อหาจะซ้ำ
        by_size[os.path.getsize(p)].append(p)
    by_hash = defaultdict(list)
    for size, group in by_size.items():
        if size == 0 or len(group) < 2:
            continue                       # ขนาดไม่ซ้ำ = เนื้อหาไม่ซ้ำแน่นอน
        for p in group:
            by_hash[sha256(p)].append(p)
    return {h: g for h, g in by_hash.items() if len(g) > 1}

def consolidate(dupes, apply=False):
    freed = 0
    for h, group in dupes.items():
        keep, extra = group[0], group[1:]
        for p in extra:
            freed += os.path.getsize(p)
            print(("[DEL] " if apply else "[DRY] ") + p + "  (เก็บ " + keep + ")")
            if apply:
                os.remove(p)
    print("คืนพื้นที่ %.2f GB%s" % (freed / 2**30, "" if apply else " (ยังไม่ได้ลบจริง)"))

if __name__ == "__main__":
    files = [l.rstrip("\n") for l in open(sys.argv[1], encoding="utf-8")]
    keep_out = [a for a in sys.argv[2:] if a != "--apply"]   # โฟลเดอร์ที่ห้ามแตะ
    consolidate(find_dupes(files, exclude=keep_out), apply="--apply" in sys.argv)

The result was 343 confirmed duplicate groups, with 997 copies totaling 10.03 GB. I acted on 103 groups, deleting 123 files to recover 4.79 GB and moving 10 files into one location. The script defaults to dry-run and requires --apply to actually delete anything, which immediately saved me from the first trap.

The first trap: I wrote another script to check the results and used import to reuse functions from the consolidate script. It turned out that the first version of consolidate had no if __name__ == '__main__' guard, so importing it reran the entire top-level code. No damage occurred because there was no --apply, so it ran as a dry-run. If actual deletion had been the default, that run would have deleted more files without my asking.

The second trap: 33 duplicate entries were in a data export from an online service, where the same files were attached to multiple conversations. Deleting the copies would mean the export no longer matched the original, for only around 39 MB of recovered space. I therefore added that folder to the exclusions.

Duplicate does not mean safe to delete

Matching hashes only establish that the contents are identical. They do not establish that a copy serves no purpose. Copies within datasets that must retain their original state, such as exports, backups, or folders referenced by other applications, must always be excluded first. Every deletion script should also remain a dry-run until explicitly told otherwise.

Merge two trees: prove nothing will be lost before deleting

Another task involved a document folder copied to two locations. The newer set, 3.27 GB across 1,695 files, appeared to cover almost all of the older set, 3.18 GB across 521 files. That word "almost" was why I could not simply delete it. I hashed both trees and compared them, finding 5 files totaling 11.60 MB that existed only in the old set.

Steps before deleting the old treeHash both trees521 and 1,695 files->Find old-only content5 files 11.60 MB->copy + verifyHash each destination file->ReindexAll 222 contents present->Delete521 files
import os, shutil, sys
from collections import defaultdict
# ใช้ walk() กับ sha256() ตัวเดียวกับข้างบน

def index(root):
    out = defaultdict(list)                # hash -> [path ที่มีเนื้อหานี้]
    for e in walk(root):
        out[sha256(e.path)].append(e.path)
    return out

def rescue(old_root, new_root):
    """คัดลอกเนื้อหาที่มีเฉพาะชุดเก่าไปชุดใหม่ แล้วยืนยัน hash ปลายทาง"""
    old, new = index(old_root), index(new_root)
    for h in [h for h in old if h not in new]:
        src = old[h][0]
        dst = os.path.join(new_root, "_from_old", os.path.relpath(src, old_root))
        os.makedirs(os.path.dirname(dst), exist_ok=True)
        shutil.copy2(src, dst)
        if sha256(dst) != h:
            sys.exit("[STOP] hash ปลายทางไม่ตรง: " + dst)
        print("[COPY] " + dst)

def drop_old(old_root, new_root, apply=False):
    old, new = index(old_root), index(new_root)   # index ใหม่ทุกครั้ง ไม่ใช้ผลเก่า
    only_old = [h for h in old if h not in new]
    print("ชุดเก่ามี %d เนื้อหา มีเฉพาะชุดเก่า %d" % (len(old), len(only_old)))
    if only_old:
        sys.exit("[STOP] ยังมีเนื้อหาที่ไม่ซ้ำอยู่ในชุดเก่า ไม่ลบ")
    for paths in old.values():
        for p in paths:
            print(("[DEL] " if apply else "[DRY] ") + p)
            if apply:
                os.remove(p)

if __name__ == "__main__":
    old_root, new_root = sys.argv[1], sys.argv[2]
    if "--rescue" in sys.argv:
        rescue(old_root, new_root)
    drop_old(old_root, new_root, apply="--apply" in sys.argv)

The key is that drop_old builds a fresh index itself every time, does not accept results from the previous step, and refuses deletion if even one piece of content is missing from the new set. After copying the 5 files over and confirming that every destination hash matched, the fresh index verified that all 222 distinct pieces of content from the old set were present in the new one. Only then did I delete the 521 files.

This task revealed two more traps. First, the folder contained a file named nul, created by typing > nul in a shell other than cmd, which produced an actual file with that name. When Python opened that name, it accessed the Windows NUL device instead of the file, and the script failed partway through. That is why the walk() above has to skip these reserved names. Second, 5 to 7 scripts in the project referenced paths in the old set. After deleting the tree, I also had to update those paths in the scripts, or they would fail silently the next time I ran them.

The sequence I used and the totals

  1. Scan metadata only across the entire drive first. Group by top-level folder and extension, looking at both sizes and file counts.
  2. Separate tool-generated data (debug symbols, SDK copies, agent logs, package caches) from my own data.
  3. For tool-generated data, use the tool's own cleanup command where available, such as conda clean -a.
  4. Before deleting each group, check whether any process has it open and what its actual size is. Skip anything still in use for now.
  5. For duplicate files, filter by size first, then verify with full-file SHA-256. Exclude datasets that must retain their original state.
  6. For duplicate trees, find content unique to the side being deleted, copy it across, verify destination hashes, then reindex to confirm 0 unique items remain before deleting.
  7. Every deletion script defaults to dry-run and always has an if __name__ == '__main__' guard.
+63.08 GBMore free space on C:
71% -> 64%C: usage
592.64 GBD: free space afterward
343 groupsConfirmed duplicate PDFs
5 filesOnly in the old set
0Content lost through deletion

On D:, free space increased from 442.7 to 592.64 GB, recovering 149.94 GB. This figure includes emptying the Recycle Bin manually; it was not all the work of the scripts.

The conclusion is that a development machine's disk fills up with things I never intended to keep. Personally, I will run a scan like this before considering buying more storage, and I will not delete anything until I can prove it has a copy. All these figures come from my machine alone; the proportions on other machines will vary with the tools installed. Anyone using these scripts should always run them in dry-run mode and review the results first. If I have left anything out or made any typos, I will come back and correct them later.

Hit something like this? Stuck somewhere?

Come trade notes on the LinuxThai board

→ Continue on the board

Comments 0

No comments yet — be the first