microsoft / microsoft/WSL

wsl --mount --vhd <volume>.vhdx --bare should report the device used to attach the volume

Open
#10,988 2 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

**Is your feature request related to a problem? Please describe.**
I would like to be able to script the creation of a WSL distro from bash and I can (from a WSL distro running from a PowerShell admin session) do:

```
powershell.exe New-VHD -Path /mnt/c/Users/mlwp/Storage/Projects3Dynamic.vhdx -SizeBytes 256GB -Dynamic -BlockSizeBytes 1MB
wsl.exe --mount --vhd Projects3Dynamic.vhdx --bare # attaches as /dev/sd? but does tell me which
mkfs.btrfs -f -L projects3 /dev/sdi
wsl --mount --vhd C:/Users/mlwp/Storage/Projects3Dynamic.vhdx --name projects3
```

**Describe the solution you'd like**
wsl.exe --mount should return device where volume is mounted

**Describe alternatives you've considered**
Not clear what if any other options I have for an automated script

**Additional context**
This is part of my attempt to script my workflows

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the documented bash and PowerShell sequence with `wsl.exe --mount --vhd ... --bare` and observe its current output. Trace the `--mount --vhd --bare` CLI entry point and define completion as reporting the device attached to the volume so the subsequent formatting command can use it without a hard-coded `/dev/sd?` path.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, shell
Domain
cli, operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.