It seems to me that 'echo hi mom' from the initramfs (or from an upstart job 
with 'output console') should never result in failure.  This is failing in the 
above situation because the kernel cmdline has 'console=tty1 console=ttyS0' on 
it, but ttyS0 is not a valid device.
So, it seems the following are potential fixes to the issue:
 a.) kernel doing better sanity checking on console= argument and not attaching 
/dev/console to something that is going to fail
 b.) initramfs and upstart verifying that /dev/console can be written to, and 
if not, then redirecting output to somewhere that *is* writable (possibly /run/ 
or /dev/null).

Clearly, i could change cloud-initramfs-growroot to not fail when it
fails to write to its stdout, but that seems not a general fix.

For initramfs, we could do something very early in the initramfs like
this:

if ! echo "initramfs running" > /dev/console; then
  read cmdline < /proc/cmdline
  consoles=""
  for tok in $cmdline; do
    [ ${tok#console=} != ${tok} ] || continue;
    tok=${tok#console=}; tok=${tok%,*};
    # reverse order on cmdline
    consoles="$tok $consoles";
  done
  failed=""
  found=""
  for console in $consoles; do
    dev="/dev/${console#/dev}"
    echo "initramfs running" > "$dev" &&
      found=$dev && break ||
      failed="${failed:+${failed}$dev}"
  done
  if [ -n "$found" ]; then
    exec > "$found" 2>&1
  else
    exec > "/run/initramfs.log" 2>&1
  fi
  echo "WARN: Failed write to /dev/console${failed:+ and ${failed}}"
fi

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1123220

Title:
  cloud-image VM causes kernel panic if image is resized

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cloud-initramfs-tools/+bug/1123220/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to