]> pere.pagekite.me Git - homepage.git/commitdiff
New post.
authorPetter Reinholdtsen <pere@hungry.com>
Sun, 8 Jul 2018 09:48:12 +0000 (11:48 +0200)
committerPetter Reinholdtsen <pere@hungry.com>
Sun, 8 Jul 2018 09:48:12 +0000 (11:48 +0200)
blog/data/2018-07-08-apt-upgrade-full-disk.txt [new file with mode: 0644]

diff --git a/blog/data/2018-07-08-apt-upgrade-full-disk.txt b/blog/data/2018-07-08-apt-upgrade-full-disk.txt
new file mode 100644 (file)
index 0000000..2d0baa2
--- /dev/null
@@ -0,0 +1,60 @@
+Title: Debian APT upgrade without enough free space on the disk...
+Tags: english, debian
+Date: 2018-07-08 12:00
+
+<p>Quite regularly, I let my Debian Sid/Unstable chroot stay untouch
+for a while, and when I need to update it there is not enough free
+space on the disk for apt to do a normal 'apt upgrade'.  I normally
+would resolve the issue by doing 'apt install &lt;somepackages&gt;' to
+upgrade only some of the packages in one batch, until the amount of
+packages to download fall below the amount of free space available.
+Today, I had about 500 packages to upgrade, and after a while I got
+tired of trying to install chunks of packages manually.  I concluded
+that I did not have the spare hours required to complete the task, and
+decided to see if I could automate it.  I came up with this small
+script which I call 'apt-in-chunks':</p>
+
+<p><blockquote><pre>
+#!/bin/sh
+#
+# Upgrade packages when the disk is too full to upgrade every
+# upgradable package in one lump.  Fetching packages to upgrade using
+# apt, and then installing using dpkg, to avoid changing the package
+# flag for manual/automatic.
+
+set -e
+
+ignore() {
+    if [ "$1" ]; then
+       grep -v "$1"
+    else
+       cat
+    fi
+}
+
+for p in $(apt list --upgradable | ignore "$@" |cut -d/ -f1 | grep -v '^Listing...'); do
+    echo "Upgrading $p"
+    apt clean
+    apt install --download-only -y $p
+    for f in /var/cache/apt/archives/*.deb; do
+       if [ -e "$f" ]; then
+           dpkg -i /var/cache/apt/archives/*.deb
+           break
+       fi
+    done
+done
+</pre></blockquote></p>
+
+<p>To use it, simply run it as root from the command line.  If it
+fail, try 'apt install -f' to clean up the mess and run the script
+again.</p>
+
+<p>It take one option, a package to ingore in the list of packages to
+upgrade.  The option to ignore a package is there to be able to skip
+the packages that are simply too large to unpack.  Today this was
+'ghc', but I have run into other large packages causing similar
+problems earlier (like TeX).</p>
+
+<p>As usual, if you use Bitcoin and want to show your support of my
+activities, please send Bitcoin donations to my address
+<b><a href="bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b</a></b>.</p>