Skip to content

Latest commit

 

History

History
64 lines (46 loc) · 3.37 KB

migrating-to-wsl2.md

File metadata and controls

64 lines (46 loc) · 3.37 KB

Migrating from WSL1 to WSL2

Note: There is a WSL Runtime that is distributed through the Windows Store. This is still in preview and not reliable. If a students 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)

Steps

  1. Install/Enable WSL2
  2. Install new Ubuntu Distro
  3. Configure Software for the new VM
  4. Migrate data to new Distro
  5. Change file/folder permissions

Install/Enable WSL2

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 he 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

Install new Ubuntu Distro

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.

  1. Open the Microsoft Store
  2. Search for "Ubuntu"
  3. Install either "Ubuntu" or "Ubuntu 20.04", whichever one you do not have installed as WSL1.

Configure Software for the new VM

  1. Open the new distribution.
  2. Input Username and Password ((These credentials do not need to be the same as the previous Distribution or Windows))
  3. Install Node.js
  4. Install Python

Migrate data to new Distro

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.

  1. Open both the old and new Ubuntu installations
  2. Open Windows File Explorer and navigate to \\wsl$
  3. 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.
  4. Open the home directory in each distribution followed by the username directory.
  5. Drag and drop any files that are wanting to be kept.

Change file/folder permissions

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 here