今日学んだこと: スナップが密かにディスクスペースを消費している(解決方法はこちら)
原題: TIL: Snaps Are Secretly Eating Your Disk Space (Here’s How to Fix It) 🐧
分析結果
- カテゴリ
- 宇宙
- 重要度
- 55
- トレンドスコア
- 17
- 要約
- スナップパッケージは、Linuxシステムでアプリケーションを管理する便利な方法ですが、知らず知らずのうちにディスクスペースを大量に消費することがあります。この記事では、スナップがどのようにストレージを占有するのか、そしてその問題を解決するための手順を紹介しています。不要なスナップを削除する方法や、ストレージの使用状況を確認する方法について詳しく説明しています。
- キーワード
If you use Linux as your daily driver, you’ve probably noticed your root partition quietly shrinking over time. You run ncdu or df -h , poke around your directories, and wonder: Where did all my storage go? Today I Learned (TIL) that a massive chunk of that missing space might be hiding in plain sight. The "Secret" Snap Stash 📦 Package managers like Snap and Flatpak are incredibly convenient for cross-distribution app installations. However, Snap has a habit of hoarding. By default, Snap secretly keeps the last 2 or 3 versions of every single application you install. The logic behind this is sound: if a new update breaks an app, you can easily roll back to the previous working version. But over time? This "just in case" feature wastes gigabytes of valuable disk space, keeping obsolete binaries on your system indefinitely. The Solution: Cleaning Up Old Snaps 🧹 You can easily reclaim this space by removing the old, "disabled" versions of your snaps. Instead of doing this manually one by one, here is a handy bash script that automates the cleanup: #!/bin/bash set -eu # Find all disabled snaps and remove them sudo snap list --all | awk '/disabled/{print $1, $3}' | while read snapname revision ; do sudo snap remove " $snapname " --revision = " $revision " done How it works: snap list --all lists every snap installed, including the inactive older versions. awk '/disabled/{print $1, $3}' filters that list to only grab the names and revision numbers of the snaps marked as "disabled". The while loop iterates through them and safely runs the snap remove command for those specific old revisions. Bonus: Don't Forget Flatpak! 🧽 While you're doing spring cleaning, you should check on your Flatpaks, too. Flatpak doesn't hoard app versions the same way Snap does, but it does leave behind orphaned runtimes (dependencies) when you uninstall apps. You can purge all unused Flatpak runtimes with one simple command: flatpak uninstall --unused The Result 📈 Running these two snippets on a machine that hasn't been cleaned in a year can easily free up anywhere from 2GB to 10GB+ of space. If you just ran this on your machine, drop a comment below—I'm curious to see who holds the record for the most gigabytes reclaimed! 👇 Do you have any other favorite Linux cleanup commands? Let's hear them in the comments! If you use Linux as your daily driver, you’ve probably noticed your root partition quietly shrinking over time. You run ncdu or df -h , poke around your directories, and wonder: Where did all my storage go? Today I Learned (TIL) that a massive chunk of that missing space might be hiding in plain sight. The "Secret" Snap Stash 📦 Package managers like Snap and Flatpak are incredibly convenient for cross-distribution app installations. However, Snap has a habit of hoarding. By default, Snap secretly keeps the last 2 or 3 versions of every single application you install. The logic behind this is sound: if a new update breaks an app, you can easily roll back to the previous working version. But over time? This "just in case" feature wastes gigabytes of valuable disk space, keeping obsolete binaries on your system indefinitely. The Solution: Cleaning Up Old Snaps 🧹 You can easily reclaim this space by removing the old, "disabled" versions of your snaps. Instead of doing this manually one by one, here is a handy bash script that automates the cleanup: #!/bin/bash set -eu # Find all disabled snaps and remove them sudo snap list --all | awk '/disabled/{print $1, $3}' | while read snapname revision ; do sudo snap remove " $snapname " --revision = " $revision " done How it works: snap list --all lists every snap installed, including the inactive older versions. awk '/disabled/{print $1, $3}' filters that list to only grab the names and revision numbers of the snaps marked as "disabled". The while loop iterates through them and safely runs the snap remove command for those specific old revisions. Bonus: Don't Forget Flatpak! 🧽 While you're doing spring cleaning, you should check on your Flatpaks, too. Flatpak doesn't hoard app versions the same way Snap does, but it does leave behind orphaned runtimes (dependencies) when you uninstall apps. You can purge all unused Flatpak runtimes with one simple command: flatpak uninstall --unused The Result 📈 Running these two snippets on a machine that hasn't been cleaned in a year can easily free up anywhere from 2GB to 10GB+ of space. If you just ran this on your machine, drop a comment below—I'm curious to see who holds the record for the most gigabytes reclaimed! 👇 Do you have any other favorite Linux cleanup commands? Let's hear them in the comments!