Skip to content

Easily move your WSL distros VHDX file to a new location.

License

Notifications You must be signed in to change notification settings

mystery-e204/move-wsl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Move WSL

Bash, batch and PowerShell script to move WSL 2 distros VHDX file to a different location.

Interactive Example

Usage

Bash

Use with git bash for Windows or similiar.

Interactive way

  1. ./move-wsl
  2. Select your distro
  3. Enter your target (i.e. /d/wsl target/ubuntu)

Explicit way

  1. Get a list of WSL distros: wsl -l
  2. Move your image: ./move-wsl [NAME] [LOCATION]

Example: ./move-wsl docker-desktop /d/docker

PowerShell

Interactive way of moving wsl for Windows PowerShell.

  1. ./move-wsl.ps1
  2. Select your distro
  3. Enter your target (i.e. D:\wsl target\ubuntu)

Batch

This is a lightweight version which can also be used from Windows CMD.

  1. Get a list of WSL distros: wsl -l
  2. Move your image: move-wsl.bat [NAME] [LOCATION]

Example: move-wsl.bat docker-desktop D:\docker

FAQ

Default user was switched to root when moving a distro

Set your default user inside your distro by adding this to your /etc/wsl.conf

[user]
default=YOUR_USERNAME

Then exit your distro, terminate it (wsl -t YOUR_DISTRO) and start it again.

Standard distro switched when moving it distro

Since we need to unregister to import it with the same name, the standard distro can be switched. Just set your standard distro again:

wsl -s YOUR_DISTRO

Changelog

1.2.1 - 2020-07-07

Feat: Better error handling of export by Schop0.
Fix: Replace newlines in wsl command output as it broke selection sometimes.

1.2.0 - 2020-06-23

Feat: Added PowerShell version by sidecus.

1.1.2 - 2020-06-22

Change: Use -q query for more parseble output of distros.

1.1.1 - 2020-05-29

Fix: (Default) appendix was breaking distro selection in interactive mode.

1.1 - 2020-04-14

Feat: Add interactive mode for bash script.

1.0 - 2020-04-13

Feat: Add validation for successfull export and import for bash and batch script.

About

Easily move your WSL distros VHDX file to a new location.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PowerShell 50.8%
  • Shell 32.2%
  • Batchfile 17.0%