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

Code

  • DevPage

Uncategorized

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.

Connect To Local’s MySQL Socket on MacOS Catalina

Reading Time: < 1 minute

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 similar steps are used to connect on Linux.

This guide is set up to help you connect to Local’s MySQL socket to do whatever you need through MySQL CLI. If you don’t already have MySQL running on your computer, please install MySQL first before continuing. If you already have MySQL installed, continue reading.


Now that you have MySQL installed, let’s visit Local to get the socket information.

  1. Make sure the site is running.
  2. Click on Database and you’ll see a screen similar to mine.
  3. Copy the text in the “Socket” area.
local mac

Now on the command line, enter the command shown below and press enter. You should be greeted with MySQL command line.

🎷 ➜ ~ mysql -uroot -proot --socket "/Users/client35/Library/Application Support/Local/run/BqChVVe5X/mysql/mysqld.sock"
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Happy coding!

Primary Sidebar

Categories

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

Secondary Sidebar

Copyright © 2025 · eleven40 Pro · spanish · devment