Skip to content

Freeing Windows Disk Space

There are a few steps we can take to try to reduce the disk space usage of Porta On Prem.

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.

  1. Use the system tray to shut down Docker Desktop.
  2. After Docker has finished shutting down, open Powershell.
  3. Run wsl --shutdown to stop all distributions.
  4. Run wsl -l -v and ensure the docker distros are stopped. A successful output will look like this:
    NAME STATE VERSION
    * Ubuntu-22.04 Stopped 2
    docker-desktop-data Stopped 2
    docker-desktop Stopped 2
  5. Export the docker-desktop-data distribution to a .tar file.
    1. Open powershell as an administrator.

    2. Confirm that docker-desktop-data exists and is stopped by running:

      wsl -l -v

      A successful output will look like this:

      NAME STATE VERSION
      * Ubuntu-22.04 Stopped 2
      docker-desktop-data Stopped 2
      docker-desktop Stopped 2
    3. In Powershell, run the following command to export the docker-desktop-data distribution to a .tar file.

      • In the command, replace D:\path\to\backup with 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
    4. You’ll know the export has finished when the PS C:\Users\username> prompt appears again on the next line.

  6. Verify the backup file was created successfully.
    1. Navigate to the backup directory you specified in step 2.
    2. Confirm that the docker-desktop-data.tar file exists.
    3. Check the file size to ensure it’s greater than 0 bytes.
  1. Open Powershell.
  2. Run the following command to stop the WSL distributions:
    Terminal window
    wsl --shutdown
  3. Run this command to open the program diskpart so we can interact with WSL’s virtual disk:
    Terminal window
    diskpart
  4. In the diskpart prompt, run the following command to select the WSL virtual disk:
    select vdisk file="%LOCALAPPDATA%\Docker\wsl\data\ext4.vhdx"
  5. Next, run the following command to attach the virtual disk:
    attach vdisk readonly
  6. 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.
  7. Finally, run this command to detach the virtual disk:
    detach vdisk
  8. Type exit to leave the diskpart program.

Once finished, you can run Docker Desktop again. Everything should boot normally and the disk space should be freed.

If something goes wrong, use the restoration guide to restore the virtual disk from the backup you created in step 1.