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 <c...@haraldrudell.com> (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" || :
}

displayGreeting() { # 160301
  echo -e "\n\n===  $NAME $(date --date=@${MASTERSTART:0:-9} 
--rfc-3339=seconds)"
}

getDuration() { # 160223
  # duration in s with .1 s resolution rounded down
  local T0; local T1;
  local DT; local DT_LENGTH
  local RESULT

  if [ $# -eq 0 ]; then RESULT="$(date +%s%N)" # time since 1970-01-01, 
intereger, ns resolution
  else
    T0="$1"
    T1="$(date +%s%N)"
    DT=$((T1 - T0)) # difference in ns
    DT_LENGTH=${#DT}
    if [ $DT_LENGTH -lt 9 ]; then RESULT="0.0" # less than .1 s
    elif [ $DT_LENGTH -eq 9 ]; then RESULT="0.${DT:0:1}" # less than 1 s
    else RESULT="${DT:0:$DT_LENGTH-9}.${DT:$DT_LENGTH-9:1}"
    fi
  fi

  echo "$RESULT"
}

parseOptions "$@" && run && X=0 || X=$?
if [ $X -ne 0 ]; then
  MSG="$SCRIPTNAME status code: $X"
  echo >&2 "$MSG" || :
  "${LOGGER[@]}" "$MSG" || :
  exit $X
fi


** Package changed: network-manager (Ubuntu) => debian-installer (Ubuntu)

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to network-manager in Ubuntu.
https://bugs.launchpad.net/bugs/1652469

Title:
  Boot partition too small, apt-get upgrade fails

Status in debian-installer package in Ubuntu:
  New

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/debian-installer/+bug/1652469/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to