You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Mount an EXT file system on Windows (or other filesystem)](#mount-an-ext-file-system-on-windows-or-other-filesystem)
19
+
-[Mount an entire disk](#mount-an-entire-disk)
20
+
-[Mount a partition from a disk](#mount-a-partition-from-a-disk)
21
+
-[Add a desktop environment to your WSL](#add-a-desktop-environment-to-your-wsl)
22
+
-[Some useful commands](#some-useful-commands)
23
+
-[Appendix - Sources and References](#appendix---sources-and-references)
24
+
8
25
## What is the WSL and how it works ?
9
26
10
27
The WSL for **W**indows **S**ubsystem for **L**inux is a compatibility layer developed by Microsoft for running Linux binaries natively (ELF format) in a console environment on Windows 10 and Windows 11. This ingenious technology provides a Linux-compatible kernel interface and can interact directly with the Windows operating system with performances very close to a native Linux distribution. Moreover, it allows a user to choose a Linux distribution to install directly from the Microsoft Store (more info in below).
@@ -109,11 +126,23 @@ At this moment (when this article was written), you can install these distributi
109
126
110
127
You can install the distribution you want directly on the Windows Store !
111
128
129
+
Or you can install it via a console with the command :
130
+
131
+
```PowerShell
132
+
wsl --install --distribution DistribName
133
+
```
134
+
112
135
## Some useful WSL features
113
136
114
-
### Mount an ext file system on Windows (non-persistent)
137
+
### Mount an EXT file system on Windows (or other filesystem)
138
+
139
+
First, you must be running Windows 11 Build 22000 or higher and have admin privileges. This procedure only works on the WSL 2 and it is non-peristent, the filesystem will be unmounted after WSL shutdown.
115
140
116
-
First, you must be running Windows 11 Build 22000 or higher and have admin privileges. This procedure only works on the WSL 2.
141
+
#### Mount an entire disk
142
+
143
+
To mount an entire disk, we first need to identify the physical disk.
144
+
145
+
In a windows console :
117
146
118
147
```Powershell
119
148
GET-CimInstance -query "SELECT * from Win32_DiskDrive"
@@ -123,13 +152,142 @@ This command should return a list of physical drives in this format :
123
152
124
153
`\\.\PHYSICALDRIVEX` X : number of the physical drive
125
154
155
+
Then we can mount it with the command :
156
+
157
+
```Powershell
158
+
wsl --mount \\.\PHYSICALDRIVEX
159
+
```
160
+
161
+
> Default filesystem is ext4, we can specify the type of filesystem with the argument `t`. We can list the available filesystem with `cat /proc/filesystems`
162
+
163
+
The mounted disk should be now accessible via the Explorer in `\\wsl$\Distro\mnt\PHYSICALDRIVEX`
164
+
165
+
Or directly in the distro used : `/mnt/PHYSICALDRIVEX`
166
+
167
+
#### Mount a partition from a disk
168
+
169
+
To mount only a partition from a disk, we first need to identify the physical disk as before.
170
+
In a windows console :
171
+
172
+
```Powershell
173
+
GET-CimInstance -query "SELECT * from Win32_DiskDrive"
174
+
```
175
+
176
+
Then mount the physcial disk :
177
+
126
178
```Powershell
127
-
wsl --mount DiskPath
179
+
wsl --mount \\.\PHYSICALDRIVEX
180
+
```
181
+
182
+
Now we are going to list the available partitions with :
183
+
184
+
```Bash
185
+
lsblk
186
+
```
187
+
188
+
It should return something like this :
189
+
190
+
```Text
191
+
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
192
+
sdb 8:16 0 1G 0 disk
193
+
├─sdb2 8:18 0 50M 0 part
194
+
├─sdb3 8:19 0 873M 0 part
195
+
└─sdb1 8:17 0 100M 0 part
196
+
sdc 8:32 0 256G 0 disk /
197
+
sda 8:0 0 256G 0 disk
198
+
```
199
+
200
+
We can now mount the partition we want by specifying only the number of the partition. For instance if it's `sdb1`, we specify `1` :
0 commit comments