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.
This commit is contained in:
Henning Heinold 2014-08-26 18:06:36 +02:00 committed by Holger Hans Peter Freyther
parent 28628cba81
commit a3a743ecb2
1 changed files with 31 additions and 6 deletions

View File

@ -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