Run Windows CMD as administrator:
wsl -l -o // list available Linux options
wsl --install -d <Linux name> // install the specified Linux
Reference:
The first method allows basic GUI usage. The second method ensure a long-term GUI operation.
Install GUI related package such as:
sudo apt install ubuntu-desktop
sudo apt install nautilus
export DISPLAY=<WINDOWS LOCALHOST IP>:0.0
You can find your Windows localhost IP by “ipconfig” in Windows CMD.
There might be difference in wsl 1 or 2. Check your version with these tips: https://linuxhint.com/check-wsl-version/
Reference:
Method allows basic GUI usage. Method-2 uses an additional utility to ensure X server continue working after host sleeps or alter network setting.
Similar to method-1 we install required package. But we set port to
export DISPLAY=:0
Next, download and run wsld
Similar to method-1. In addition, download and run wsldhost.ext –daemon with admin privilege.
All these can be done on system boot with shell or batch script.
apt-get install -y cuda-toolkit-11-4
In windows CMD
wsl --export Ubuntu-20.04 tmp.tar
wsl --unregister Ubuntu-20.04
wsl --import Ubuntu-20.04 <PATH_TO_STORE_VM> tmp.tar
[network]
hostname = WSL # in case manually setting machine name
generateHosts = false # in case manually setting machine name
[user]
default = <USERNAME>
sudo rm /etc/resolv.conf
sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'
sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf'
sudo chattr +i /etc/resolv.conf # prevent overwrite
Run PowerShell as administrator:
GET-CimInstance -query "SELECT * from Win32_DiskDrive" # now the device path
wsl --mount \\.\PHYSICALDRIVE2 --bare # mount
wsl --unmount \\.\PHYSICALDRIVE2 # unmount
In WSL:
lsblk # see mounted disk
mount /dev/sdc1/ /mnt/wsldisk2 # mount sdc's sdc1 to '/mnt/wsldisk2' folder
In case formatting is needed
sudo mkfs.ntfs -f /dev/sdc1/
Ubuntu 20 running in WSL seems weakly supports i386 packages.
dpkg -x <DEB_FILE_NAME> <DESTINATION_DIRECTORY>
A few highlight
in src/pulsecore/mutex-posix.c
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#undef HAVE_PTHREAD_PRIO_INHERIT // add this line
After installing
export PULSE_SERVER=tcp:localhost # your host IP
# in Windows power shell
Resize-VHD -Path <YOUR_VIRTUAL_DISK> -SizeBytes <NUM> # can append MB or GB to specify unit
sudo resize2fs /dev/sdc # assume the disk is mounted at /dev/sdc, by default it fits partition to disk size
wsl --mount --vhd E:\wsldisk2.vhdx # in powershell
In case access denied, repeat following
In case system hang during using large software, or installing large software, simplify your PATH by removing unessential 9p filesystem paths.