Logo

dev-resources.site

for different kinds of informations.

Change WSL/Docker files to another disk

Published at
9/1/2024
Categories
docker
wsl
Author
gabrielmodog
Categories
2 categories in total
docker
open
wsl
open
Author
12 person written this
gabrielmodog
open
Change WSL/Docker files to another disk

Introduction

I'm writing this post to help when I forget how to do this or if someone else needs a little help with this kinda of issue.

Motivation

I use more than one SSD. My main SSD was being filled with my development files from WSL and Docker. So I wanted find a way to move this data to another disk. Testing and searching I found a way to do so.

Getting Things Done

First of all you need to check if your WSL is running:

wsl -l -v
Enter fullscreen mode Exit fullscreen mode

You might get something like this:

  NAME                   STATE           VERSION
* Ubuntu                 Running         2
  docker-desktop-data    Running         2
  docker-desktop         Running         2
Enter fullscreen mode Exit fullscreen mode

if STATE is Running you have to shutdown WSL:

wsl  --shutdown
Enter fullscreen mode Exit fullscreen mode

Now we will export the WSL data to another place:

wsl --export docker-desktop-data "<your-new-wsl-data-location>\docker-desktop-data.tar"
Enter fullscreen mode Exit fullscreen mode

Exporting data maybe will take a while. When finished, we need to unregister the distro by using this command:

wsl --unregister docker-desktop-data
Enter fullscreen mode Exit fullscreen mode

WARNING: your ext4.vhdx data will be removed as well from the original file destination.

wsl --import docker-desktop-data "<new-data-location-folder>" "<new-data-location-folder>\docker-desktop-data.tar" --version 2
Enter fullscreen mode Exit fullscreen mode

WARNING: you see we put a flag --version 2, this is the version of WSL distro.

Conclusion

You can delete ONLY the <your_docker_path>\wsl\data\docker-desktop-data.tar file. Don't delete others files the might be in the folder!

Thanks for read until right here and I hope this help.

wsl Article's
30 articles in total
Favicon
Update WSL Ubuntu password
Favicon
Building OpenCV 4.10.0 with GUI Support in WSL
Favicon
Video: Install Ubuntu using WSL 2
Favicon
Install Zellij on WSL
Favicon
Work from anywhere with VSCode Remote Tunnels
Favicon
SSL verification error at depth 2 - Zscaler | WSL
Favicon
Accelerate 1-bit LLM Inference with BitNet on WSL2 (Ubuntu)
Favicon
Just start using WSL
Favicon
Change WSL/Docker files to another disk
Favicon
Setup your laravel 11 in windows
Favicon
Install Ubuntu on WSL 2
Favicon
How to Install WSL from PowerShell on Windows 10 and 11
Favicon
WSL in AWS Windows Server 2022 Core instance
Favicon
Docker Installation Log for WSL 2 on Windows
Favicon
Enable WSL shell in GitHub Desktop
Favicon
Installing Ruby using rbenv on your WSL Ubuntu system
Favicon
How to Install Redis on Windows Using WSL2
Favicon
PowerShell Development in Neovim
Favicon
WSL: Gerenciando o disco da distro
Favicon
Docker
Favicon
Share Postgresql from Windows to WSL Linux
Favicon
Add Manjaro into WSL 2
Favicon
Using WSL2 as primary driver for 3 months with Fedora
Favicon
Wsl installation error
Favicon
Install Debian in Different Location -WSL Windows
Favicon
Monitor GPU Usage in WSL debian
Favicon
Dicas e configurações para seu sistema linux
Favicon
Instalando de maneira rápida e eficiente suas ferramentas no WSL. Pt-3
Favicon
Arch install azure cli
Favicon
Melhorando e configurando seu novo Shell linux. Pt-2

Featured ones: