I've been using Ubuntu on VirtualBox for about a year now, but I recently learned about WSL, and it seems a lot more useful for my purposes. I've been trying to migrate all my data out of the VirtualBox VM, but I'm unable to find any resources online that tell me how to do so. I was able to migrate my VM and all the data within to Hyper-V in the hopes that migration from Hyper-V to WSL2 would be simpler, but so far that process eludes me too.

Right now all I want is access to all the files that are in my VM, from outside the VM (i.e. accessible from WSL).

Any advice would be much appreciated!


You can go several routes here:

  • As mentioned in the comments, this question covers how to directly mount the VirtualBox disk image directly in Ubuntu. While I haven't tried it, I can't see any reason that this won't work on WSL2 (but it will not on WSL1).

    One thing to keep in mind will be size and performance. I'm assuming that the .vdi is on a Windows drive at the moment, so you'll need to access it using /mnt/c/path/to/vdi (or /mnt/d, etc.). The performance when accessing files on Windows drives under WSL2 is quite a bit degraded, but that's generally only a problem when dealing with a lot of smaller files. I'm not sure, but I think performance will be okay with a single large .vdi. It's a "one-time-only" thing anyway, so I'm sure that degraded performance won't be a total showstopper, at least.

    Alternatively, if you choose to copy your .vdi into WSL before mounting, realize that it will grow the size of the WSL virtual disk, and the space that is consumed won't be reclaimed when you delete the .vdi (or move it back "out" of WSL2. See my answer here on Super User for details on how to reclaim the space if you end up in this situation.

  • Alternatively, you might choose to use a network share/copy from VirtualBox to WSL. The trick here is making sure that the network is accessible, but I don't think that's going to be a problem when attempting to contact your VirtualBox VM from WSL2. If you have trouble connecting, let me know, and we can work on that part.

    Assuming that you have ssh set up inside the existing VM, you can always use sftp or scp to copy files over manually to WSL.

    Or, if you have Samba installed in the VM, you can simply mount the CIFS share from inside WSL2. See this answer on Stack Overflow (also off-topic since it's not programming-related, but some of them slip through) along with the other answers to that question about mounting Samba shares.