Getting Disk Space Back by Uninstalling Ubuntu 24.04 WSL2 on Windows 10
If you're using Ubuntu 24.04 on Windows 10's WSL2 (Windows Subsystem for Linux 2) and have noticed that even after uninstalling the distribution, you're not getting back the disk space you expected, you're not alone. This article will guide you through the process of properly uninstalling Ubuntu 24.04 on WSL2 and reclaiming your disk space.
Understanding WSL2 and Disk Space Usage
WSL2 is a compatibility layer for running Linux binary executables natively on Windows 10. It utilizes a real Linux kernel to provide a Linux-like user space, enabling you to run your favorite Linux tools and applications directly on Windows. However, when you install a Linux distribution like Ubuntu 24.04 on WSL2, it creates a virtual hard disk (VHD) file to store the distribution's files and settings.
Even after uninstalling the distribution, the VHD file remains, consuming disk space. To reclaim this space, you need to manually delete the VHD file.
Locating and Deleting the Ubuntu 24.04 VHD File
To locate and delete the Ubuntu 24.04 VHD file, follow these steps:
- Press Win + X and select Command Prompt (Admin) or PowerShell (Admin) from the list.
- Run the following command to list all WSL2 VHD files:
wsl --list --verboseThis command will display a list of all WSL2 distributions and their corresponding VHD file paths.
- Identify the Ubuntu 24.04 VHD file from the list. It should have a name similar to
ext4.vhdxand be located in theC:\Users\YourUsername\AppData\Local\Microsoft\WSL\Data\directory. - Delete the Ubuntu 24.04 VHD file using the following command:
del /f "C:\Users\YourUsername\AppData\Local\Microsoft\WSL\Data\ext4.vhdx"Replace YourUsername with your actual Windows username.
Reclaiming Disk Space
After deleting the Ubuntu 24.04 VHD file, you may need to reclaim the freed disk space manually. To do so, follow these steps:
- Press Win + X and select Command Prompt (Admin) or PowerShell (Admin) from the list.
- Run the following command to open Disk Cleanup:
cleanmgrSelect the drive where your Ubuntu 24.04 VHD file was located, then click OK.
- In the Disk Cleanup window, click Clean up system files.
- Select the drive again, then click OK.
- Check the box next to Temporary Files and any other unnecessary file categories, then click OK.
- Confirm the deletion by clicking Delete Files.
- WSL2 creates a virtual hard disk (VHD) file to store the distribution's files and settings.
- After uninstalling Ubuntu 24.04 on WSL2, the VHD file remains, consuming disk space.
- To reclaim disk space, locate and delete the Ubuntu 24.04 VHD file using the
wsl --list --verbosecommand. - Manually reclaim disk space using Disk Cleanup.