Ubuntu 14.04 Azure Serial Console Not Working
After migrating an Ubuntu 14.04 server to Azure using Azure Site Recovery (ASR), the serial console in the portal displayed output correctly but refused to accept any keyboard input. Not particularly helpful when SSH wasn't available.
The fix turns out to be surprisingly simple — it all comes down to one file.
The Fix
Create or update /etc/init/ttyS0.conf with the following contents:
# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.
start on stopped rc RUNLEVEL=[12345]
stop on runlevel [!12345]
respawn
exec /sbin/getty -L 115200 ttyS0 vt102
Then start the service without rebooting:
sudo start ttyS0
That's it. Full two-way serial console access restored.
Why This Happens
Ubuntu 14.04 uses Upstart for service management. The ttyS0 service (which provides the serial console) is not always configured out of the box, and the ASR migration process doesn't add it. Without the ttyS0.conf file, the kernel sends output to the serial port but nothing is listening to accept input.
The getty process that ttyS0.conf launches is what makes the serial port interactive — it handles the login prompt and keyboard input.
Note on Ubuntu 16.04+
Later Ubuntu versions use systemd instead of Upstart. On those, the serial console is typically enabled with:
sudo systemctl enable serial-getty@ttyS0.service
sudo systemctl start serial-getty@ttyS0.service