Score:0

rm'd 300GB of storage in ubuntu but disk space hasn't been reclaimed

gr flag

Due to a program I was running in ubuntu doing a number of unnecessary tasks (not immensely important but background) I had over 300GB of unwanted files on my local disk. I used the rm command on all the files I didn't want.

Using du --max-depth=1 -h | sort -h command I can see that my ubuntu profile is only taking up 16GB of space. The root is only taking of 2.3MB of disk space. I am using windows 11 and I would expect my ubuntu app to be using about 17GB of space (as seen installed apps).

Ubuntu, however, is still taking up 325GB of space (max 476GB, so a signifcant chunck and I basically have none left as displayed in file explorer->This PC).

This could be a few different things

  • The deleted files have been put in some kind of 'trash' folder. However none exists and rm supposedly removes files and reclaims the storage immiediately
  • Windows hasn't updated the file sizes
  • Corrupted files

etc...

Potentially worth noting that my ubuntu crashed numerous times when trying to write files when my system space was full (I foolishly wasn't aware of how much space was being taken up and when it aborted programs I was running it closed ubuntu without a status report so I didn't know what had happened).

Ever since it has being running incredibly slowly taking over 3 minutes to load su myprofile as well as taking up significant system resources for an application that isn't currently running.

Any assistance on what the problem may be and how to potentially fix it would be greatly appreciated. I have restarted my laptop.

cn flag
`rm` does not use a trash folder unless you installed a package to do so. "Windows hasn't updated the file sizes" what has that got to do with it? you mean WSL? if so do use the tag ;) "Corrupted files" Linux aint windows... file coruption is not an issue. and filesystem error trigger a fschk at boot.
cn flag
regarding proces consumption check command `top` for that.
Luuk avatar
cn flag
There is an (old) answer on superuser.com (here: [How do I get back unused disk space from Ubuntu on WSL2?](https://superuser.com/a/1612289/421114)) which might help to reduce the size of your virtual WSL disk. (Remember to change the paths when you use a newer version than Ubuntu 20 )
waltinator avatar
it flag
File space won't be freed until no process has the file open. Try `sudo lsof` to list open files. Read `man lsof sudo kill`
Score:1
gr flag

Thank you Luuk for the solution in comments. This is basically copied from a couple other threads but might as well have the answer on this thread. Check Luuk's comment if you want more details or are not using windows.

This initially didn't work, the attach vdisk readonly command in diskpart had an error, however, trying again today it has worked cleared the removed files from used storage. Ubuntu is still running painfully slowly however.

Inside a windows terminal (I used Command Prompt)

wsl --shutdown

then

diskpart

This will open an administrator command prompt window. Then type

select vdisk file="C:\Users\%Profile%\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx"

attach vdisk readonly

compact vdisk

detach vdisk

exit

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.