$

DockerのせいでバカデカになったWSL2ディスクを小さくする

備忘。

手順

ファイル削除

WizTreeとかでどこが容量食ってるかみる。
だいたいWSL2の ext4.vhdx 。

いい感じにdockerイメージを削除する。

$ docker rmi hogehoge
$ docker system prune

あとはrustのビルドキャッシュがクソデカになっているときもある。 githubリポジトリとかおいてるディレクトリの容量を計算して削除。

$ du -h -d 1

ディスクサイズ削減

ファイル消しただけでは縮まない。

まずはWSL2を落とす。

> wsl --shutdown
> diskpart
> select vdisk file="C:\Users\{ユーザ名}\AppData\Local\Packages\{PackageFamilyName}\LocalState\ext4.vhdx"
> attach vdisk readonly
> compact vdisk
> detach vdisk
> exit

だいたいこれでおk

Privacy Policy

This website uses Google Analytics to collect traffic information for site improvement. Google Analytics may use cookies and similar technologies to measure page views and usage patterns.

By continuing to use this site, you acknowledge that your site usage may be recorded for analytics purposes.

Disclaimer

The content published on this website is based on publicly accessible information available on the Internet and other open sources, and represents the author's personal views. Paid training materials, non-public materials, and similar sources are not used as information sources.

The content of this website does not represent the views, policies, or positions of any organization, group, company, or other third party with which the author is affiliated or has a relationship.

No warranty is made as to the accuracy, completeness, or usefulness of the information on this website. The author assumes no responsibility for any damages arising from the use of, or inability to use, the content of this website.