Follow these insttructions if your Windows device is currently set up with WSL1. You will need to use WSL2 for the course.
Note: There is a WSL Runtime that is distributed through the Windows Store. This is still in preview and not reliable. If your terminal window says "Windows Subsystem for Linux [Preview]" it likely means that they are using the WSL Runtime from the Microsoft Store. Uninstall this before following the steps below. (It's treated like a normal Windows Application in settings).
- Install/Enable WSL2
- Install new Ubuntu Distro
- Configure Software for the new VM
- Migrate data to new Distro
- Change file/folder permissions
To install WSL1 you previously ran the following command in Powershell:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
To continue onto the more stable and robust WSL2 we run the following commands in Powershell to enable virtualization:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Once Virtualization is enabled, we'll want to run/install the Linux Kernal Update package found here.
WSL2 should now be configured. Now we want to instruct newly installed Distros to utilize WSL2 instead by running the following Powershell command:
wsl --set-default-version 2
Distro is shorthand for distribution. The preference for this course is the Ubuntu Distribution. There are three versions listed in the Microsoft Store. It doesn't matter which one we use but the preference would be Ubuntu or Ubunutu 20.04.
- Open the Microsoft Store
- Search for "Ubuntu"
- Install either "Ubuntu" or "Ubuntu 20.04", whichever one you do not have installed as WSL1.
- Open the new distribution.
- Input Username and Password (These credentials do not need to be the same as the previous Distribution or Windows)
- Install Node.js
- Install Python
Because this is a new distribution, it contains none of the data we've created previously in the WSL1 instance. We can migrate the data using Windows Explorer.
- Open both the old and new Ubuntu installations
- Open Windows File Explorer and navigate to
\\wsl$
- There should be two folders, one for each distribution. Open each one in a separate window so we can drag-and-drop files between distributions.
- Open the home directory in each distribution followed by the username directory.
- Drag and drop any files that are wanting to be kept.
By transferring files across distributions, we lose access to read and write files in the new distribution. To fix this we can take ownership of those files be running the following command in the new distribution where files were transferred to.
chown -R $USER DIRECTORY
Where DIRECTORY
is any folders with files you wish to take ownership of.
installation of WSL2 sourced from this source