title: Linux initramfs switch_root unable to find console which kernel uses
body: <p>My system (ARM32) is booting Linux via U-Boot.
  The kernel gets <code>console=ttymxc1,115200</code> as an argument from u-boot.
  Then it uses a shell script with <code>switch_root</code> (interpreted by <code>busybox</code>) inside a initramfs for initializing the root filesystem.
  Furthermore this initramfs script parses the kernel commandline to get the correct <code>console</code>.</p>
  
  <p>The problem is that <code>switch_root</code> is printing to <code>tty1</code>. Nonetheless the kernel uses the correct console, specified in its arguments.
  If I pass no <code>-c</code> argument to <code>switch_root</code> it also uses <code>/dev/tty1</code>, which is the display in my case.</p>
  
  <p>Does anybody of you have an idea how I could get <code>init</code> (sysvinit) to use the console specified in the kernel arguments?</p>
  
  <p>Here's the initramfs script source:</p>
  
  <pre><code>#!/bin/sh
  
  echo "init: rootfs setup"
  
  # mount temporary filesystems
  mount -n -t devtmpfs devtmpfs /dev
  mount -n -t proc     proc     /proc
  mount -n -t sysfs    sysfs    /sys
  mount -n -t tmpfs    tmpfs    /run
  
  read -r cmdline &lt; /proc/cmdline
  
  # define filesystems
  ROOT_DEV="/dev/mydev"
  ROOT="/newroot"
  
  # mount rootfs
  mkdir -p ${ROOT}
  mount ${ROOT_DEV} ${ROOT}
  
  # get &amp; create console
  CONSOLE=$(echo $cmdline) | sed 's/.*console=\(.*\),.*/\1/'
  mknod -m 644 ${ROOT}/dev/${CONSOLE} c 5 1
  
  # switch to new rootfs and exec init
  echo "init: rootfs successful mounted (${ROOT})"
  cd ${ROOT}
  exec switch_root -c /dev/${CONSOLE} . "/sbin/init" "$@"
  </code></pre>
  
  <p>And here's the initramfs <code>config.cfg</code></p>
  
  <pre><code>dir /bin 755 1000 1000
  dir /dev 755 0 0
  dir /mnt 755 0 0
  dir /proc 755 0 0
  dir /run 755 0 0
  dir /sys 755 0 0
  file /bin/busybox initramfs/busybox 755 0 0
  file /init initramfs/init 755 0 0
  nod /dev/console 644 0 0 c 5 1
  nod /dev/ttymxc1 644 0 0 c 5 1
  slink /bin/chroot busybox 777 0 0
  slink /bin/find busybox 777 0 0
  slink /bin/grep busybox 777 0 0
  slink /bin/mkdir busybox 777 0 0
  slink /bin/mknod busybox 777 0 0
  slink /bin/mount busybox 777 0 0
  slink /bin/sed busybox 777 0 0
  slink /bin/sh busybox 777 0 0
  </code></pre>