diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-05-29 16:36:58 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-05-29 16:36:58 +0300 |
commit | c6d5f522c24683a7846dfd2407e264977ce19122 (patch) | |
tree | 753c9ebca1b64dadbe593c5eb1a2e8dd3a1d91c4 | |
parent | 5f68e0b7c2d9511d61565f97ac233894a186305d (diff) | |
download | vmdb2-c6d5f522c24683a7846dfd2407e264977ce19122.tar.gz |
Enable serial console for grub installs
-rw-r--r-- | pc.vmdb | 1 | ||||
-rw-r--r-- | vmdb/plugins/grub_plugin.py | 21 |
2 files changed, 22 insertions, 0 deletions
@@ -40,3 +40,4 @@ steps: root-fs: root-fs root-part: root-part device: "{{ output }}" + console: serial diff --git a/vmdb/plugins/grub_plugin.py b/vmdb/plugins/grub_plugin.py index 58af4e0..49a311b 100644 --- a/vmdb/plugins/grub_plugin.py +++ b/vmdb/plugins/grub_plugin.py @@ -121,6 +121,7 @@ class GrubStepRunner(vmdb.StepRunnerInterface): def install_grub(self, step, settings, state, grub_package, grub_target): device = step['device'] + console = step.get('console', None) rootfs = step['root-fs'] chroot = state.mounts[rootfs] @@ -147,7 +148,19 @@ class GrubStepRunner(vmdb.StepRunnerInterface): 'consoleblank=0', 'systemd.show_status=true', ] + if console == 'serial': + kernel_params.extend([ + 'quiet', + 'loglevel=3', + 'rd.systemd.show_status=false', + 'systemd.show_status=false', + 'console=tty0', + 'console=ttyS0,115200n8', + ]) + self.set_grub_cmdline_config(chroot, kernel_params) + if console == 'serial': + self.add_grub_serial_console(chroot) self.chroot(chroot, ['grub-mkconfig', '-o', '/boot/grub/grub.cfg']) self.chroot( @@ -235,3 +248,11 @@ class GrubStepRunner(vmdb.StepRunnerInterface): with open(filename, 'w') as f: f.write('\n'.join(lines) + '\n') + + def add_grub_serial_console(self, chroot): + filename = self.chroot_path(chroot, '/etc/default/grub') + + with open(filename, 'a') as f: + f.write('GRUB_TERMINAL=serial\n') + f.write('GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 ' + '--word=8 --parity=no --stop=1"\n') |