microsoft / microsoft/WSL

[Feature] Adding --name parameter to wsl --mount

Open
#6,489 3 comments 0 reactions 1 assignee View on GitHub

@OneBlue is already working on this.

Since Feb 2, 2021.

feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

As by the docs: https://docs.microsoft.com/en-us/windows/wsl/wsl2-mount-disk

$disk = "\\.\PhysicalDrive$((Mount-VHD -Path D:\data_disk.vhdx -PassThru | Get-Disk).Number)"
# assuming \\.\PhysicalDrive5
wsl --mount $disk -p 1

This will mount a VHD to /mnt/wsl/PhysicalDrive5p1

The problem is, if, at some point, other hard drives get attached to (or removed from) windows, /mnt/wsl/PhysicalDrive5p1 becomes no longer a reliable fixed mount point in WSL.

Use-case: Setting up WSL to use PhysicalDrive5p1 as the home-folder of the Linux user

Create a folder /mnt/wsl/PhysicalDrive5p1/<username>
ln -s /mnt/wsl/PhysicalDrive5p1/<username> /home/<username>

Problem: After attaching/detaching other hard drives PhysicalDrive5p1 becomes PhysicalDrive6p1 or PhysicalDrive4p1 which breaks the existing symlink.

Solution

wsl --mount $disk -p 1 --name dataDisk
ln -s /mnt/wsl/dataDisk/<username> /home/<username>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.