Enable /dev/ttyS0 on Centos 7 vm on ESX server

Issues related to applications and software problems
Post Reply
neo3matrix
Posts: 2
Joined: 2017/05/26 06:56:03

Enable /dev/ttyS0 on Centos 7 vm on ESX server

Post by neo3matrix » 2017/05/26 06:59:50

Hi,

I have created a centos 7 VM on VMWare vsphere ESX server.
I have not attached serial port to this VM to begin with.
But I still need to enable /dev/ttyS0.
How can achieve this? I remember on Centos 6 it was working fine even without attaching serial port.

Any operations I do on /dev/ttyS0 results in ttyS0: input/output error.
dmesg | grep tty only shows:
console [ttyS0] enabled.

But if I attach a serial port to this VM, ttyS0 works just fine.
Then, the dmesg | grep tty shows:
console [ttyS0] enabled.
ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A <---- this tells me that somewhere ttyS0 is now mapped(?) to some pci irq slot which was not happening in the above case.
I tried even playing with systemd files like [email]serial-getty-ttyS0.service but no luck!
If I try to start the service serialgetty-ttyS0, agetty gives error as "/dev/ttyS0 is not a character device."

Could someone please help me?

Thanks in advance.

neo3matrix
Posts: 2
Joined: 2017/05/26 06:56:03

Re: Enable /dev/ttyS0 on Centos 7 vm on ESX server

Post by neo3matrix » 2017/05/26 17:07:58

Let me explain you what I am trying to achieve here:

We have our linux software which can work centos 6 as well as centos 7.
One of the task of that software is to ask user password on the console. (It's a shell script that used "read" command.) User enters that password and it is stored at some location on filesystem.
Now, for a vm instance, a user can use the graphical console of VMWare ESX server (tty1) OR he can use a serial port (ttyS0) connected to this VM - we don't know what he will configure/use at his end.

So, our shell script is generic - something like this:
for t in /dev/tty0 /dev/ttyS0; do
prompt_user_for_password_script $t &
:
:
done
some other important logic "assuming" there are 2 processes running in background.
Now, if I have 2 VMs - one is centos 6 VM and other is Centos 7 VM (Both VMs doesn't have any serial port configured):
1. For centos 6 VM, the above script shows there are 2 processes running in background for prompt_user_for_password script.
2. for centos 7 VM, one of the background process dealing with /dev/ttyS0 fails and returns immediately. Also, if you run any command like stty, or echo or anything on /dev/ttyS0, it fails with error "ttyS0: Input/Output error".
But, if I attach a serial port to centos 7 VM, then the above script works fine.


I think it has something to do with systemd's dynamic tty logic or something. Can someone please help me?

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: Enable /dev/ttyS0 on Centos 7 vm on ESX server

Post by hunter86_bg » 2017/05/27 05:55:54

The only way I have used the serial is by passing the following 2 kernel parameters:

Code: Select all

console=ttyS0 console=tty0
Give it a try.

Post Reply