TL;DR:
You can safely reduce the size of a WSL instance's rootfs by deleting /mnt/<DRIVE_LETTER>/*
from the WSL rootfs after unmounting the underlying disk from within WSL instance. In my case, my WSL instance had a lot of cached data from Windows' M:
drive stored in /mnt/m
. I cleaned it safely from within the WSL instance by:
sudo umount /mnt/m
rm -rf /mnt/m/*
If you are paranoid, first use mount
from within your WSL instance to verify the drive you want to clean. Then after running the unmount command (sudo unmount /mnt/<DRIVE_LETTER>
), run mount
again and verify the drive no longer appears in the list. Then you can safely proceed to use rm -rf
on the files from within the WSL instance to wipe the cached data without affecting the data on the underlying Windows disk.
---- My Findings ----
Looks like WSL 1 uses that rootfs folder as a data cache. I noticed after unmounting my M:
drive from within WSL with sudo umount /mnt/m
that some of the folders' permissions changed while others didn't (notice the color difference in the below image which was taken after unmounting /mnt/m
). The folders whose permissions didn't change are the folders that were taking up space on my Windows' C:
drive in that rootfs
folder.

My Dropbox folder contributed to 11 GB on my C:
drive but takes up much more on my M:
drive. Since I knew it was already backed-up on Dropbox's servers, I wiped it from within WSL 1 (after having unmounted /mnt/m
from within WSL) with the following: rm -rf /mnt/m/Dropbox
then checked and confirmed from Windows with WinDirStat that my C:
drive gained 11 GB more free space while my M:
drive's Dropbox folder was unaffected. I closed the WSL window and reopened it to trigger auto-mount of my drives. Then checked /mnt/m/Dropbox
and it was there with everything again. I unmounted /mnt/m
and proceeded to delete everything from within WSL with: rm -rf /mnt/m/*
. I double checked my M drive again - all files still there. Then I double checked how WSL behaved by exiting and re-launching it. ls -la /mnt/m
showed everything still there. Now my rootfs on C drive is very small... Nice!
