1
0
mirror of https://github.com/avinal/avinal.github.io.git synced 2026-07-03 23:30:09 +05:30
Files
avinal.github.io/content/posts/development/wsl1.md
T
avinal 62efd95607 feat: use new theme for the website
Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
2025-01-01 23:39:45 +05:30

2.7 KiB

category, date, description, image, tags, title
category date description image tags title
development 2020-12-31T19:07:00 It is real pain when you have small SSD and Windows Subsystem for Linux (WSL) is growing exponentially in size. There is no easy way to move the WSL installation to another drive. Here in this blog I will discuss how to tackle this problem with bite size steps. /images/windows-wsl2.webp
wsl
wsl2
Move WSL 2 Safely to another Drive

It is real pain when you have small SSD and Windows Subsystem for Linux (WSL) is growing exponentially in size. There is no easy way to move the WSL installation to another drive. Here in this blog I will discuss how to tackle this problem with bite size steps.

  1. Open a PowerShell or Command Prompt with Admin access. For this you can use WinKey + X shortcut and select Windows PowerShell(Admin).
  2. Check if the WSL 2 installation you are planning to move is is currently running/stopped.
PS C:\\Users\\Avinal> wsl -l -v
PS C:\\Users\\Avinal>
  NAME      STATE           VERSION
* Ubuntu    Running         2
  Kali      Stopped         2
  1. If its running then you must stop the particular WSL distribution. (Ubuntu used as example)
PS C:\\Users\\Avinal> wsl -t Ubuntu
  1. Export to some folder. (Here exporting Ubuntu as ubuntu-ex.tar to Z:wsl2)
PS C:\\Users\\Avinal> wsl --export Ubuntu "Z:\\export\\ubuntu-ex.tar"
  1. Unregister previous WSL installation
PS C:\\Users\\Avinal> wsl --unregister Ubuntu
  1. Create a new folder and import your WSL installation to that folder.
PS C:\\Users\\Avinal> New-Item -Path "Z:\\wsl2" -ItemType Directory

    Directory: Z:\\

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        31-12-2020     21:03                wsl2

PS C:\\Users\\Avinal> wsl --import Ubuntu "Z:\\wsl2" "Z:\\export\\ubuntu-ex.tar"
  1. Check after import is complete
PS C:\\Users\\Avinal> wsl -l -v
PS C:\\Users\\Avinal>
  NAME      STATE           VERSION
* Ubuntu    Running         2
  Kali      Stopped         2
  1. Mark one of your WSL distribution as (default).
PS C:\\Users\\Avinal> wsl -s Ubuntu
  1. After exporting your default user will be set as root , to change it to your desired username, run following command
PS C:\\Users\\Avinal> ubuntu config --default-user user_name
  1. Finally run wsl and you have successfully moved your WSL 2 installation to another drive.

Attribution