Boot partition too small, apt-get upgrade fails

Bug #1652469 reported by Harald Rudell
This bug report is a duplicate of:  Bug #1465050: Size of /boot partition is too small. Edit Remove
12
This bug affects 2 people
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.img-4.4.0-57-generic
gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.4.0-57-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-57-generic (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-extra-4.4.0-57-generic; however:
  Package linux-image-extra-4.4.0-57-generic is not configured yet.

Errors were encountered while processing:
 linux-image-extra-4.4.0-57-generic
 linux-image-generic
 linux-generic
 linux-signed-image-generic
 linux-signed-generic
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

Revision history for this message
Harald Rudell (harald-rudell) wrote :
Download full text (4.0 KiB)

GETAROUND
Run the following script before any apt-upgrade
It ensures only two kernels are installed

#!/bin/bash -eu
# ~/bin/auto-remove-kernels
# Remove kernels except the currently running and the latest
# © 2016 Harald Rudell <email address hidden> (http://haraldrudell.com) Licence: ISC.

MASTERSTART="$(date +%s%N)"

run() {
  getRunningKernelRelease || return
  echo "Running kernel: $KERNEL_RELEASE"
  MSG="Running: $KERNEL_RELEASE"

  getInstalledKernelReleases || return
  LATEST_RELEASE="${INSTALLED_RELEASES[$((INSTALLED_RELEASES_COUNT-1))]}"
  echo "Latest installed release: $LATEST_RELEASE"
  MSG+=" latest: $LATEST_RELEASE"

  getRemovableReleases "$KERNEL_RELEASE" "${INSTALLED_RELEASES[@]}" || return
  if [ ${#REMOVABLE_RELEASES[@]} -gt 0 ]; then
    getPackagesToRemove "${REMOVABLE_RELEASES[@]}" || return
    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
  SCRIPTNAME="$(basename "${BASH_SOURCE[0]}")"
  LOGGER=(logger --priority local1.info --tag "$SCRIPTNAME[$$]" --)
  NAME="$(hostname):$SCRIPTNAME:$$"
  displayGreeting

  "${LOGGER[@]}" "$NAME: Starting…" || return
}

getRunningKernelRelease() {
  KERNEL_RELEASE="$(doCmd uname --kernel-release)" || return
  KERNEL_RELEASE="$(sed --silent 's/^\([0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+\).*/\1/p' <<<"$KERNEL_RELEASE")"
  if [ ! "$KERNEL_RELEASE" ]; then
    echo >&2 "Failed to determine kernel release"
    return 1
  fi
}

getInstalledKernelReleases() {
  getLinuxPackages || return
  INSTALLED_RELEASES=($(sed --silent 's/^ii linux-[^-]\+-\([0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+\).*/\1/p' <<<"$LINUX_PACKAGES" | sort --version-sort | uniq))
  INSTALLED_RELEASES_COUNT=${#INSTALLED_RELEASES[@]}
  if [ $INSTALLED_RELEASES_COUNT -lt 1 ]; then
    echo >&2 "Failed to determine installed kernel releases"
    return 1
  fi
}

getRemovableReleases() { # running-version installed-version…
  local RUNNING="$1"; shift

  REMOVABLE_RELEASES=()
  while [ $# -gt 1 ]; do # skip last
    if [ "$1" != "$RUNNING" ]; then
      REMOVABLE_RELEASES+=("$1")
    fi
    shift
  done
}

getPackagesToRemove() { # releases…
  PACKAGES=()
  while [ $# -ge 1 ]; do
    PACKAGES+=($(cut --delimiter=" " --fields=3 <<<"$LINUX_PACKAGES" | fgrep "$1" | cat))
    shift
  done
}

getLinuxPackages() {
  # LINUX_PACKAGES: string with newlines
  LINUX_PACKAGES="$(doCmd dpkg --list "linux-*")" || return
  LINUX_PACKAGES="$(egrep ^ii <<<"$LINUX_PACKAGES")" || :
}

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" || :
}
...

Read more...

affects: network-manager (Ubuntu) → debian-installer (Ubuntu)
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in debian-installer (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.