214 字
1 分钟
WSL换安装位置

WSL换安装位置#

1.查看已安装的linux发行版本

Terminal window
wsl -l --all -v

2. 导出分发版为tar文件到d盘

Terminal window
wsl --export Ubuntu-22.04 e:\WSL\wsl-ubuntu22.04.tar

3. 注销当前分发版

Terminal window
wsl --unregister Ubuntu-22.04

4. 重新导入并安装WSL在D盘

Terminal window
wsl --import Ubuntu-22.04 e:\WSL\wsl-ubuntu22.04 e:\WSL\wsl-ubuntu22.04.tar --version 2

5. 设置默认登陆用户为安装时用户名

Terminal window
ubuntu2204 config --default-user liguolong

6. 删除wsl-ubuntu20.04.tar

Terminal window
del d:\wsl-ubuntu20.04.tar

换源#

Terminal window
# 查看你的 Ubuntu 版本代号
UBUNTU_CODENAME=$(lsb_release -sc)
echo "你的 Ubuntu 版本代号是: $UBUNTU_CODENAME"
# 设置为阿里云源(最稳定)
# 源码仓库(可选)
sudo tee /etc/apt/sources.list << EOF
deb https://mirrors.aliyun.com/ubuntu/ $UBUNTU_CODENAME main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ $UBUNTU_CODENAME-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ $UBUNTU_CODENAME-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ $UBUNTU_CODENAME-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ $UBUNTU_CODENAME main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ $UBUNTU_CODENAME-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ $UBUNTU_CODENAME-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ $UBUNTU_CODENAME-backports main restricted universe multiverse
EOF
# 图像
sudo apt install gimp -y
# 管理夹
sudo apt install nautilus -y

安装桌面#

Reference#

【1】https://blog.csdn.net/w851685279/article/details/108904106

WSL换安装位置
https://tuoyuangui.github.io/website/posts/typora/windows系统/wsl换位置/
作者
椭圆规/tuoyuangui
发布于
2025-07-09
许可协议
CC BY-NC-SA 4.0