Ubuntuディスク使用量が増えてきたら

Ubuntuのディスク使用量、インストールしたときは余裕があったのに
いつのまにか、ディスク容量を圧迫していました。

僕の場合、aptのキャッシュと不要パッケージがほとんどだったようで、
後述の2つの作業をすれば、最初の頃と同じ程度に収まりました。

ディスク使用状況

sudo du -sh /*

du コマンドでどこのディレクトリが占めているのか調べます。
大きそうなところが見つかったら、 sudo du -sh /lib/* などと、更に深く見てみるなどします。

BEFORE

6.5G    /var
3.6G    /lib
2.8G    /usr

僕の場合は、/lib と、/usr が大きかったです。

/var は、dockerを使ってるので、/var/lib/docker というディレクトリが4Gくらい占めてました。
(これはdockerを使う上で仕方ないくらいのサイズなのかな??)

あと、スワップメモリ用の容量も/var/swap に配置していますので、
まあ、/var は削減できなさそうです。

AFTER

6.3G    /var
1.3G    /usr
880M    /lib

で、最終的に /usr と /lib がこんなにスッキリしました。

aptの不要リソースを削除しよう

apt-get autoremove

sudo apt-get autoremove

もう依存しなくなったパッケージ類を検出して削除してくれるようです。

apt-get clean

sudo apt-get clean

インストール時にダウンロードした圧縮ファイルなどを、削除してくれるようです。
(ダウンロードファイルがある場合は、きっと再ダウンロードしないようになってるんだろうな。)

apt usage

$ apt-get -h
apt 1.2.24 (amd64)
Usage: apt-get [options] command
       apt-get [options] install|remove pkg1 [pkg2 ...]
       apt-get [options] source pkg1 [pkg2 ...]

Most used commands:
  update - Retrieve new lists of packages
  upgrade - Perform an upgrade
  install - Install new packages (pkg is libc6 not libc6.deb)
  remove - Remove packages
  purge - Remove packages and config files
  autoremove - Remove automatically all unused packages
  dist-upgrade - Distribution upgrade, see apt-get(8)
  dselect-upgrade - Follow dselect selections
  build-dep - Configure build-dependencies for source packages
  clean - Erase downloaded archive files
  autoclean - Erase old downloaded archive files
  check - Verify that there are no broken dependencies
  source - Download source archives
  download - Download the binary package into the current directory
  changelog - Download and display the changelog for the given package

おしまい

めっちゃディスク容量が空きました。

たかだが、4GB程度ですが、
IDCFでの月額500円のVMで、容量は15GBなので、
ここで削減できた4GBはおおきいです!

余談

前から気にはなっていた、テイルズ・オブ・ベルセリアを買っちゃっいました。
中古で買おうか迷いましたが、ダウンロード版でもWelcome価格になってて、4000円くらいで購入できる!

案外中古で売ったりしに行かない面倒くさがりなので、
これからの時代は、ダウンロード版やな!と思いました。
(ディスク入れ替えとかしなくていいからね)

コメントを残す