Whoa! What Happened To All The Disk Space On My Google Cloud Platform Free Tier Debian VPS?
Introduction
For over four years now I have been enjoying a Google Cloud Platform (GCP) Free Tier Debian VPS. During this time, Debian's package system cache has grown to use more than half of the VPS's 10 GB of file storage space to cache .deb package files. This post explains the history and the use of this wonderful, free VPS (Thanks, Google!); shows the size of the package cache; and explains how to reclaim the large amount of disk space used for the cache.
VPS Creation in 2019
According to the Google Cloud Console, my e2-micro instance was created on January 27, 2019. That was more than four and a half years ago!
Larger File System Size Possible Within Current GCP Free Tier Limits
Looking at the current GCP Free Tier Resource Limits suggests that the Compute Engine limit is "30 GB-months standard persistent disk." My VPS is only 10 GB, so maybe, when I need it, I could increase the file system size to add an additional 20 GB.
VPS Use
This GCP VPS has been in modest, but continuous, steady use throughout more than four years. It serves my tiny personal website, holds a few small backup files, and runs TinyProxy. Tinyproxy works great for accessing certain websites in the US when I am in Mexico.
I log in to the VPS frequently. I wouldn't say every week for sure, but, if I am working on something, I log in many times in one week. Of course, to update the VPS's Debian operating system, I regularly run apt-get update
and then apt-get upgrade
.
Running EOL Debian 10 Buster
My GCP VPS is still running Debian 10 Buster (End of Life (EOL) a year ago, September 10, 2022), which might be okay, because the check-support-status
utility doesn't list any installed packages without Long Term Support (LTS).
root@gc:~# man check-support-status
root@gc:~# check-support-status
root@gc:~# echo $?
0
root@gc:~#
Great VPS Uptime!
Usually I run the w
command when I log in. Here's what I saw today. 590 days of uptime isn't bad!
root@gc:~# w
20:43:01 up 590 days, 16:55, 1 user, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
tom pts/0 187.189.238.2 19:30 0.00s 0.08s 0.01s sshd: tom [priv]
root@gc:~#
Low Free Disk Space
One thing I have noticed is that free disk space on the VPS has been decreasing. Here is what free disk space looked like earlier today.
root@gc:~# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.8G 8.7G 673M 93% /
root@gc:~#
The VPS image was set up without a swap partition. Since I might want to add more website or backup files, install additional utilities, or even add a swap file, I thought the remaining 673 MB might be a little small. I decided to take a look around and see if I could find a place or a few places where I could remove a big file that no longer was needed.
root@gc:/# du -sh /home/tom /var/www
77M /home/tom
67M /var/www
root@gc:/#
Hmm! It didn't look like my home directory or even my website files were too piggy! Looking some more, I was surprised to find that /var
was using a lot of space!
root@gc:/# du -sh /var
5.9G /var
root@gc:/#
Wow! "Lots of logs?" I wondered.
root@gc:/# du -sh /var/*
1.2M /var/backups
5.7G /var/cache
156M /var/lib
4.0K /var/local
0 /var/lock
13M /var/log
3.3M /var/mail
4.0K /var/opt
0 /var/run
8.7M /var/spool
12K /var/tmp
67M /var/www
root@gc:/#
What's using all that space in /var/cache
?
root@gc:/# du -sh /var/cache/*
108K /var/cache/apparmor
5.7G /var/cache/apt
3.8M /var/cache/debconf
20K /var/cache/ldconfig
2.5M /var/cache/man
4.0K /var/cache/private
root@gc:/#
Oh! It's the package system! Four years of .deb files live there! 5.7 GB! Looking at the full output of the below command without the pipe to wc
, it was instantly clear that all except the first five of the 346 output lines were .deb files. That's 341 .deb files! Together, the 341 cached .deb files used more than half of my VPS's disk space!
root@gc:/# ls -l /var/cache/apt/* | wc
346 3090 28173
root@gc:/#
About .deb Files
Binary .deb files are packages containing binaries which are "directly useable by dpkg
." Source .deb files contain source code.
Luckily for small VPSes, after the system has been updated, the .deb files may be removed.
How To Reclaim Disk Space
From man apt-get
:
clean
clean clears out the local repository of retrieved package files. It removes
everything but the lock file from /var/cache/apt/archives/ and
/var/cache/apt/archives/partial/.
After running apt-get clean
the VPS got its empty disk space back! 6.4 GB available instead of 673 MB!
root@gc:~# apt-get clean
root@gc:~# ls -l /var/cache/apt/*
total 4
-rw-r----- 1 root root 0 Jan 24 2019 lock
drwx------ 2 _apt root 4096 Sep 13 21:22 partial
root@gc:~# du -sh /var/cache/apt
64K /var/cache/apt
root@gc:~# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.8G 3.0G 6.4G 32% /
root@gc:~#
Disabling The Cache
One possible way to prevent running out of disk space might be to disable the caching of .deb files. From man 5 apt-conf
:
DIRECTORIES
[ . . . ]
Dir::Cache contains locations pertaining to local cache information, such as the two
package caches srcpkgcache and pkgcache as well as the location to place downloaded
archives, Dir::Cache::archives. Generation of caches can be turned off by setting
pkgcache or srcpkgcache to "".
Please see also this old Bug #753531 from 2014, which was very fun to read because it almost said rm -rf /*
!
It seems possibly safer and generally less work all around to leave the .deb caching defaults as they are. It's easy to empty the cache once in awhile with apt-get clean
.
Conclusion
For small Debian VPSes which have been in use a long time, you might want to run apt-get clean
to reclaim the large amount of disk space used by the apt cache.
I hope everyone gets the servers they want!
Comments
Once again a great article . In each of your articles I learn at least one thing I did not know before. Thank you for the time and effort you put in to make this happen.
I mainly run AlmaLinux 8 these days and run a cron job once a month. For yum I run:
I am currently traveling in mostly remote areas until sometime in April 2024. Consequently DM's sent to me will go unanswered during this time.
For staff assistance or support issues please use the helpdesk ticket system at https://support.lowendspirit.com/index.php?a=add
Every time I run
apt update
, and upgrade/dist-upgrade (if any), I'll make sure it ends with anapt clean
I had like 3 GB of journal data in a couple of my Debian VPSes, so I ran
journalctl --vacuum-time=2d
.(Also possible:
--vacuum-size=100M
etc ...)btw, Doesn't GCP free tier apply only for the first year?
I believe GCP Free Tier Compute Engine VPS is free forever, subject to monthly usage limits. I believe the initial $300 credit expires in 90 days if unused. Please check https://cloud.google.com/free and especially https://cloud.google.com/free/docs/free-cloud-features .
Have a great day!
I hope everyone gets the servers they want!
WoW! nice sharing thankyou. i will try again
Only 1GB bandwidth per month?
Yeah, the second of the linked pages says 1 GB per month for Compute Engine. There also is App Engine, for which 1 GB per day is available. On the good side, GCP Free Tier is free, and it's very dependable. Thanks, Google!
I hope everyone gets the servers they want!
My Debian upgrade snippet is always:
apt update ; apt upgrade ; apt dist-upgrade ; apt autoremove ; apt autoclean
Localepurge can be nice too if you want to free up space and don't need additional language support. https://manpages.debian.org/bullseye/localepurge/localepurge.8.en.html
Cheap dedis are my drug, and I'm too far gone to turn back.
I have that in crontab everyday on low disk Debians
Haven't bought a single service in VirMach Great Ryzen 2022 - 2023 Flash Sale.
https://lowendspirit.com/uploads/editor/gi/ippw0lcmqowk.png
Can also use
apt autopurge
.FWIW, note that
clean
andautoclean
are different. Fromman apt-get
:I hope everyone gets the servers they want!
Hi @Not_Oles , I don't know if the IP brings any security issues to you, but I would anonymize the output of "w" if I were you Use 1.1.1.1 or 8.8.8.8 instead
It was discussed before the article was published and since it is CGNAT should not be an issue.
I am currently traveling in mostly remote areas until sometime in April 2024. Consequently DM's sent to me will go unanswered during this time.
For staff assistance or support issues please use the helpdesk ticket system at https://support.lowendspirit.com/index.php?a=add
Ok then, but anyways I always try to anonymize IPs even if they are CGNAT, no need to bring any incomming traffic on my ISP anyways
Hi @MrEd! Thanks for helping! It's really appreciated!
@FrankZ This is the second or maybe even the third time some kind person has mentioned my CGNAT IP being exposed. Maybe, in the future, I should obfuscate the IP just to save everybody the trouble. I really, really appreciate it when people correct my mistakes, so I don't want to waste the wonderful resource which is other guys here watching my back. Thank you, guys!
I hope everyone gets the servers they want!
@Not_Oles I stole the space for one of many, many irons I have in the fire. So sorry no refunds, chargebacks, or UNO reverse cards will be accepted.
It is all the Yeti's now mwahahahahah!
Free Hosting at YetiNode | Cryptid Security | URL Shortener | LaunchVPS | ExtraVM | Host-C | In the Node, or Out of the Loop?
@AuroraZero Oh my! I've been Yetihacked, and I didn't even know until you told me!
I hope everyone gets the servers they want!
Free Hosting at YetiNode | Cryptid Security | URL Shortener | LaunchVPS | ExtraVM | Host-C | In the Node, or Out of the Loop?
pacman -Scc
for cleaning cache of Arch linux, and here are corresponding commands of other major distributions in this Rosetta page.Or if the memory is big enough, you can set the cache directory to a tmpfs directory.
MicroLXC is lovable. Uptime of C1V
@bliss Thanks again for your comment! I went to look at the Rosetta page to which you linked. It's helpful to have the pacman equivalent commands for major distributions all together in one place!
I hope everyone gets the servers they want!
Are you able to stay under 1 GB/month, or do you normally run over? Or maybe it's one of those things where if you run over a few GB the charge is so small they don't even bother running your card?
I haven't paid careful attention to how much bandwidth my GCP Free Tier instance is using. Except for an occasional Google Voice video call, the instance typically is neither serving or proxying video or music. So it's probably not using much bandwidth. Nevertheless, as you suggest, there indeed have been a couple of months when I have wondered about possibly having used a little more than 1 GB. Since I haven't been charged yet, all I can say is, "Thanks Google!"
I hope everyone gets the servers they want!
Check out the promotion they've got on T2A VM type...north of 200+ discount per month till March. It's their new ARM line. That's a pretty chunk instance. Pity it is time limited
Checked it yesterday and seems to be working as expected
Did you forget what happened to their "free tier" of email hosting?
Free forever -> Free for current users -> Pay now or GTFO
Websites have ads, I have ad-blocker.
And they did it over night, with no noticeable notice.
Like, hello, today your mails and files are locked, subscribe to our plans to access them.
If i were Google, i'd at least put a yellow banner message on top, a month or two ahead.
Google is no better than Indian ransomware.
Well, actually they did send notices to the admin emails. So that part I am not unhappy with. I am sad that I had to pack up my emails and leave or pay $5 per user per month, even for personal usage...
Websites have ads, I have ad-blocker.
I love India (Bharat).
I've chatted with some Indians online and in real life, whom I think are polite and reasonable.
MicroLXC is lovable. Uptime of C1V