2

I have a computer (let's call it as DevPC) that sometimes run Linux in native environment and that sometimes run Linux on Xen. I connect this computer to another computer (let's call it as MonitorPC) via serial console so that when the DevPC crashes, I know the error message.

The situation is as follows:

When the DevPC runs Linux in native environment, the serial console /dev/ttyS4 will use the configuration exec /sbin/getty -8 -L ttyS4 115200 vt102 in /etc/init/ttyS0.conf;

When the DevPC runs Linux in Xen environment, the serial console /dev/ttyS4 will use the configuration exec /sbin/getty -8 -L hvc0 115200 vt102 in /etc/init/ttyS0.conf

If the DevPC runs Linux in Xen environment, but uses the configuration exec /sbin/getty -8 -L ttyS4 115200 vt102, I will see that the getty will fails to spawn. The error message is as follows:

[ 3807.606153] init: ttyS0 main process (7171) terminated with status 1 [ 3807.606197] init: ttyS0 main process ended, respawning

I can fix this manually by changing the /etc/init/ttyS0.conf when it happens. However, this is quite annoying and is a kind of labor work.

My question is:

Is there a way that I can configure the ttyS0.conf so that the getty can use different configurations in different environments?

I know how to detect if the machine is running in Xen environment by checking the output of the command xl list. However, I'm not sure how to encode this information into the getty's spawning scripts or into the ttyS0.conf

Thank you very much for your help and time! I really appreciate for any advice or suggestion.

  • This isn't a direct answer, but: If you're running udev to set up the contents of /dev, you can give the device a persistent name, say, montty, by telling udev to add a SYMLINK to whichever of ttyS4 or hvc0 gets created. – Mark Plotnick May 7 '16 at 19:56
  • Did you mean that let the udev script to determine if it's in Xen env or not and then dynamically link the montty to ttyS4 or hvc0 based on the environment it's running? – Mike May 8 '16 at 14:28
  • If hvc0 and ttyS4 each exist in only one environment, you can just key off of their presence; no need to run an external command like xl list. – Mark Plotnick May 8 '16 at 14:37
  • Hi @MarkPlotnick, thank you very much for your advice! Both ttyS4 and hvc0 can exist at the same time, so I guess I have to use xl list or similar command to detect the environment? – Mike May 8 '16 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.