Hi Thomas Thomas Goirand <tho...@goirand.fr> writes:
> Hi Gaudenz, > > Thanks for this useful bug report. > > Do you know how to tweak systemd to use tty1 instead? Is it possible to > just add something on the command line? I investigated this some more and thin I found the optimal solution which keeps regular console output on the serial console but starts the emergency shell on tty0. To do this the ExecStart setting of the emergency.service systemd unit needs to be overriden. Create a file /etc/systemd/system/emergency.service.d/console.conf with the following content: [Service] ExecStart= ExecStart=-/bin/sh -c "/sbin/sulogin /dev/tty0; /bin/systemctl --fail --no-block default" This first reset the ExecStart setting and then sets it to start the emergency shell on tty0. The same should be done for rescue.service. The first attached patch implements this for both services. During my investigation I also found several other things that are suboptimal about the boot setup: 1. The kernel is booted with the quiet commandline parameter. While this is a nice setting for physical hardware (especially laptop/desktops) to not clutter the boot I think this is suboptimal for cloud images where you only access the boot logs in case of problems. There the quiet parameter might suppress usefull output. 2. There are two copies of extlinux.conf one in / and another one in /boot/extlinux. There should only be one to not confuse users. 3. extlinux is installed into / for no good reason. Why not remove all the copying of extlinux.conf to / and just install to /boot/extlinux. This also avoids additional files in / 4. The kernel and initrd.img are referenced in extlinux.conf by their full path in /boot. This leads to problems if the kernel is updated to an ABI incompatible new version because then the filename changes. This can be avoided by just referencing the symlinks in /. The second attached patch fixes these issues. BTW, why are you using extlinux instead of grub2 which is the standard bootloader in Debian? I would prefer the images to be as similar to the default install as possible. With grub also the kernel update issue would completely go away because update-grub takes care of this. And one more thing. Why is the string "7.0.0-3" hardcoded into the image filename? I would suggest to either just use debian-${RELEASE}-amd64 or read the version number from /etc/debian_version (after debootstrap of course and read from ${MOUNT_DIR}/etc/debian_version, we don't want the version of the build host in the filename). Gaudenz
>From 330eb695e0ec3f5b6519ccb2218ad4019d7f0a0e Mon Sep 17 00:00:00 2001 From: Gaudenz Steinlin <gaud...@soziologie.ch> Date: Mon, 18 May 2015 16:24:43 +0200 Subject: [PATCH 1/2] Start rescue and emergency shells on tty1 By default the rescue and emergency shell are started on the boot console. This is ttyS0 on this image in order to have the boot output on the serial console which is accessible by "nova console-log". But there is no input device connected to this console, so the shells there are pretty useless. On the other hand tty0 is accessible via the spice or VNC console. Closes: #784334 --- build-openstack-debian-image | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build-openstack-debian-image b/build-openstack-debian-image index e503fa9..bd7824f 100755 --- a/build-openstack-debian-image +++ b/build-openstack-debian-image @@ -358,6 +358,15 @@ chroot ${MOUNT_DIR} update-initramfs -u rm ${MOUNT_DIR}/var/cache/apt/archives/*.deb +# Set console for emergency and rescue shells +SYSTEMD_DIR="${MOUNT_DIR}/etc/systemd/system/" +for service in emergency.service rescue.service ; do + mkdir "${SYSTEMD_DIR}/${service}.d" + echo '[Service] +ExecStart= +ExecStart=-/bin/sh -c "/sbin/sulogin /dev/tty0; /bin/systemctl --fail --no-block default"' > "${SYSTEMD_DIR}/${service}.d/console.conf" +done + ########################### ### Setting-up extlinux ### ########################### -- 2.1.4
>From caee39deebc111a0dfa40f4b6cccc579c40f43a8 Mon Sep 17 00:00:00 2001 From: Gaudenz Steinlin <gaud...@soziologie.ch> Date: Mon, 18 May 2015 16:27:35 +0200 Subject: [PATCH 2/2] Improved extlinux configuration * Only install extlinux in /boot/extlinux. Some parts were installed in / only, others in both locations. * Remove the quiet flag from the standard boot command. This is usefull on desktops to not clutter the boot screen, but not on a cloud image. * Use symlinks to kernel and initrd. This allows seamless kernel upgrades. --- build-openstack-debian-image | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/build-openstack-debian-image b/build-openstack-debian-image index bd7824f..d318810 100755 --- a/build-openstack-debian-image +++ b/build-openstack-debian-image @@ -370,19 +370,14 @@ done ########################### ### Setting-up extlinux ### ########################### -KERNEL=`chroot ${MOUNT_DIR} find boot -name 'vmlinuz-*'` -RAMDISK=`chroot ${MOUNT_DIR} find boot -name 'initrd.img-*'` UUID=`blkid -o value -s UUID /dev/mapper/${LOOP_DEVICE}` mkdir -p ${MOUNT_DIR}/boot/extlinux echo "default linux timeout 1 label linux -kernel ${KERNEL} -append initrd=${RAMDISK} root=/dev/vda1 console=tty0 console=ttyS0,115200 ro quiet" > ${MOUNT_DIR}/boot/extlinux/extlinux.conf -#append initrd=${RAMDISK} root=/dev/vda1 ro quiet console=ttyS0" > ${MOUNT_DIR}/boot/extlinux/extlinux.conf -cp ${MOUNT_DIR}/boot/extlinux/extlinux.conf ${MOUNT_DIR}/extlinux.conf -extlinux --install ${MOUNT_DIR} -#chroot ${MOUNT_DIR} extlinux-update +kernel /vmlinuz +append initrd=/initrd.img root=/dev/vda1 console=tty0 console=ttyS0,115200 ro" > ${MOUNT_DIR}/boot/extlinux/extlinux.conf +extlinux --install ${MOUNT_DIR}/boot/extlinux ################### ### HOOK SCRIPT ### -- 2.1.4