As you know, WSL 2 provides Windows users with a powerful, efficient and flexible Linux environment, especially for developers. It combines the advantages of Windows and Linux to provide a more comprehensive and efficient working environment. However, the disadvantage is also obvious, that is, it is installed on the C drive by default, which is not rich in space.
This time we quickly install a wsl2 based linux development environment on a non-C disk drive and painlessly use Win11's web proxy service.
Installation of WSL 2
First of all, make sure that the local computer has been opened to open the Windows virtualization and Linux subsystem, click Control Panel - & gt; Programs - & gt; Enable or disable windows function, open the Windows virtualization and Linux subsystem (WSL2) and Hyper-V
Subsequently, enter the command in the terminal:
bcdedit /set hypervisorlaunchtype auto
Turn on hyper-v.
Subsequently, enter the command in the terminal:
wsl --update
Upgrade system version
Next install the ubuntu system:
wsl --install -d Ubuntu
After entering your username and password, you will be automatically logged in as a linux system:
At this point, WSL 2 has been successfully installed.
WSL 2 system transfer
Now let's migrate the linux system to a different drive letter and create the directory backup on a non-C drive letter.
mkdir backup
Then run the command:
wsl --export Ubuntu D:\backup\
Export the installed system to the backup directory.
Next, log off the linux system on the C drive:
wsl --unregister Ubuntu
Create a new wsl directory:
mkdir wsl
Import the ubuntu system you just exported:
wsl --import Ubuntu D:\wsl\ D:\backup\
At this point, the wsl2 system has been successfully migrated.
Installing cuda and using Win11's web proxy
Installing cuda is easy, just go directly to nvidia's official website:
/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=deb_local
Copy the officially given installation commands:
wget /compute/cuda/repos/ubuntu2204/x86_64/
sudo mv /etc/apt//cuda-repository-pin-600
wget /compute/cuda/12.6.0/local_installers/cuda-repo-ubuntu2204-12-6-local_12.6.0-560.28.03-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2204-12-6-local_12.6.0-560.28.03-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2204-12-6-local/cuda-*- /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-6
After successful installation, type nvidia-smi to display the graphics card information:
At this point the cuda installation is complete.
Although it is already working properly, the system will prompt:
It means that although win11 has a proxy configuration, it is not mirrored to wsl and cannot use the proxy.
Engage in development if there is no proxy service, then what development, is not a fool's errand, why is it easy to blind son of the night.
Create a new: .wslconfig configuration file in the user directory:
[experimental]
autoMemoryReclaim=gradual # gradual | dropcache | disabled
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true
Then run the command to restart the wsl service:
wsl --shutdown
Go to linux again and test to see if you can access twitter.
wget
The system returns:
(base) root@ly:~# wget
--2024-08-02 17:08:49-- /
Connecting to 127.0.0.1:7890... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: / [following]
--2024-08-02 17:08:49-- /
Connecting to 127.0.0.1:7890... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘’
[ <=> ] 2.55K -.KB/s in 0s
2024-08-02 17:08:50 (1.13 GB/s) - ‘’ saved [2610]
(base) root@ly:~#
Cozy up.
Note that Win11's proxy service needs to be turned on: allow LAN access.