Boot partition too small, apt-get upgrade fails
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
debian-installer (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
PROBLEM:
On install, the boot partition has the size 244.0 MiB or 499,712 sectors
SYMPTOM:
This causes apt-get upgrade to fail at a later time with messages like:
apt-get --yes dist-upgrade
…
update-initramfs: Generating /boot/initrd.
gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.
run-parts: /etc/kernel/
dpkg: error processing package linux-image-
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of linux-image-
linux-
Package linux-image-
…
Errors were encountered while processing:
linux-
linux-
linux-generic
linux-
linux-
E: Sub-process /usr/bin/dpkg returned an error code (1)
- status code: 100
FIX:
usually want multiple of 2,048 sectors / 1 MiB
One kernel revision is 56 MiB
Miscellaneous files is 28 MiB
File system overhead is 11 MiB
Typically there are 3 kernels: is the running, the latest and the second to latest
56 * 3 + 28 = 196 MiB
A system upgrade requires 120 MiB free
So /boot should be at least 196 + 11 + 120 = 327 MiB in 1 MiB increments
A power of 2 would be 512 MiB or 1,048,576 sectors
affects: | network-manager (Ubuntu) → debian-installer (Ubuntu) |
GETAROUND
Run the following script before any apt-upgrade
It ensures only two kernels are installed
#!/bin/bash -eu remove- kernels haraldrudell. com) Licence: ISC.
# ~/bin/auto-
# Remove kernels except the currently running and the latest
# © 2016 Harald Rudell <email address hidden> (http://
MASTERSTART="$(date +%s%N)"
run() { nelRelease || return
getRunningKer
echo "Running kernel: $KERNEL_RELEASE"
MSG="Running: $KERNEL_RELEASE"
getInstalledK ernelReleases || return RELEASE= "${INSTALLED_ RELEASES[ $((INSTALLED_ RELEASES_ COUNT-1) )]}"
LATEST_
echo "Latest installed release: $LATEST_RELEASE"
MSG+=" latest: $LATEST_RELEASE"
getRemovableR eleases "$KERNEL_RELEASE" "${INSTALLED_ RELEASES[ @]}" || return RELEASES[ @]} -gt 0 ]; then ToRemove "${REMOVABLE_ RELEASES[ @]}" || return
if [ ${#REMOVABLE_
getPackages
if [ ${#PACKAGES[@]} -eq 0 ]; then
echo >&2 "Failed to determine what packages to remove"
return 1
fi
echo "$MSG"
"${LOGGER[@]}" "$MSG" || return
CMD=(sudo apt-get remove --yes ${PACKAGES[@]})
echo "${CMD[*]}"
"${LOGGER[@]}" "${CMD[*]}" || return
"${CMD[@]}" || return
MSG="Package removal ok"
else MSG+=" no more releases: ok"
fi
MSG+=" in $(getDuration "$MASTERSTART") s."
echo "$MSG"
"${LOGGER[@]}" "$MSG" || return
}
parseOptions() { # 160301 "$(basename "${BASH_ SOURCE[ 0]}")" "$(hostname) :$SCRIPTNAME: $$"
SCRIPTNAME=
LOGGER=(logger --priority local1.info --tag "$SCRIPTNAME[$$]" --)
NAME=
displayGreeting
"${LOGGER[@]}" "$NAME: Starting…" || return
}
getRunningKerne lRelease( ) { RELEASE= "$(doCmd uname --kernel-release)" || return RELEASE= "$(sed --silent 's/^\([ 0-9]\+\ .[0-9]\ +\.[0-9] \+-[0-9] \+\).*/ \1/p' <<<"$KERNEL_ RELEASE" )"
KERNEL_
KERNEL_
if [ ! "$KERNEL_RELEASE" ]; then
echo >&2 "Failed to determine kernel release"
return 1
fi
}
getInstalledKer nelReleases( ) { RELEASES= ($(sed --silent 's/^ii linux-[ ^-]\+-\ ([0-9]\ +\.[0-9] \+\.[0- 9]\+-[0- 9]\+\). */\1/p' <<<"$LINUX_ PACKAGES" | sort --version-sort | uniq)) RELEASES_ COUNT=$ {#INSTALLED_ RELEASES[ @]} RELEASES_ COUNT -lt 1 ]; then
getLinuxPackages || return
INSTALLED_
INSTALLED_
if [ $INSTALLED_
echo >&2 "Failed to determine installed kernel releases"
return 1
fi
}
getRemovableRel eases() { # running-version installed-version…
local RUNNING="$1"; shift
REMOVABLE_ RELEASES= () _RELEASES+ =("$1")
while [ $# -gt 1 ]; do # skip last
if [ "$1" != "$RUNNING" ]; then
REMOVABLE
fi
shift
done
}
getPackagesToRe move() { # releases… =($(cut --delimiter=" " --fields=3 <<<"$LINUX_ PACKAGES" | fgrep "$1" | cat))
PACKAGES=()
while [ $# -ge 1 ]; do
PACKAGES+
shift
done
}
getLinuxPackages() { PACKAGES= "$(doCmd dpkg --list "linux-*")" || return PACKAGES= "$(egrep ^ii <<<"$LINUX_ PACKAGES" )" || :
# LINUX_PACKAGES: string with newlines
LINUX_
LINUX_
}
doCmd() { # [-p] command… 160311
# echoes command unless first argument is -p
local AA; local X
if [ "${1-}" = "-p" ]; then shift
else echo "$*"
fi
AA="$("$@" 2>&1)" && X=0 || X=$?
if [ $X != 0 ]; then
echo >&2 -e "Status code: $X\nCommand: $*\nOutput: $AA"
return $X
fi
[ "$AA" ] && echo "$AA" || :
}
...