Tuesday 20 March 2018

Linux connect from host to VirtualBox Guest over virtual serial port


I need to retrieve config file from guest VM without network support. The simplest way to do that is probably to use serial port. As far as I understand I need to create kind of serial port "loop" so that I'll connect using eg. minicom to lets say /dev/vttyS0 and I'll assign /dev/vttyS1 to VirtualBox guest.


Guest is using baud rate 115200. How do I create such pair of devices?


I tried socat:


socat -d -d pty,raw,echo=0 pty,raw,echo=0

However VirtualBox doesn't seem to understand it as correct serial device throwing error


Ioctl failed for serial host device /dev/pts/10 (VERR_INVALID_PARAMETER)
Device will not work properly

ErrorID DrvHostSerialFail
Severity Warning

Answer




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 serial-getty@ttyS0.service
# sudo systemctl start serial-getty@ttyS0.service
# sudo systemctl daemon-reload


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


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...