Freeing Windows Disk Space
There are a few steps we can take to try to reduce the disk space usage of Porta On Prem.
1. Decrease Porta’s disk usage
Section titled “1. Decrease Porta’s disk usage”2. Free up Windows disk space by compacting the virtual disk
Section titled “2. Free up Windows disk space by compacting the virtual disk”After taking steps to clear out Porta disk space, it may not be immediately reclaimed by the Windows drive. To compact the virtual disk used by WSL and free up Windows disk space immediately, follow the steps below.
2a. Backup the virtual disk
Section titled “2a. Backup the virtual disk”- Use the system tray to shut down Docker Desktop.
- After Docker has finished shutting down, open Powershell.
- Run
wsl --shutdownto stop all distributions. - Run
wsl -l -vand ensure the docker distros are stopped. A successful output will look like this:NAME STATE VERSION* Ubuntu-22.04 Stopped 2docker-desktop-data Stopped 2docker-desktop Stopped 2 - Export the
docker-desktop-datadistribution to a.tarfile.-
Open powershell as an administrator.
-
Confirm that
docker-desktop-dataexists and is stopped by running:wsl -l -vA successful output will look like this:
NAME STATE VERSION* Ubuntu-22.04 Stopped 2docker-desktop-data Stopped 2docker-desktop Stopped 2 -
In Powershell, run the following command to export the
docker-desktop-datadistribution to a.tarfile.- In the command, replace
D:\path\to\backupwith your desired backup directory.- This directory must already exist prior to exporting. Create a new directory if necessary.
- Make sure the export destination has enough free disk space.
- The export may take a while if the virtual disk is large (anywhere from 5 to 15 minutes).
-
Terminal window wsl --export docker-desktop-data D:\path\to\backup\docker-desktop-data.tar
- In the command, replace
-
You’ll know the export has finished when the
PS C:\Users\username>prompt appears again on the next line.
-
- Verify the backup file was created successfully.
- Navigate to the backup directory you specified in step 2.
- Confirm that the
docker-desktop-data.tarfile exists. - Check the file size to ensure it’s greater than 0 bytes.
2b. Compact the virtual disk
Section titled “2b. Compact the virtual disk”- Open Powershell.
- Run the following command to stop the WSL distributions:
Terminal window wsl --shutdown - Run this command to open the program
diskpartso we can interact with WSL’s virtual disk:Terminal window diskpart - In the
diskpartprompt, run the following command to select the WSL virtual disk:select vdisk file="%LOCALAPPDATA%\Docker\wsl\data\ext4.vhdx" - Next, run the following command to attach the virtual disk:
attach vdisk readonly
- Now, run this command to compact the virtual disk:
compact vdisk
- This will shrink the disk to free up space on the host’s drive.
- Finally, run this command to detach the virtual disk:
detach vdisk
- Type
exitto leave thediskpartprogram.
2c. Start Docker Desktop
Section titled “2c. Start Docker Desktop”Once finished, you can run Docker Desktop again. Everything should boot normally and the disk space should be freed.
2d. Restoration (if needed)
Section titled “2d. Restoration (if needed)”If something goes wrong, use the restoration guide to restore the virtual disk from the backup you created in step 1.