1
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?

WSLの場所替え

Last updated at Posted at 2025-01-15

緒言

Cドライブ容量が小さすぎるがDドライブがバカでかいとき、WSLの場所をDドライブにしたいなと思った。
以下のようにすればよい。
術式,不義遊戯!!!

方法

PowerShellを管理者として実行する

  1. 以下を実行してWSLをエクスポート。ディストリビューション名は自分のものに適宜変えること.

    wsl --export Ubuntu-xx.xx D:\WSL\Ubuntu-xx.xx.tar
    
  2. 「この操作を正しく終了しました」と出るので、一旦シャットダウン

    wsl --shutdown
    
  3. いったん登録も解除しておく

    wsl --unregister Ubuntu-xx.xx
    
  4. WSLをインポートする。

    wsl --import Ubuntu-xx.xx D:\WSL\Ubuntu D:\WSL\Ubuntu-xx.xx.tar
    
  5. 「この操作を正しく終了しました」と出たらOK。

  6. ext4.vhdxファイルがD:\WSL\Ubuntu内にあれば成功である。

  7. 以下のコマンドを実行し、/dev/sdcが示すものがWSLの使える領域(容量)である。

    df -h
    

そして晴れてUbuntu-xx.xxを起動すると...
なぜかroot権限でのログインがデフォルトになっている模様...
そこで以下を実行

nano /etc/wsl.conf

で編集する。以下を入力。

[user]
default=myuser

myuserはユーザ名なので適宜変更すること。

1
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
1
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?