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
- As an example, to find the path for Ubuntu, you would enter: `Get-AppxPackage -Name "*Ubuntu*" | Select PackageFamilyName`
179
-

177
+

178
+
179
+
3. Use the resulting `PackageFamilyName` to locate the VHD file `fullpath` used by your WSL 2 installation, this will be your `pathToVHD`. To find the full path:
180
+
- In your Start menu, enter: "%LOCALAPPDATA%" and select to open the %LOCALAPPDATA% file folder.
181
+
- Next, open the "Packages" folder and search for the `PackageFamilyName` of your distribution. Open that folder (ie. CanonicalGroupLimited.Ubuntu20.04onWindows_79xxxxx).
182
+
- Inside the `PackageFamilyName` folder, open the "LocalState" folder and find the `<disk>.vhdx` file.
183
+
- Copy the path to that file, it should look something like:
- For example, the `<pathToVHD>` for Ubuntu 20.04 should look something like: `%LOCALAPPDATA%\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79xxxx\LocalState\ext4.vhdx`.
180
186
181
187
4. Resize your WSL 2 VHD by completing the following commands:
182
188
- Open Windows Command Prompt with admin privileges and enter:
183
189
184
-
```powershell
190
+
```cmd
185
191
diskpart
192
+
```
193
+
194
+
```cmd
186
195
DISKPART> Select vdisk file="<pathToVHD>"
196
+
```
197
+
198
+
```cmd
187
199
DISKPART> detail vdisk
188
200
```
189
201
190
-
- Examine the output of the **detail** command. The output will include a value for **Virtual size**. This is the current maximum. Convert this value to megabytes. The new value after resizing must be greater than this value. For example, if the **detail** output shows **Virtual size: 256 GB**, then you must specify a value greater than **256000**. Once you have your new size in megabytes, enter the following command in **diskpart**:
202
+
- Examine the output of the **detail** command. The output will include a value for **Virtual size**. This is the current maximum. Convert this value to megabytes. For example, if the **detail** output shows **Virtual size: 256 GB**, convert this to **256000**.
203
+
- The new value you enter must be greater than this original value. As an example, to double the virtual size listed above, you could enter the value: **512000**. Once you have determined the number you would like to set for your new size (in megabytes), enter the following command in your Windows Command Prompt **diskpart** prompt:
191
204
192
-
```powershell
205
+
```cmd
193
206
DISKPART> expand vdisk maximum=<sizeInMegaBytes>
194
207
```
195
208
196
209
- Exit **diskpart**
197
210
198
-
```powershell
211
+
```cmd
199
212
DISKPART> exit
200
213
```
201
214
202
215
5. Launch your WSL distribution (Ubuntu, for example).
203
216
204
-
6. Make WSL aware that it can expand its file system's size by running these commands from your Linux distribution command line.
205
-
206
-
> [!NOTE]
207
-
> You may see this message in response to the first **mount** command: **/dev: none already mounted on /dev**. This message can safely be ignored.
217
+
6. Make WSL aware that it can expand its file system's size by running these commands from your WSL distribution command line.
208
218
209
-
```powershell
219
+
```bash
210
220
sudo mount -t devtmpfs none /dev
211
221
mount | grep ext4
212
222
```
213
223
214
-
Copy the name of this entry, which will look like: `/dev/sdX` (with the X representing any other character). In the following example the value of **X** is **b**:
224
+
- You may see this message in response to the first **mount** command: "/dev: none already mounted on /dev." This message can safely be ignored.
225
+
- Copy the name of this entry, which will look like: `/dev/sdX` (with the X representing any other character). In the following example the value of **X** is **b**:
215
226
216
-
```powershell
227
+
```bash
217
228
sudo resize2fs /dev/sdb <sizeInMegabytes>M
218
229
```
219
230
231
+
- Using the example from above, we changed the vhd size to **512000**, so the command would be: `sudo resize2fs /dev/sbd 512000M`.
232
+
220
233
> [!NOTE]
221
234
> You may need to install **resize2fs**. If so, you can use this command to install it: `sudo apt install resize2fs`.
222
235
223
236
The output will look similar to the following:
224
237
225
238
```bash
226
-
resize2fs 1.44.1 (24-Mar-2018)
239
+
resize2fs 1.44.1 (24-Mar-2021)
227
240
Filesystem at /dev/sdb is mounted on /; on-line resizing required
228
241
old_desc_blocks = 32, new_desc_blocks = 38
229
242
The filesystem on /dev/sdb is now 78643200 (4k) blocks long.
230
243
```
231
244
232
-
> [!NOTE]
233
-
> We recommend that you do not modify, move, or access the WSL related files located inside of your AppData folder using Windows tools or editors. Doing so could cause your Linux distribution to become corrupted. If you would like to access your Linux files from Windows that is possible via the path `\\wsl$\<distroName>\`. To learn more, see the blog post: [Accessing Linux files from Windows](https://devblogs.microsoft.com/commandline/whats-new-for-wsl-in-windows-10-version-1903/#accessing-linux-files-from-windows).
245
+
> [!IMPORTANT]
246
+
> We recommend that you do not modify, move, or access the WSL related files located inside of your AppData folder using Windows tools or editors. Doing so could cause your Linux distribution to become corrupted. If you would like to access your Linux files from Windows, that is possible via the path `\\wsl$\<distroName>\`. Open your WSL distribution and enter `explorer.exe .` to view that folder. To learn more, see the blog post: [Accessing Linux files from Windows](https://devblogs.microsoft.com/commandline/whats-new-for-wsl-in-windows-10-version-1903/#accessing-linux-files-from-windows).
0 commit comments