Can I delete /var/tmp/mkinitramfs-* files?
Generally, you can delete any file in /tmp
and /var/tmp
without breaking the system. The worst case scenario is that it's a file needed by an open app, but that doesn't seem to be the case.
Regarding those files related to mkinitramfs
, I would say that it's safe to prune them. See also this Debian bug: #818345 -
tmp file is left under /var/tmp if mkinitramfs fails. Basically those files should be purged after the process that created them is over, but for some reason they are not.
I am not sure if you are affected by that bug specifically, but the point is that those files are needed by mkinitramfs
while the process is ongoing. After the process is over, you don't need them anymore. Also, as usual with temporary files, they will be recreated in subsequent runs of the same process if necessary.
I hope you can point out to me some references on the role of those
mkinitramfs_*
folders and how to usetmpreaper
app or other tools to automatically delete old temporary files.
I don't have experience with tmpreaper
, but you could use a cron job to delete those files periodically. See:
Auto delete files older than 7 days
Related videos on Youtube
Xiaodong Qi
Updated on September 18, 2022Comments
-
Xiaodong Qi over 1 year
I notice that my
/var/tmp
folder has occupied by 9.3GB space on my Ubuntu 16.04.2. Particularly, there are a bunch ofmkinitramfs_*
folders taken most of the space in the tmp folder. I looked into them, and they seem to be the temporary files for linux kernels compiled recently and in the past. Can I delete them safely, or they are linked to other important files?I have tried using
tmpreaper
app to automate the temporary file cleaning process on reboots. But I find I can only put both/tmp/
and/var/tmp/
folders together into the auto-clean settings and only set up one max file age to remove old files. This may make it hard to set up the max file age parameterTMPREAPER_TIME
properly. If I set it too short (by default, 7 days), I might delete those recent kernel compiling files inmkinitramfs_*
folders which might be useful. If I set it too long, I may end up with a lot of files in/tmp
. I hope you can point out to me some references on the role of thosemkinitramfs_*
folders and how to usetmpreaper
app or other tools to automatically delete old temporary files.Thanks!
-
Admin about 7 yearsI have heard it's better to keep a longer age for files in
/var/tmp
than in/tmp
.lsof
doesn't show any process is using those files. But there are a bunch of warnings in thetmpreaper
app's manual when I tried to set it up to automatically delete those files, that is where I got scared away. So, you think deleting those files 7days after the last access is safe? -
Admin about 7 yearsI have noticed that bug on my searching. Firstly, those files were generated not because of any kernel installation failure. Secondly, the bug was said being fixed. Is there any way to verify if they are not linked to any other files?
-
Admin almost 7 yearsI've converted my previous comments to a proper answer. I'm going to clean them up now.
-
-
Xiaodong Qi almost 7 yearsThank you for writing this answer. After understanding the tmp files, I used
tmpreaper
(see my notes for details) to automatically clean up those files older than 30 days and saved me 7GB of space. That is very helpful! -
Xiaodong Qi almost 5 yearsUpdate my notes' link.