WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Automount vhdx disk images via [automount] settings .wslconfig , wsl.conf

Open nkrepo opened this issue 1 year ago • 4 comments

There is a need to easily automount vhdx virtual disk images in WSL2 every time WSL2 is booted. Now vhdx can be easily mounted in a WSL2 distro, but only after WSL2 has started and it required to be re-mounted every time WSL2 is rebooted. Various automation scripts and hacks exist to achieve that, but they are not 100% reliable and not elegant.

The proposed solution is to add the ability to mount a vhdx by specifying the image alongside with the mount options in the [automount] section of .wslconfig, wsl.conf every time the WSL2 is booted.

nkrepo avatar Feb 21 '24 08:02 nkrepo

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

github-actions[bot] avatar Feb 21 '24 08:02 github-actions[bot]

I second this.

My current solution is to run the following script (as administrator) any time my development machine reboots

wsl --shutdown; wsl -d Ubuntu --mount --vhd D:\projects\projects.vhdx --bare ; wsl -d Ubuntu /bin/bash -c 'sleep 2 && exit'

I simply wish wsl2 had more options for the powerusers it's supposed to cater to. There is a lot of hand-wavey stuff going on with wsl2 (especially with regards to networking) and it would be nice to customize it for our use-cases without kludges.

Neo-Desktop avatar Jan 28 '25 08:01 Neo-Desktop

I created this gist that shows show to create, mount, and persist additional VHDX drives for WSL2 even after Windows restart AND wsl --shutdown events.

https://gist.github.com/omarmciver/0c85f5a68448aa6c94fee381e5fdbe9b

omarmciver avatar Feb 02 '25 12:02 omarmciver

I support this request. At the moment, the only reliable method seems to be manually mount a VHDX image. On my managed workstation, I have to manually acquire the privilege to do that.

ww9rivers avatar Nov 14 '25 15:11 ww9rivers