Project

General

Profile

Actions

Foreman and xen

While deploying debian/ubuntu based clients from foreman in xen virtual environment I faced some issues. I will explain them with solutions I found.

1) When you install OS from xen template tty is redirected properly but when deploy using foreman tty is not redirected and thus you will only see starting of vm but not the login console. To solve this debian and ubuntu both has different ways.

For Debian you should add "console=hvc0" in GRUB_CMDLINE_LINUX in file /etc/default/grub and update grub. I did it using following commands.

sed -i 's/'GRUB_CMDLINE_LINUX=""'/'GRUB_CMDLINE_LINUX="console=hvc0"'/g' /etc/default/grub && update-grub2

you will also have to add line "co:2345:respawn:/sbin/getty hvc0 9600 linux" in /etc/inittab this can be done using following commands

sed -i "s/1:2345:respawn:\/sbin\/getty 38400 tty1/co:2345:respawn:\/sbin\/getty hvc0 9600 linux\n\n1:2345:respawn:\/sbin\/getty 38400 tty1/g" /etc/inittab

For Ubuntu you should mv tty1.conf in /etc/init/ to hvc0.conf and replace every instance of tty1 with hvc0 you can use following commands to do that

mv /etc/init/tty1.conf /etc/init/hvc0.conf 
sed -i 's/'tty1'/'hvc0'/g' /etc/init/hvc0.conf

For both Debian & Ubuntu, if you don't want to restart server after doing this to see console you can start hvc0 by following command

exec /sbin/getty hvc0 9600 linux &

2) During provisioning if you are using pv(para-virtualization) mode, there is no bios and pxe boot enable. To overcome this you can create a new vm using template as you normally do with iso or cd. Boot the vm so you on console you see installation, now instead of starting installation shutdown the vm. This starting and shutting down vm is important part as this marks virtual disk bootable. Now eject cd or remove iso from vm and go to vm menu and select start in recovery mode. This will boot vm in HV mode with pxe booting enabled. If you have configured DHCP server for vm's MAC address vm will boot from tftp server and automated OS installation will start.
This should work with all OS not only debian based but I have only tested this with debian and ubuntu.

Updated by Pujan Shah over 9 years ago · 2 revisions