Skip to content

Commit b755070

Browse files
authored
On branch edburns-msft-diskpart-expand-improvement Fixes #951 resize improvement (#952)
modified: WSL/compare-versions.md
1 parent 77e4287 commit b755070

1 file changed

Lines changed: 50 additions & 14 deletions

File tree

WSL/compare-versions.md

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Comparing WSL 2 and WSL 1
3-
description: Compare version 1 and version 2 of the Windows Subsystem for Linux. Learn whats new in WSL 2 - actual Linux kernel, faster speed, full system call compatibility. WSL 1 works better if your storing files across operating file systems. You can expand the size of your WSL 2 Virtual Hardware Disk (VHD).
4-
keywords: BashOnWindows, bash, wsl, windows, windowssubsystem, gnu, linux, ubuntu, debian, suse, windows 10, UX changes, WSL 2, linux kernel, network applications, localhost, IPv6, Virtual Hardware Disk, VHD, VHD limitations, VHD error
3+
description: Compare version 1 and version 2 of the Windows Subsystem for Linux. Learn whats new in WSL 2 - actual Linux kernel, faster speed, full system call compatibility. WSL 1 works better if your storing files across operating file systems. You can expand the size of your WSL 2 Virtual Hard Disk (VHD).
4+
keywords: BashOnWindows, bash, wsl, windows, windowssubsystem, gnu, linux, ubuntu, debian, suse, windows 10, UX changes, WSL 2, linux kernel, network applications, localhost, IPv6, Virtual Hard Disk, VHD, VHD limitations, VHD error
55
ms.date: 09/15/2020
66
ms.topic: conceptual
77
ms.localizationpriority: high
@@ -155,11 +155,11 @@ netsh interface portproxy add v4tov4 listenport=4000 listenaddress=0.0.0.0 conne
155155

156156
WSL 2 distributions currently cannot reach IPv6-only addresses. We are working on adding this feature.
157157

158-
## Expanding the size of your WSL 2 Virtual Hardware Disk
158+
## Expanding the size of your WSL 2 Virtual Hard Disk
159159

160-
WSL 2 uses a Virtual Hardware Disk (VHD) to store your Linux files. If you reach its max size you may need to expand it.
160+
WSL 2 uses a Virtual Hard Disk (VHD) to store your Linux files. In WSL 2, a VHD is represented on your Windows hard drive as a *.vhdx* file.
161161

162-
The WSL 2 VHD uses the ext4 file system. This VHD automatically resizes to meet your storage needs and has an initial maximum size of 256GB. If your distribution grows in size to be greater than 256GB, you will see errors stating that you've run out of disk space. You can fix this error by expanding the VHD size.
162+
The WSL 2 VHD uses the ext4 file system. This VHD automatically resizes to meet your storage needs and has an initial maximum size of 256GB. If the storage space required by your Linux files exceeds this size you may need to expand it. If your distribution grows in size to be greater than 256GB, you will see errors stating that you've run out of disk space. You can fix this error by expanding the VHD size.
163163

164164
To expand your maximum VHD size beyond 256GB:
165165

@@ -174,18 +174,54 @@ To expand your maximum VHD size beyond 256GB:
174174

175175
4. Resize your WSL 2 VHD by completing the following commands:
176176
- Open Windows Command Prompt with admin privileges and enter:
177-
- `diskpart`
178-
- `Select vdisk file="<pathToVHD>"`
179-
- `expand vdisk maximum="<sizeInMegaBytes>"`
177+
178+
```powershell
179+
diskpart
180+
DISKPART> Select vdisk file="<pathToVHD>"
181+
DISKPART> detail vdisk
182+
```
183+
184+
- 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**:
185+
186+
```powershell
187+
DISKPART> expand vdisk maximum=<sizeInMegaBytes>
188+
```
189+
190+
- Exit **diskpart**
191+
192+
```powershell
193+
DISKPART> exit
194+
```
180195
181196
5. Launch your WSL distribution (Ubuntu, for example).
182197
183-
6. Make WSL aware that it can expand its file system's size by running these commands from your Linux distribution command line:
184-
- `sudo mount -t devtmpfs none /dev`
185-
- `mount | grep ext4`
186-
- Copy the name of this entry, which will look like: `/dev/sdXX` (with the X representing any other character)
187-
- `sudo resize2fs /dev/sdXX`
188-
- Use the value you copied earlier. You may also need to install resize2fs: `apt install resize2fs`
198+
6. Make WSL aware that it can expand its file system's size by running these commands from your Linux distribution command line.
199+
200+
> [!NOTE]
201+
> You may see this message in response to the first **mount** command: **/dev: none already mounted on /dev**. This message can safely be ignored.
202+
203+
```powershell
204+
sudo mount -t devtmpfs none /dev
205+
mount | grep ext4
206+
```
207+
208+
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**:
209+
210+
```powershell
211+
sudo resize2fs /dev/sdb <sizeInMegabytes>M
212+
```
213+
214+
> [!NOTE]
215+
> You may need to install **resize2fs**. If so, you can use this command to install it: `sudo apt install resize2fs`.
216+
217+
The output will look similar to the following:
218+
219+
```bash
220+
resize2fs 1.44.1 (24-Mar-2018)
221+
Filesystem at /dev/sdb is mounted on /; on-line resizing required
222+
old_desc_blocks = 32, new_desc_blocks = 38
223+
The filesystem on /dev/sdb is now 78643200 (4k) blocks long.
224+
```
189225

190226
> [!NOTE]
191227
> In general 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.

0 commit comments

Comments
 (0)