Linux connect from host to VirtualBox Guest over virtual serial port


First Setup Serial Console Setting in Host OS.
In virtualbox setting,
serial Ports --> Port 1
Port No. COM1
Port Mode - Host Pipe
connect to existing pipe/socked - UNCHECKED
Path/Addess: /tmp/vbox
Now, Set Minicom
sudo minicom -s -c on
Serial port setup
Serial Device : unix#/tmp/vbox
Exit


Enable Serial Console In Guest
sudo vi /etc/default/grub
GRUB_CMDLINE_LINUX="console=ttyS0,115200n8 console=tty0 ignore_loglevel"
sudo update-grub
Now Enable getty On Console ttyS0
For Upstart Sytem
1) Create a file called /etc/init/ttyS0.conf containing the following:

# 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

2) Ask upstart to start the getty

sudo start ttyS0


For Systemd Systems

# sudo systemctl enable [email protected]
# sudo systemctl start [email protected]
# sudo systemctl daemon-reload


Now reboot your guest os and you will get serial console on your host os via minicom


The way to connect from host to guest is to

  1. Create serial port in virtualbox in "Host Pipe" mode with path eg. /dev/vboxttyS0.
  2. enable that serial port in guest
  3. Use socat unix-connect:/dev/vboxttyS0 -,b57600 or socat unix-connect:/dev/vboxttyS0 -,raw,echo=0 which in my particular case worked better.

I contacted OS vendor and it turns out serial ports have to be enabled explicitly, even though on bare metal devices they're enabled by default :/