2

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
  • Installing Guest additions, so you can mount a shared storage into both Guest and Host, is out of the question? – Marek Rost Jun 29 '17 at 5:34
  • @MarekRost it's proprietary embedded OS. Doesn't have standard prompt nor even direct access to drive. It only has configuration prompt with command that dumps device configuration to console output. It seems to be the only way to get config out of device. It doesn't even support framebuffer, VirtualBox is displaying standard VM monitor using serial port 0. – Lapsio Jun 29 '17 at 20:07
6


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

1

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 :/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.