Automount vhdx disk images via [automount] settings .wslconfig , wsl.conf
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.
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:
- Fail to auto attach(mount) a vhd file with /etc/wsl.conf (#9864), similarity score: 0.74
- Mount a Linux disk in WSL 2 automatically on WSL 2 start via .wslconfig (#8010), similarity score: 0.72
- Configuration Options for Mounting Physical Drive(s) or VHDX(s) when WSL Starts (#11029), similarity score: 0.70
Closed similar issues:
- A guideline/Howto to mount a VHDX image in WSL2 (#5247), similarity score: 0.75
- Why my wsl.conf automount options not working? (#6258), similarity score: 0.73
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
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.
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
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.