• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar

Code

  • DevPage

How to Migrate Data Between WSL Distros

Reading Time: 2 minutes

I wrote this guide because I searched forever and couldn’t find a solution that I was needing; I even asked ChatGPT and Microsoft Copilot – both weren’t nearly as helpful – alas it could have also been my prompt. Anyway, I digress.

This guide helps with copying data from one Linux distro running in WSL to another Linux distro.

I was running Windows 10 and started testing out WSL in the early days of development using WSL and Ubuntu 18.04. As WSL grew in popularity and has matured, it seems like MS has baked in better ways to distribute and download Linux distros on Windows.

Fast forward to this year when I decided to upgrade to Windows 11, only realizing after the fact that I now have to manage Ubuntu through MS Store and didn’t seem like a straightforward way to migrate data between the two. For context: I had already installed the latest Ubuntu from the Microsoft Store and didn’t want to completely erase what I set up. In short, I needed a way to migrate data from my older Ubuntu installation to the new one. Okay, enough talking, let’s dive in.


Using the details below, I was able to migrate my crucial data from my source distro to my destination distro.

Source: Ubuntu 18.04
Destination: Ubuntu 22.04

The path to where your distros are stored look like the following. Remember to replace [USER], [DISTRO] and [DRIVE] with your own.

C:\Users[USER]\AppData\Local\Packages[DISTRO]\LocalState\[DRIVE]

Steps

  1. Start Windows PowerShell as an Administrator
  2. Run the following commands.
    • The wsl --mount command makes it so that the drive shows up the devices list when running sudo lsblk.
# lists out all Linux-based distributions installed on Windows
wsl -l --all

# Shutdown all WSL distros
wsl --shutdown

wsl --mount 'C:\Users\USER\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx' --vhd --bare

After entering those, you should see “Successfully completed” message in your PowerShell terminal.

Next, start up the distro that you want to transfer files to (in my case Ubuntu 22.04) and run commands to mount the device to a custom directory of your choosing on your destination. You’ll need to replace /mnt/ubuntu18 and /dev/sdc to match your own set up.

sudo mkdir /mnt/ubuntu18
sudo mount /dev/sdc /mnt/ubuntu18

Voila! You should now see your virtual drive mounted inside your destination. From there, you can use the copy tool of your choice (I chose rsync) to copy over your contents.

Connecting to a Remote Database through an SSH Tunnel on WP Engine

In this guide, we'll explore what it's like to connect to a remote database using MySQL, through an SSH tunnel. WP Engine recently stopped allowing direct remote SQL connections to their servers for security reasons, and switched to allowing … [Continue reading] about Connecting to a Remote Database through an SSH Tunnel on WP Engine

Parsing WP Engine Security Auditor Information from Your Error Logs

WP Engine has a plugin called Security Auditor which logs certain activities to a site's error logs. While it can muddy up your logs, it's a great resource, but they only keep the logs for 5 days, so download them from within your WordPress site by … [Continue reading] about Parsing WP Engine Security Auditor Information from Your Error Logs

Connect To Local’s MySQL Socket on MacOS Catalina

If you've ever ran into issues using Adminer, have a large database that you need to manually import, or just want to do some work in MySQL CLI, then this guide is for you!This guide also requires that you have Local setup and are using Mac, although … [Continue reading] about Connect To Local’s MySQL Socket on MacOS Catalina

Cut

No way to cut it

There's no way to cut it when it comes to telling you how to use this great tool! Whenever I've used it, I commonly use it in lieu of a user's home directory: $(pwd | cut -d\/ -f5). This helps me save time from copy and pasting the install name, … [Continue reading] about Cut

  • Page 1
  • Page 2
  • Go to Next Page »

Primary Sidebar

Categories

  • command-line-tutorials (4)
  • how-to-general (1)
  • Uncategorized (2)

Secondary Sidebar

Copyright © 2025 · eleven40 Pro · spanish · devment