25

Can someone provide some background?

It seems like this folder is growing even when I'm not updating or installing any packages, but I'm not entirely sure about that.

Context: My AWS instances keep running out of disk space, and i already learned to do this periodically:

apt-get -y autoremove
apt-get -y autoclean

But I don't understand why it grows in the first place.

Also see:

EDIT: On my very new server i get this:

du -h -d1 /usr/src/ | sort -hr
266M  /usr/src/
115M  /usr/src/linux-aws-headers-4.15.0-1035
115M  /usr/src/linux-aws-headers-4.15.0-1032
19M   /usr/src/linux-headers-4.15.0-1035-aws
19M   /usr/src/linux-headers-4.15.0-1032-aws
Reto Höhener
  • 447
  • 1
  • 5
  • 8
  • You can save space by not installing headers in the first place. You do need them to compile programs though. For example `dkms` compiles driver programs. How large are your directories? – WinEunuuchs2Unix May 08 '19 at 22:04
  • I'm just running stuff like apache, artifactory, or jenkins. /usr/src grew to 3G on 8G disk, before the system died. Never installed any header on purpose (didn't know about them before analyzing disk usage). – Reto Höhener May 08 '19 at 22:18
  • Can you run `du /usr/src/ -d 1 -h` and paste the results into your question. Reply using @WinEunnuchs2Unix and I'll check the output for clues. A single Linux Kernel version's headers are about 120 MB on my machine. I have almost 20 kernel headers installed plus other "driver stuff" and `/usr/src/ is only 1.5 GB. – WinEunuuchs2Unix May 08 '19 at 23:26
  • @WinEunuuchs2Unix done. On my old server it looked more like the list in the referenced SO question. I am interested in understanding when and why this list grows, and not so much how to clean it up (already know that). – Reto Höhener May 08 '19 at 23:46
  • It's only 266 MB today. Maybe check it daily to see if it grows? Then if it doesn't after 7 days check it weekly? Whenever it grows update your question with new stats and ping me again. – WinEunuuchs2Unix May 08 '19 at 23:48

1 Answers1

19

This is probably due to the automatic updates.

You can disable the automatic updates and even remove the unused kernel images and headers running sudo apt autoremove --purge (as you are already doing)

More info here: https://help.ubuntu.com/lts/serverguide/automatic-updates.html

frommelmak
  • 606
  • 6
  • 6
  • 1
    They only have two kernel versions so autoremove will do nothing. Turning off automatic updates means nothing gets updated, not just the headers and new kernel versions. – WinEunuuchs2Unix Oct 30 '19 at 11:52
  • 1
    That command saved me 8.5GB. But also, the link now just redirects to https://ubuntu.com/server/docs – crimson_penguin Jul 11 '21 at 20:14