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 f…


This content originally appeared on DEV Community and was authored by Gabriel Tavares

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

You might get something like this:

  NAME                   STATE           VERSION
* Ubuntu                 Running         2
  docker-desktop-data    Running         2
  docker-desktop         Running         2

if STATE is Running you have to shutdown WSL:

wsl  --shutdown

Now we will export the WSL data to another place:

wsl --export docker-desktop-data "<your-new-wsl-data-location>\docker-desktop-data.tar"

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

wsl --unregister docker-desktop-data

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

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.


This content originally appeared on DEV Community and was authored by Gabriel Tavares


Print Share Comment Cite Upload Translate Updates
APA

Gabriel Tavares | Sciencx (2024-09-01T23:03:19+00:00) Change WSL/Docker files to another disk. Retrieved from https://www.scien.cx/2024/09/01/change-wsl-docker-files-to-another-disk/

MLA
" » Change WSL/Docker files to another disk." Gabriel Tavares | Sciencx - Sunday September 1, 2024, https://www.scien.cx/2024/09/01/change-wsl-docker-files-to-another-disk/
HARVARD
Gabriel Tavares | Sciencx Sunday September 1, 2024 » Change WSL/Docker files to another disk., viewed ,<https://www.scien.cx/2024/09/01/change-wsl-docker-files-to-another-disk/>
VANCOUVER
Gabriel Tavares | Sciencx - » Change WSL/Docker files to another disk. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/01/change-wsl-docker-files-to-another-disk/
CHICAGO
" » Change WSL/Docker files to another disk." Gabriel Tavares | Sciencx - Accessed . https://www.scien.cx/2024/09/01/change-wsl-docker-files-to-another-disk/
IEEE
" » Change WSL/Docker files to another disk." Gabriel Tavares | Sciencx [Online]. Available: https://www.scien.cx/2024/09/01/change-wsl-docker-files-to-another-disk/. [Accessed: ]
rf:citation
» Change WSL/Docker files to another disk | Gabriel Tavares | Sciencx | https://www.scien.cx/2024/09/01/change-wsl-docker-files-to-another-disk/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.