2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WSLのコマンドと関連する情報の確認方法など

Posted at

1.この記事の内容

使う頻度の低いコマンドなどは忘れやすいので,この記事に集約することにしました.
コマンドの仕様はwsl --helpやMicrosoft公式のWSL の基本的なコマンドを参照するものとして,この記事には筆者が使うことのあるものを中心に残すこととします.

2.WSLのコマンドなど

2-1.ディストリビューションの一覧

> wsl --list --verbose
  NAME              STATE           VERSION
* Ubuntu-22.04_E    Exporting       2
  Ubuntu-20.04      Stopped         2
  Ubuntu-22.04      Stopped         2

2-2.ディストリビューションのシステムサイズ確認

> wsl --system -d <distribution name> df -h /mnt/wslg/distro
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb       1007G  439G  517G  46% /mnt/wslg/distro

2-3.仮想ハードディスクの保存場所の確認

レジストリエディタのLxssのBasePathで確認できます.

image.png

PowerShellなどのコマンドなら,Get-ItemPropertyで確認できます.

> Get-ItemProperty -Path Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\*

2-4.仮想ハードディスクの保存場所の変更方法

ディストリビューションのインストール時に指定した場所に保存することはできないようで,wsl exportwsl importの手順が必要なようです.

  1. WSLを停止
    > wsl --shutdown
    
  2. exportする
    > wsl --export <distribution name> <destination path>
    
  3. 登録を解除(unregister)する
    > wsl --unregister <distribution name>
    
  4. importする
    > wsl --import <distribution name> <install path> <exported tar>
    

3.さいごに

他にWSLの使い方に関して忘れて困るようなものを思い出したらこちらの記事に加筆していこうと思います.
なお,筆者が遭遇するトラブルへの対処方法については,WSLで良くあるトラブルと対処方法に書いていますので,よろしければ参照ください.

4.関連リンク

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?