Boot partition filling up: Is this a bug in Ubuntu?

5,081

why does Ubuntu keep doing this?

Short version: safety.

Long version: the kernel is the most important part of an OS. It handles communication between hardware and software, among other things that I won't cover in detail here.

Changing the kernel might give you problems. Most of the time everything goes well, but the one time that something is screwed up you do want to have it working again quickly.

Say you are researching materials for your thesis and the deadline is approaching... suddenly a kernel upgrade breaks your Wi-Fi. Do you prefer to postpone your graduation for saving 150 MB of disk space?

I guess no, you don't want that. Here's why you reboot, select the previous kernel and go on with your work. Things like this don't happen often, but they may happen rarely and on some specific hardware, maybe only for one kernel release.

I actually experienced seeing my parents' PC not accepting any keyboard input after a kernel upgrade (a simple keyboard, not a wireless one). Now, using a PC without a keyboard is not nice.

isn't this a serious design flaw?

Not that serious, since benefits outreach the downsides and nowadays hard drives are basically always bigger than 250 GB. Even with 10 different kernels you would occupy only like 2 GB. Yes it starts to be a waste of space after a while, but not that noticeable. Moreover you can uninstall them manually, they are not locked.

Nevertheless, it's reasonable to say that only the last few kernels are needed. That's why Ubuntu 16.04 Xenial marks as "auto-removable" the old kernels, except the last 2.

I always assume the default options will be the safest

Indeed, your assumption is correct. Ubuntu won't never let you blindly overwrite your kernel without any backup solution.

Share:
5,081

Related videos on Youtube

JereCB
Author by

JereCB

Updated on September 18, 2022

Comments

  • JereCB
    JereCB over 1 year

    I keep running into the issue of the /boot partition filling up with old kernel images, which causes obscure errors during upgrades (but now I know what they are...).

    Note that I already know how to fix this thanks to Ask Ubuntu: here's my favorite answer.

    My question is, why does Ubuntu keep doing this, and isn't this a serious design flaw?

    In reading questions related to /boot filling up, I have seen comments like "This happens because you assigned a small space for the boot partition or you have UEFI and forgot to increment the space.". However, I have encountered this problem on at least three different Ubuntu installations, spanning versions from 12 to 15, and I have never used anything other than the default install options. I've always done a clean Ubuntu install using the entire disk (no dual-boot), although the drive has usually had something else on it before.

    Am I doing something wrong in the install (i.e. an option I should select)? I always assume the default options will be the safest.

    Also, even if the install was different (i.e. no /boot, or a larger /boot), wouldn't this still be an issue? (i.e. if old kernel images are never deleted, they are going to eat up the disk space, which seems like a design flaw even if there is plenty of free space).

    • Pilot6
      Pilot6 almost 8 years
      The default install option is not to create a separate /boot partition. You probably use encryption.
    • Andrea Lazzarotto
      Andrea Lazzarotto almost 8 years
      @Pilot6 good point, but since using FDE is an absolutely smart idea, OP is right that the default options (with encryption) create a separate /boot. :)
    • mikewhatever
      mikewhatever almost 8 years
      Old kernels do get deleted here, not sure who told you they don't.
    • JereCB
      JereCB almost 8 years
      I believe the comment from Pilot6 etc above are inaccurate; I have ended up with a (stupidly small) /boot partition on installs without encryption or LVM (no change to the default options, as I said...). In fact every Ubuntu install I have done has had this issue. Perhaps the installer should have a note on it: "Select this set of options to prevent obscure errors in a few months which will require Google searching and command-line hackery to fix"?
    • Pilot6
      Pilot6 almost 8 years
      I installed Ubuntu lots of times and I never had a separate /boot partition. It is created only if you choose to encrypt the file system.
    • JereCB
      JereCB almost 8 years
      I'm going to have to do another install to test this...
    • Andrea Lazzarotto
      Andrea Lazzarotto over 7 years
      @JereCB: If an answer was helpful to you, then please consider marking it as the accepted answer so others may more easily find it in the future. This is also a polite way to thank the person answering your question for helping you out.
    • JereCB
      JereCB over 7 years
      I'm afraid there has been no useful answer, but then it wasn't a very good question. The conclusion seems to be that Ubuntu does gradually fill the drive with old kernels that it never deletes, but this shouldn't be a problem because of Moore's Law (you'll buy bigger drives faster than Ubuntu can eat them). I.e. it's only a "problem" if you have a small /boot partition. Nobody has explained how I ended up with a small /boot partition on several installs, but I just (tonight) tried with latest 16.04 (default options) and I DON'T have a /boot now, so I guess it's less of an issue.
    • Andrea Lazzarotto
      Andrea Lazzarotto over 7 years
      You can always schedule apt autoremove to happen every week, if you are keen to take the risk.
    • Gnudiff
      Gnudiff about 5 years
      This (old kernels filling up space) is the single reason why I am wary of installing Ubuntu for non-geeks. I currently have my sister-in-law's Ubuntu not booting due to old kernels. And I did set all the options I could for automatic removal of old kernels, but apparently it is not a fireproof method, since now it has happened again. And the default Ubuntu install does create a separate (not as small as perviously, but of course not a very large one either) /boot partition.
  • JereCB
    JereCB almost 8 years
    I agree that it's a good idea to keep old kernels, but I think it should be limited to maybe two; I am glad to hear that it's a Ubuntu 16 fixes this; does "auto-removable" actually mean they will disappear by themselves? Also, the /boot partition should really be bigger.
  • JereCB
    JereCB almost 8 years
    "It is the user that is responsible for removing old, unneeded kernels."
  • JereCB
    JereCB almost 8 years
    "It is the user that is responsible for removing old, unneeded kernels." - I actually don't mind doing this, as I have become quite comfortable with the command line. However, to put this in context, I have installed Linux Mint on my parent's PC after Windows 10 imploded. For them, incomprehensible messages must be eliminated and the system needs to run stably with minimal intervention... If having a /boot partition is such an advanced configuration, the installer should make that clear as I never selected any strange options.
  • JereCB
    JereCB almost 8 years
    PS I don't know how the Mint installer sets things up and I don't even know whether theirs has a /boot (must check next time I look) - I was just using that as an example of a system which needs to be stable and not generate problems for itself!
  • Andrea Lazzarotto
    Andrea Lazzarotto almost 8 years
    «does "auto-removable" actually mean they will disappear by themselves?» Software does not disappear by itself. You can, however, schedule a apt-get autoremove to happen daily or weekly and it will take care of it.
  • JereCB
    JereCB almost 8 years
    BTW thanks for your answer... it's good in terms of explaining the issue, but I still feel unsatisfied. I feel this problem will occur for other users and there is no clear answer as to how to prevent it. Some people want to just use the computer, and not wear a sys admin hat or hack around with the terminal. It's unfair to say "it's your fault for creating a small /boot partition" when the installer doesn't explain the options. I certainly never selected the "create a small /boot partition that requires frequent maintenance" option.
  • Cbhihe
    Cbhihe about 7 years
    @JereCB: +1 on yr question and on the accepted answer too. The pbm happens to many. I regularly see my separate 650 MB boot partition fill up completely with old kernel images and I have to regularly go and clean the mess up. I prefer to do so manually to control what is going on, although I could just as easily automate this with a small script and a cron job. Today, for instance, with 0% space left on my boot partition, I cleaned up 11 old kernel images (complete with headers) and that removed more than 36000 (small files) from my system. (I still run Trusty 14.04.5 on my 3 boxes.)
  • Cbhihe
    Cbhihe about 7 years
    +1 The fact that Ubuntu 16.04 Xenial has taken stock of the issue and now automatically deals with the clutter is good. Thanks for pointing this out.
  • Steven Lu
    Steven Lu about 6 years
    16.04's improved behavior is ipso facto proof of this being dramatically unnecessary friction exhibited in the default configuration of 14.04: The system will fill its /boot after a given finite period, and the package manager shall remain borked (not to mention further kernel upgrades blocked as well) until a sufficiently knowledgeable user attempts to administer the system. Although the answer's points are all valid, the point was never that "saving kernel images" is a design flaw: allowing (what are essentially backup) kernel images to introduce denial of service is the design flaw.
  • Steven Lu
    Steven Lu about 6 years
    This wouldn't be one fifth as bad if apt-get could be remotely helpful about this error condition by providing any hint toward /boot being filled with ancient kernels. Instead it gives some nonsensical "package X is needed, but will not be installed". Anyway, rant over, avoid 14.04 if you can.
  • Vectorjohn
    Vectorjohn about 3 years
    This is absolutely wrong behavior. This happened to me on what was a clean 20.04 install. I did not manually configure partitions and my /boot is ~512mb. Over time it got full with 6 or 8 different kernels. There is no good reason to keep an infinite list of kernels around, and no real user can ever be expected to discover and solve this issue on their own. This is a glaring mistake.