Safely deleting files to free up space on local disk

MarcinTD

Member
Jun 1, 2021
19
3
8
Hi, can I safely delete all the contents of this path for PVE?

root@proxmox:/var/cache/apt/archives#

Also, in what other locations can I completely delete all files to free up a lot of space on local disk?
 
You can run apt clean to remove unneeded cache files. I would also expect that removing old log files from /var/log won't have any risk (you can't use them for debugging problems after removal obviouvsly) but logrotate should already take care of this. Otherwise I would be very cautious to remove anything else if you don't know the purpose of the file.
Why do you want to remove files? If your disk is running full (e.g. due to large log files) this might be more an indicator of a problem so the best action would be to fix the root cause instead of fighting symptoms
 
I want to lighten the disk a bit because its current usage is:
95.44% (441.34 GB out of 462.44 GB)

Unfortunately I can't locate what is taking up so much space. Previously the occupied space was about 300 GB.

I understand that apt clean is absolutely safe and I should run it from root@proxmox, i.e. 'root@proxmox: apt clean', or already being in the folder where I want this command to remove unnecessary files?

Ps. My PVE version is 8.2.7. I started my adventure with PVE with version 6, then updated to 7, and now I'm using 8.
You can run apt clean to remove unneeded cache files. I would also expect that removing old log files from /var/log won't have any risk (you can't use them for debugging problems after removal obviouvsly) but logrotate should already take care of this. Otherwise I would be very cautious to remove anything else if you don't know the purpose of the file.
Why do you want to remove files? If your disk is running full (e.g. due to large log files) this might be more an indicator of a problem so the best action would be to fix the root cause instead of fighting symptoms
I want to lighten the disk a bit because its current usage is:
95.44% (441.34 GB out of 462.44 GB)

Unfortunately I can't locate what is taking up so much space. Previously the occupied space was about 300 GB.

I understand that apt clean is absolutely safe and I should run it from root@proxmox, i.e. 'root@proxmox: apt clean', or already being in the folder where I want this command to remove unnecessary files?

Ps. My PVE version is 8.2.7. I started my adventure with PVE with version 6, then updated to 7, and now I'm using 8.
 
I want to lighten the disk a bit because its current usage is:
95.44% (441.34 GB out of 462.44 GB)

Unfortunately I can't locate what is taking up so much space. Previously the occupied space was about 300 GB.

I understand that apt clean is absolutely safe and I should run it from root@proxmox, i.e. 'root@proxmox: apt clean', or already being in the folder where I want this command to remove unnecessary files?

Just run apt clean, this would be fine. It will remove the files in the cache of the apt package manager, so if you need to reinstall a package it will need to download it again. To find out which files take how much space you could use du, which is already installed during the proxmox os install.
It's quite slow though and you would need to recurse it:
sudo du -shc /*
This will give you which directory under / will take the most space. Afterwards you would repeat the command just for this directory, e.G:
sudo du -shc /var/* and so on until you find the culproit-
A more performant and less tedious tool is dust: https://github.com/bootandy/dust/releases
After install login to a root shell, change to / and run dust to get an overview of the used space
 
Probably older (unused) kernels taking up space.

You can search these & other forums for the safest method to remove.

I use Tteck's script, see here.

USE AT YOUR OWN RISK!
ALWAYS MAKE SURE YOU HAVE FULLY RESTORABLE BACKUPS!
 
Probably older (unused) kernels taking up space.

You can search these & other forums for the safest method to remove.

I use Tteck's script, see here.

USE AT YOUR OWN RISK!
ALWAYS MAKE SURE YOU HAVE FULLY RESTORABLE BACKUPS!
Don't use helper scripts without understanding how they work. And if you understand how they work, you can to the work yourself. Thus: DON'T USE HELPER SCRIPTS AT ALL, especially (!) if you lack the knowledge to understand them. Unused kernels should be cleaned up on modern systems autoamatically so it shouldn't even be needed in this case.
However: Instead of guessing which takes space it's better to actually know. For this reason I would still go the du/dust route to investigate the disk usage
 
Don't use helper scripts without understanding how they work
Definitely true.

you can to the work yourself
Not always necessarily true. Scripts are there to make "life easier", so if you COMPLETLY perceive the script's functionality & consequence, they can be extremely useful.

Unused kernels should be cleaned up on modern systems autoamatically so it shouldn't even be needed in this case.
You demonstrate with this a lack of PVE understanding & functionality. Proxmox will generally NEVER remove older & unused kernels.

A more performant and less tedious tool is dust: https://github.com/bootandy/dust/releases
I would not go installing other third party solutions in my HV.
 
Not always necessarily true. Scripts are there to make "life easier", so if you COMPLETLY perceive the script's functionality & consequence, they can be extremely useful.

Well, maybe I'm too damaged by reddits homelab/proxmox subs but my (obviousvly highly subjective) impression is that helper scripts are mainly used by beginners to spare them the work to understand how to setup their systems. While I understand where they come from, this doesn't mean it's a good idea. For this reason I have decided for myself to be a dissenting voice whenever one of them is referenced.

You demonstrate with this a lack of PVE understanding & functionality. Proxmox will generally NEVER remove older & unused kernels.

Thanks for the correction I'm used to this from my Debian desktop. Since PVE is based on Debian I assumed that the behaviour will be the same.
However removing old kernels is actually not that hard and up to now we don't even know whether they are the problem of the OP or not.

I would not go installing other third party solutions in my HV.

I agree but then in consequence one shouldn't use any helper scripts either. dust however is a single-binary standalone tool so it's easy to remove. And of course regular GNU du can be used as well.
I however had the impression, that the OP might found GNU du to tedious so I wanted to provide an alternative path for consideration.