Enable ttyS0 on VMWare vsphere VM instace for Centos 7

General discussion and chat (archived)
neo3matrix

Enable ttyS0 on VMWare vsphere VM instace for Centos 7

Unread post by neo3matrix » 2017-05-26, 06:31

Hi,

I have created a centos 7 VM on VMWare vspher 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 serial-getty@ttyS0.service but no luck!
If I try to start the serive serialgetty@ttyS0, agetty gives error as "/dev/ttyS0 is not a character device."

Could someone please help me?

Thanks in advance.

neo3matrix

Re: Enable ttyS0 on VMWare vsphere VM instace for Centos 7

Unread post by neo3matrix » 2017-05-26, 17:18

Hi all,

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?

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35477
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Enable ttyS0 on VMWare vsphere VM instace for Centos 7

Unread post by Moonchild » 2017-05-26, 19:29

Moving this to technical chat since it's completely unrelated to pale moon development.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Locked