Skip to content

Commit e7eadd9

Browse files
committed
Update vhd file size instructions based on #533
1 parent ec254b6 commit e7eadd9

2 files changed

Lines changed: 32 additions & 19 deletions

File tree

WSL/compare-versions.md

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -169,65 +169,78 @@ To expand your maximum VHD size beyond 256GB:
169169

170170
1. Terminate all WSL instances using the command: `wsl --shutdown`
171171

172-
2. Find your distribution installation package name ('PackageFamilyName')
172+
2. To find your distribution installation package name ('PackageFamilyName'):
173173
- Using PowerShell (where 'distro' is your distribution name) enter the command:
174174
- `Get-AppxPackage -Name "*<distro>*" | Select PackageFamilyName`
175+
- For example: `Get-AppxPackage -Name "*Ubuntu*" | Select PackageFamilyName`
175176

176-
3. Locate the VHD file `fullpath` used by your WSL 2 installation, this will be your `pathToVHD`:
177-
- `%LOCALAPPDATA%\Packages\<PackageFamilyName>\LocalState\<disk>.vhdx`
178-
- As an example, to find the path for Ubuntu, you would enter: `Get-AppxPackage -Name "*Ubuntu*" | Select PackageFamilyName`
179-
![Get-AppxPackage command line screenshot](/media/get-AppxPackage.png)
177+
![Get-AppxPackage command line screenshot](./media/get-appxpackage.png)
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:
184+
`%LOCALAPPDATA%\Packages\<PackageFamilyName>\LocalState\<disk>.vhdx`
185+
- For example, the `<pathToVHD>` for Ubuntu 20.04 should look something like: `%LOCALAPPDATA%\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79xxxx\LocalState\ext4.vhdx`.
180186

181187
4. Resize your WSL 2 VHD by completing the following commands:
182188
- Open Windows Command Prompt with admin privileges and enter:
183189

184-
```powershell
190+
```cmd
185191
diskpart
192+
```
193+
194+
```cmd
186195
DISKPART> Select vdisk file="<pathToVHD>"
196+
```
197+
198+
```cmd
187199
DISKPART> detail vdisk
188200
```
189201
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:
191204
192-
```powershell
205+
```cmd
193206
DISKPART> expand vdisk maximum=<sizeInMegaBytes>
194207
```
195208
196209
- Exit **diskpart**
197210
198-
```powershell
211+
```cmd
199212
DISKPART> exit
200213
```
201214
202215
5. Launch your WSL distribution (Ubuntu, for example).
203216
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.
208218
209-
```powershell
219+
```bash
210220
sudo mount -t devtmpfs none /dev
211221
mount | grep ext4
212222
```
213223

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**:
215226

216-
```powershell
227+
```bash
217228
sudo resize2fs /dev/sdb <sizeInMegabytes>M
218229
```
219230

231+
- Using the example from above, we changed the vhd size to **512000**, so the command would be: `sudo resize2fs /dev/sbd 512000M`.
232+
220233
> [!NOTE]
221234
> You may need to install **resize2fs**. If so, you can use this command to install it: `sudo apt install resize2fs`.
222235
223236
The output will look similar to the following:
224237

225238
```bash
226-
resize2fs 1.44.1 (24-Mar-2018)
239+
resize2fs 1.44.1 (24-Mar-2021)
227240
Filesystem at /dev/sdb is mounted on /; on-line resizing required
228241
old_desc_blocks = 32, new_desc_blocks = 38
229242
The filesystem on /dev/sdb is now 78643200 (4k) blocks long.
230243
```
231244

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).

WSL/media/localappdata.png

30.5 KB
Loading

0 commit comments

Comments
 (0)