From a3a743ecb2a96ade123b1237716bd489625b7825 Mon Sep 17 00:00:00 2001 From: Henning Heinold Date: Tue, 26 Aug 2014 18:06:36 +0200 Subject: [PATCH] initramfs: set baudrate for grub from cmdline * take the baudrate for the grub serial console setting from the kernel-cmdline which the system was booted from * better parsing of the options which the install-script gets from init * Video Mode, VGA mode are not used right now and make it empty right now. --- .../initrdscripts/files/init-install.sh | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/recipes-core/initrdscripts/files/init-install.sh b/recipes-core/initrdscripts/files/init-install.sh index 0a02368188..2399a2496e 100644 --- a/recipes-core/initrdscripts/files/init-install.sh +++ b/recipes-core/initrdscripts/files/init-install.sh @@ -9,9 +9,32 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin # We want a 1 Gig partition on the cf partition_size=1000 +# Parse original arguments coming from the kernel cmdline. +# Then shift the first two arguments which contains +# partition information. +dev_name=$1 +shift +image_name=$1 +shift + +kernel_cmdline_console="" +kernel_cmdline_video_mode="" +kernel_cmdline_vga_mode="" + +while [ "$1" != "" ]; do + + echo "$1" | grep -q "console=" + success_console=$? + if [ $success_console -eq 0 ]; then + kernel_cmdline_console=$1 + fi + shift + +done + # Get a list of hard drives hdnamelist="" -live_dev_name=${1%%/*} +live_dev_name=${dev_name%%/*} echo "Searching for hard drives ..." @@ -120,7 +143,7 @@ mkdir /tgt_root mkdir -p /boot echo "Copying rootfs files..." -dd if=/media/$1/$2 of=$rootfs bs=1024 +dd if=/media/$dev_name/$image_name of=$rootfs bs=1024 # Handling of the target root partition mount $rootfs /tgt_root @@ -139,11 +162,13 @@ echo "Preparing boot partition..." GRUBCFG="/boot/grub/grub.cfg" mkdir -p $(dirname $GRUBCFG) +baudrate=`echo $kernel_cmdline_console | cut -f 2 -d ',' | cut -f 1 -d 'n'` + cat > $GRUBCFG << EOF default=0 timeout=1 -serial --unit=0 --speed=38400 +serial --unit=0 --speed=$baudrate terminal --timeout=2 serial terminal_input --append serial @@ -155,9 +180,9 @@ if [ -f /etc/grub.d/40_custom ] ; then cat /etc/grub.d/40_custom >> $GRUBCFG sed -i "s@__ROOTFS__@$rootfs $rootwait@g" $GRUBCFG - sed -i "s/__VIDEO_MODE__/$3/g" $GRUBCFG - sed -i "s/__VGA_MODE__/$4/g" $GRUBCFG - sed -i "s/__CONSOLE__/$5/g" $GRUBCFG + sed -i "s/__VIDEO_MODE__/$kernel_cmdline_video_mode/g" $GRUBCFG + sed -i "s/__VGA_MODE__/$kernel_cmdline_vga_mode/g" $GRUBCFG + sed -i "s/__CONSOLE__/$kernel_cmdline_console/g" $GRUBCFG sed -i "s/quiet/net.ifnames=0 quiet/g" $GRUBCFG sed -i "s/rw/ro/g" $GRUBCFG sed -i "/#/d" $GRUBCFG