Score:0

How to rescue after apt install or upgrade fills disk space and breaks?

in flag

I'd like to know if there is an official way to rescue from a botched install due to filled disk space. Working with VMs and trying to conserve space on golden images has led me to this problem several times. I can usually remedy it by using ncdu -x / and deleting unneeded files, but apt install ncdu has to installed beforehand. I've also used journalctl --vacuum-size=5M to reduce the system log file. Or using apt purge *<old kernel number>, but again that wont work once the apt install process is broken.

This one suggests finding and deleting the packages that installed. https://www.cyberciti.biz/howto/debian-linux/ubuntu-linux-rollback-an-apt-get-upgrade/

This post suggests using apt clean and apt install -f to repair the database. I'm not sure apt clean work with apt broken and apt purge showing apt --fix-broken install. apt install -f seems to retry with force the pending install. Disk space issue after apt-get update

I actually just checked and apt clean does in fact work and restores some disk space. It seems that using apt purge <package> after clearing some space with apt clean is the only way to get back to the state before the broken install.

It would be great if Apt would say to "use apt clean if the disk is full", which it could check. It could also check for enough free space before allowing non-forced install.

Nmath avatar
ng flag
If you let your root file system run out of space, and you have problems, this is often fatal and requires you to reinstall the operating system. There are too many possibilities for things to go wrong when system critical writes have failed due to lack of space. FYI: apt *does* give a warning about the space needed for operations. You might have missed it, or perhaps you used a `-y` flag which bypasses confirmation prompts.
alchemy avatar
in flag
@Nmath thx. my wording says apt "could check before *allowing* non-forced install". I know that it show the disk space required. It could check that against current free space before proceeding. Also, with Ubuntu server, it fails gracefully when filled up. I've filled it several times while testing for this post. Desktop will freeze up, but you can get to tty2 with ctrl+alt+f2 and back with ctrl+alt+f7. I used to make a 200MB dummy file just for this to quickly delete. Vacumm and apt clean works well. I do have my Home and Tmp dirs on fixed files mounted as directories to cap them.
user535733 avatar
cn flag
Please file a bug report. Apt is not supposed to damage an Ubuntu system by causing an out-of-space condition.
alchemy avatar
in flag
@user535733 its been that way from the dawn of Apt. Where would I file a bug report?
user535733 avatar
cn flag
True, but that doesn't make it right. Use the Search box at the top of the page to learn how to file a useful bug report that developers will pay attention to.
Nmath avatar
ng flag
That's not supposed to happen. See: [How do I report a bug?](https://askubuntu.com/q/5121) I would caution against filling your root file system. It can and will inevitably cause problems. Allocate more space for Ubuntu so that it won't fill up.
alchemy avatar
in flag
Yes, I use `echo 'SystemMaxUse=200M' >> /etc/systemd/journald.conf && systemctl restart rsyslog` to keep my root happy while running a tight ship. The only things beside var that fill up are home and tmp and i've addressed those per CIS benchmarks as stated above.
Nmath avatar
ng flag
It makes no sense to me why you would deliberately want your file system to be so close to full all of the time. Running a "tight ship" is not a good practice. Ubuntu just doesn't take enough space that you need to be so miserly. FYI `apt clean` only clears the apt cache.
Nmath avatar
ng flag
Perhaps your current and past behavior can explain why apt is currently not functioning as it's supposed to?
alchemy avatar
in flag
@Nmath I dont think my configuring my system is connected to how Apt operates. I wish I had that much power.
Nmath avatar
ng flag
Anyone has the power to break their system! Running out of space on root is a good way for that to happen.
alchemy avatar
in flag
@Nmath yes, thats why that is part of CIS Benchmarks to put home, tmp and var on a separate partition. It still doesnt resolve running into filling storage with apt on small servers. The idea is to mitigate that, not ignore it's possibility. Try setting up a golden image, one that needs to be the smallest size, and you will invariably run into this because Apt's install size estimate isnt perfect. Also, it is much more difficult to reduce a filesystem than to expand it. And it doesnt just break it. Basic systems run perfectly fine for short periods with no root disk space.
alchemy avatar
in flag
For example `df` just said I had 174M free space, "Need to get 16.7 MB of archives. After this operation, 79.5 MB of additional disk space will be used." and then proceeded to fill up the disk to 0% free and halting install during the process. I used `apt clean` and restarted the remaining install which only need 10MB, succeeded and I have 7.7MB left, 89MB after `apt clean`.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.