2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

公式情報をもとに WSL2 を D drive にインストールする

Posted at

C drive が OS、D drive が大容量の人向け。
実験装置を使うため Windows で、それを Linux のみのツールを解析したい人は一定数いるはず?
この場合、WSL2 も D drive に置き、解析に使うファイルを WSL2 の root にコピーして使うのが良さそう。
WSL2 の D drive へのインストールを AI に聞いても公式情報か不明の答えばっかりだった(実際、公式情報が散らばっていた)ので、公式情報をまとめた。

前提

wsl コマンドが powershell で使える。
まだの場合は、powershell で

wsl --install --no-distribution

方法1 WSL2 を C drive で使ったことがない人向け

公式情報

Ubuntu-24.04 の場合の例

  1. https://cloud-images.ubuntu.com/wsl/releases/noble/current/ にて ubuntu-noble-wsl-amd64-wsl.rootfs.tar.gz をダウンロード(D:\Downloads に置いたとする)
  2. WSL のインストール先のフォルダを作る
    mkdir D:\WSL\Ubuntu2404
    
  3. Powershell で以下
    wsl.exe --import Ubuntu-24.04 D:\WSL\Ubuntu2404 D:\Downloads\ubuntu-noble-wsl-amd64-wsl.rootfs.tar.gz
    

方法2 WSL2 を C drive で使っていて、移行したい人向け

公式情報

# Export your distro to that folder as a VHD
wsl --export <Distro, e.g: Ubuntu> <FileName, e.g: D:\WSLDistros\Ubuntu\ext4.vhdx> --format vhd

# Unregister your old distro
# Please note this will erase your existing distro's file contents, please ensure the backup file you created in the 2nd step is present at the location and that the export operation completed successfully.
# Please exercise caution when using this command, as it is destructive and could cause data loss.
wsl --unregister <Distro, e.g: Ubuntu>

# Import your VHD backup
wsl --import-in-place <Distro, e.g: Ubuntu> <FileName, e.g: D:\WSLDistros\Ubuntu\ext4.vhdx>

実はこっちのほうが単純かも。
いったん公式情報に沿って C drive にインストールしてから、上記の方法で D drive に移してもよいかも。
(ただ、この場合 C drive で 1 GB 程度の書き込み&消去を行うため、最初から D drive へインストールする方がドライブには優しい。)

2
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?