SixFoisNeuf

Totally irregular blog on computers and security


Accessing the WSL2 filesystem from outside Windows

Written on Sep 19, 2024

Quick tip I wish was easier to find: how to get access to your WSL2 files when you’re not currently running Windows and need to access a script that’s stored there.

  • Go to Users/<USERNAME>/AppData/Local/Packages/
  • Enter either CanonicalGroupLimited... or TheDebianProject..., depending on whether you got Ubuntu or Debian from the Store
  • Your rootfs is in LocalState/ext4.vhdx

You can mount it with libvhdi:

$ sudo apt install vhdiutils
$ sudo vhdimount ext4.vhd /mnt/vhd
$ sudo mount -o ro /mnt/vhd/vhd1 /mnt/wsl