Microsoft

Moving your installed WSL Linux Distro

Why start this series with moving Distro’s around and not just about installing? Simple, The distro’s tend to default their install on the C: drive in the login user App Data space (don’t even get me started on over loading c:\users\<YourUserName>).

So what’s the problem with c:\users\<YourUserName>\AppData\Local?  where do I begin… protected? hidden? Filling up your c: drive… pick one. But the most annoying one when it comes to Windows WSL distros… the install places these in the package folder. So c:\users\<YourUserName>\AppData\Local\Packages, and it does it in a way that usually involves a GUID like naming… Get the picture?

Ok, enough harping on it… Let’s get to moving things about.

You start with getting the most handy little utility called LxRunOffline. You can go to their GitHub page:

[visual-link-preview encoded=”eyJ0eXBlIjoiZXh0ZXJuYWwiLCJwb3N0IjowLCJwb3N0X2xhYmVsIjoiIiwidXJsIjoiaHR0cHM6Ly9naXRodWIuY29tL0REb1NvbGl0YXJ5L0x4UnVuT2ZmbGluZSIsImltYWdlX2lkIjotMSwiaW1hZ2VfdXJsIjoiaHR0cHM6Ly9hdmF0YXJzMy5naXRodWJ1c2VyY29udGVudC5jb20vdS8yNTg1NjEwMz9zPTQwMCZ2PTQiLCJ0aXRsZSI6IkREb1NvbGl0YXJ5L0x4UnVuT2ZmbGluZSIsInN1bW1hcnkiOiJBIGZ1bGwtZmVhdHVyZWQgdXRpbGl0eSBmb3IgbWFuYWdpbmcgV2luZG93cyBTdWJzeXN0ZW0gZm9yIExpbnV4IChXU0wpIC0gRERvU29saXRhcnkvTHhSdW5PZmZsaW5lIiwidGVtcGxhdGUiOiJ1c2VfZGVmYXVsdF9mcm9tX3NldHRpbmdzIn0=”]

Lots of mucking about with install verbiage (that’s a bit on the side of… yeah you really don’t need to do all of that on windows 10). Just go to the release page and download the zip file already:

[visual-link-preview encoded=”eyJ0eXBlIjoiZXh0ZXJuYWwiLCJwb3N0IjowLCJwb3N0X2xhYmVsIjoiIiwidXJsIjoiaHR0cHM6Ly9naXRodWIuY29tL0REb1NvbGl0YXJ5L0x4UnVuT2ZmbGluZS9yZWxlYXNlcyIsImltYWdlX2lkIjotMSwiaW1hZ2VfdXJsIjoiaHR0cHM6Ly9hdmF0YXJzMy5naXRodWJ1c2VyY29udGVudC5jb20vdS8yNTg1NjEwMz9zPTQwMCZ2PTQiLCJ0aXRsZSI6IlJlbGVhc2VzIMK3IEREb1NvbGl0YXJ5L0x4UnVuT2ZmbGluZSIsInN1bW1hcnkiOiJBIGZ1bGwtZmVhdHVyZWQgdXRpbGl0eSBmb3IgbWFuYWdpbmcgV2luZG93cyBTdWJzeXN0ZW0gZm9yIExpbnV4IChXU0wpIC0gRERvU29saXRhcnkvTHhSdW5PZmZsaW5lIiwidGVtcGxhdGUiOiJ1c2VfZGVmYXVsdF9mcm9tX3NldHRpbmdzIn0=”]

Unzip to a favorite directory… one that is in your execute path works fine. This gives one a exe that will execute from either a command window or powershell.

So let’s step through it…

First go ahead and install one or more of your favorite distros for WSL.

Next we move it….

##
##  We will do this in Powershell
##
##  Start with choosing a place we want our distro's to live... in my case the root distro I do is D:\cseWSL\<distroName>
##

## Find your user
##
D:\>whoami

## I get something like
mysystem\scott

## Next for the location you wish to move the distro to... i.e. in my case d:\cseWSL\Ubuntu18
## I'm doing my Ubuntu 18.04 
##  We set some access control to that directory
icacls d:\cseWSL\Ubuntu18 /grant "scott:(OI)(CI)(F)"
## Here we are setting some inheriate properties and full file access to my user
## you can lookup icacls and what those parameters are from the internet

## Finding out what the distro names are
##
LxRunOffline list 

Ubuntu

##This is same as the WSL -l  command

## You can list the current location of a distro using
LxRunOffline get-dir -n Ubuntu
## The -n <distro Name> is required for the get-dir command
## For my Fedora distro I get something like this
....  \AppData\Local\Packages\WhitewaterFoundryLtd.Co.FedoraRemixforWSL_kd1vv0z0vy70w\LocalState

## Now the magic part... Moving a distro
LxRunOffline move -n Ubuntu -d d:\cseWSL\Ubuntu18
##  the -n and -d are required for the move command
##  if the named distro exists and the directory exists, then this will move the distro over
##
## To check that everything is ok with the move
## Do another LxRunOffline get-dir -n
## and see the new location
##
## Then of course, run your distro to make sure it starts up
## LxRunOffline provides a run command
LxRunOffline run -n Ubuntu

## Or start the moved distro in the normal way


 


Seems a little much to do… but not really.  It comes down to Create a Directory destination, set some permissions, and then run a command.

There we are… distros located in a Happy Place.

Next up: Backing up your WSL Distro and Copying it to another PC

Back to Index of WSL Articles

~SG

 

 

One Comment

Leave a Reply