Console - Serial Console
Console - Serial Console
Overview
The serial console in VyOS provides a mechanism for remotely managing the router through a serial port. This is especially useful in the following scenarios:
- Out-of-band management: Access to the device independent of the state of the network interfaces
- Boot diagnostics: Monitoring the system boot process and identifying problems at an early stage
- Emergency recovery: Access to the system when the network configuration is not working
- Cloud platforms: Access to virtual machines through the cloud provider’s web console
- Bare-metal servers: Managing physical servers through KVM or IPMI
The serial console is not a necessity for ordinary users, but it becomes critically important for system administrators working with server hardware or cloud infrastructures.
Supported Console Devices
VyOS supports various types of console devices:
Serial Devices (ttySN)
Standard serial ports built into server hardware:
ttyS0- First serial port (COM1)ttyS1- Second serial port (COM2)ttyS2- Third serial port (COM3)ttyS3- Fourth serial port (COM4)
These ports are typically used on physical servers and some virtual machines.
USB Serial Devices (ttyUSBX)
USB-to-serial adapters and converters:
ttyUSB0- First USB serial adapterttyUSB1- Second USB serial adapterttyUSBX- Additional USB adapters
USB adapters are useful for devices without built-in serial ports or when additional console connections are required.
Virtual Consoles
Specialized console devices for virtualization:
hvc0- Xen HVM console (for Xen virtualization)
Basic Console Configuration
Configuring the Serial Console
Basic serial console configuration on ttyS0 with default settings:
configure
set system console device ttyS0
commit
saveConfiguring the Baud Rate
VyOS supports the following data transfer rates:
- 1200 bps
- 2400 bps
- 4800 bps
- 9600 bps (standard rate)
- 19200 bps
- 38400 bps
- 57600 bps
- 115200 bps (high speed, used by default)
Example: Console at 9600 bps
configure
set system console device ttyS0 speed 9600
commit
saveExample: Console at 115200 bps
configure
set system console device ttyS0 speed 115200
commit
saveExample: USB console at 38400 bps
configure
set system console device ttyUSB0 speed 38400
commit
saveRecommendations for Choosing a Baud Rate
9600 bps:
- The most compatible rate
- Recommended for older hardware
- Minimal risk of data transmission errors
- Slow for large volumes of text
115200 bps:
- High data transfer rate
- Recommended for modern hardware
- Fast output of logs and commands
- May be unstable on poor-quality cables or USB adapters
The golden mean (38400-57600 bps):
- Optimal balance of speed and stability
- Suitable for most scenarios
- Good performance with a reliable connection
Console Rotation
VyOS supports configuring multiple console devices simultaneously. This is useful for redundancy or access through different physical interfaces.
Example: Multiple Serial Consoles
configure
# First console on ttyS0 (primary)
set system console device ttyS0 speed 115200
# Second console on ttyS1 (backup)
set system console device ttyS1 speed 115200
# USB console for local access
set system console device ttyUSB0 speed 9600
commit
saveExample: Combination of Virtual and Physical Consoles
configure
# Xen virtual console (for the cloud platform)
set system console device hvc0 speed 115200
# Physical serial console (for IPMI/KVM)
set system console device ttyS0 speed 115200
commit
saveBoot Console Configuration
GRUB Serial Console
To access the GRUB bootloader through the serial console, you need to modify the GRUB configuration. This allows you to control the system boot process through the serial port.
Editing the GRUB Configuration
# Edit the GRUB configuration
sudo vi /boot/grub/grub.cfgAdd the following lines to the beginning of the file (after the header):
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal_input serial console
terminal_output serial consoleKernel Boot Parameters
Make sure the kernel boot parameters include the console settings:
# Add the following to the linux parameters:
console=tty0 console=ttyS0,115200n8Full example of a GRUB entry:
menuentry 'VyOS' {
load_video
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
echo 'Loading VyOS...'
linux /boot/vmlinuz root=/dev/sda1 ro console=tty0 console=ttyS0,115200n8 quiet
echo 'Loading initial ramdisk...'
initrd /boot/initrd.img
}Persistent GRUB Configuration
To preserve the changes across system updates, edit the default configuration file:
# Edit the default configuration file
sudo vi /etc/default/grubAdd or modify the following parameters:
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
GRUB_TERMINAL="serial console"Update the GRUB configuration:
sudo update-grubExamples for Cloud Platforms
Yandex Cloud: Access via Serial Console
Yandex Cloud provides access to the serial console of virtual machines through the web interface. VyOS in Yandex Cloud uses a pre-configured serial console.
VyOS Configuration for Yandex Cloud
Standard configuration for Yandex Cloud (usually already set up in the image):
configure
# Configuring the serial console for Yandex Cloud
set system console device ttyS0 speed 9600
commit
saveAccess via the Yandex Cloud Web Console
- Open the Yandex Cloud Console: https://console.cloud.yandex.ru
- Go to the “Compute Cloud” section
- Select the VyOS virtual machine
- Click the “Connect” button and select “Serial Console”
- In the terminal that opens, press Enter to activate the console
Access via the Yandex Cloud CLI
# Connecting to the serial console via CLI
yc compute instance serial-port-output <instance-id>
# Retrieving the last 1000 lines of output
yc compute instance serial-port-output <instance-id> --lines 1000
# Interactive connection (requires an SSH key)
yc compute connect-to-serial-port --instance-id <instance-id>Configuring Serial Console Logging in Yandex Cloud
configure
# Enable system logging
set system syslog global facility all level info
# Configure console output
set system console device ttyS0 speed 9600
commit
saveYandex Cloud Serial Console Specifics
- Speed: Use 9600 bps for stable operation
- Availability: The serial console is available even when there are network problems
- History: Yandex Cloud stores the console output history (up to 64 KB)
- Security: Access to the serial console requires permissions on the virtual machine
VK Cloud: Serial Console for Bare-Metal Servers
VK Cloud (formerly Mail.ru Cloud Solutions) provides access to the serial console for bare-metal servers through the IPMI/KVM interface.
VyOS Configuration for VK Cloud Bare-Metal
configure
# Configuring the serial console
set system console device ttyS0 speed 115200
# Optional: an additional console for redundancy
set system console device ttyS1 speed 115200
commit
saveAccess via IPMI Console
- Log in to the VK Cloud control panel
- Go to the “Servers” -> “Bare-metal” section
- Select the server with VyOS
- Click “IPMI Console” or “KVM Console”
- The serial console will be available in the window that opens
Configuration for Remote IPMI Access
configure
# Configuring a high-speed console for IPMI
set system console device ttyS0 speed 115200
# Enable SSH for alternative access
set service ssh port 22
set service ssh listen-address 0.0.0.0
commit
saveIPMI Serial-over-LAN (SOL)
For direct access through IPMI Serial-over-LAN:
# From the client machine, connect to IPMI
ipmitool -I lanplus -H <ipmi-ip> -U <username> -P <password> sol activateThe VyOS configuration must use a speed of 115200 bps for SOL:
configure
set system console device ttyS0 speed 115200
commit
saveVerifying the Console Configuration
Viewing the Current Configuration
# Show the system console configuration
show configuration system console
# Example output:
# console {
# device ttyS0 {
# speed 115200
# }
# }Checking Active Console Devices
# Show active TTY devices
show system tty
# Alternative method (in operational mode)
run show system ttyViewing System Console Logs
# View the serial console logs
show log tail
# Search for messages related to the console
show log | match consoleTesting Console Output
# Print a test message to the console
echo "Test message to console" | tee /dev/ttyS0
# Verify console operation through dmesg
show system kernel-messages | match ttySChecking Serial Port Parameters
# View serial port parameters (from operational mode)
run show interfaces serial ttyS0
# Detailed information via stty (from the shell)
sudo stty -F /dev/ttyS0 -aTroubleshooting
Problem: The console does not respond
Symptoms: No output on the serial console after connecting.
Solutions:
- Check the speed (baud rate) settings on both ends of the connection:
# Make sure the console speed matches the terminal program
show configuration system console device ttyS0- Verify that the device is active:
# Check the device status
run show system tty- Restart getty for the console:
# From shell mode
sudo systemctl restart serial-getty@ttyS0.service- Check the physical cable connection (for bare-metal).
Problem: Garbled characters on the console
Symptoms: The console output contains incorrect characters or unreadable text.
Cause: A mismatch in the speed, parity, or data bit settings.
Solutions:
- Set the standard speed of 9600 bps:
configure
set system console device ttyS0 speed 9600
commit
saveCheck the terminal program parameters:
- Data bits: 8
- Parity: None
- Stop bits: 1
- Flow control: None (or Hardware)
Try other speeds one by one:
configure
set system console device ttyS0 speed 38400
commit
# Test the console
# If it does not work, try another speed
set system console device ttyS0 speed 57600
commitProblem: The USB console is not detected
Symptoms: The USB-to-serial adapter is not displayed as ttyUSB0.
Solutions:
- Check that the USB device is recognized:
# Check USB devices
run show system usb
# Or via lsusb
lsusb- Check that the drivers are loaded:
# Check the loaded modules for USB serial
lsmod | grep usbserial
lsmod | grep ftdi
lsmod | grep pl2303- Check dmesg for USB-related messages:
run show system kernel-messages | match -i usb
run show system kernel-messages | match ttyUSB- Try another USB port or adapter.
Problem: The console works, but GRUB is not displayed
Symptoms: The VyOS console works, but the GRUB menu is not visible during boot.
Solution: Configure GRUB to output to the serial console:
# Edit the GRUB configuration
sudo vi /etc/default/grub
# Add the parameters:
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"
GRUB_TERMINAL="serial console"
# Update GRUB
sudo update-grub
# Reboot the system
reboot nowProblem: Slow console output
Symptoms: Commands execute quickly, but the output appears slowly.
Solutions:
- Increase the transfer speed:
configure
set system console device ttyS0 speed 115200
commit
save- Check the flow control settings:
# Disable flow control (in shell mode)
sudo stty -F /dev/ttyS0 -crtscts -ixon -ixoff- Reduce the volume of output:
# Instead of the full show configuration
show configuration commands
# Use grep to filter
show configuration | match interfaceProblem: The console loses connection
Symptoms: The console connection drops periodically.
Solutions:
- For cloud platforms, check the timeout settings:
# Increase the timeout for SSH sessions
configure
set service ssh client-keepalive-interval 60
commit
saveFor physical connections:
- Check the cable quality
- Use shielded cables
- Reduce the speed to 9600 bps
Configure automatic reconnect in the terminal program.
Best Practices
Console Security
- Restricting access to the physical console:
configure
# Configure the console session timeout
set system login timeout 300
# Require authentication for the console
set system console device ttyS0
commit
save- Logging console sessions:
configure
# Enable auditing of system events
set system syslog global facility auth level info
set system syslog global facility authpriv level info
# Send logs to a remote server
set system syslog host 192.168.1.100 facility auth level info
commit
save- Protecting GRUB with a password (optional):
# Create a password hash for GRUB
grub-mkpasswd-pbkdf2
# Add to /etc/grub.d/40_custom
set superusers="root"
password_pbkdf2 root <generated-hash>Performance and Reliability
Choosing the optimal speed:
- Local connections: 115200 bps
- Cloud platforms: 9600-38400 bps
- Long cables: 9600-19200 bps
Console redundancy:
configure
# Configure multiple console devices
set system console device ttyS0 speed 115200
set system console device ttyS1 speed 115200
# For cloud environments
set system console device hvc0 speed 115200
set system console device ttyS0 speed 9600
commit
save- Monitoring the console state:
# Create a console check script
configure
set system task-scheduler task check-console executable path /config/scripts/check-console.sh
set system task-scheduler task check-console interval 5m
commit
saveExample of the /config/scripts/check-console.sh script:
#!/bin/bash
# Check the health of the serial console
CONSOLE_DEVICE="/dev/ttyS0"
LOG_FILE="/var/log/console-check.log"
if [ -e "$CONSOLE_DEVICE" ]; then
echo "$(date): Console device $CONSOLE_DEVICE is present" >> "$LOG_FILE"
# Check whether writing is possible
if echo "test" > "$CONSOLE_DEVICE" 2>/dev/null; then
echo "$(date): Console device $CONSOLE_DEVICE is writable" >> "$LOG_FILE"
else
echo "$(date): WARNING: Console device $CONSOLE_DEVICE is not writable" >> "$LOG_FILE"
# Restart getty
systemctl restart serial-getty@ttyS0.service
fi
else
echo "$(date): ERROR: Console device $CONSOLE_DEVICE not found" >> "$LOG_FILE"
fiDocumenting the Configuration
- Adding comments to the configuration:
configure
# Add a description of the console configuration
comment system console device ttyS0 "Primary serial console for IPMI/KVM access"
comment system console device ttyS0 speed "115200 bps for high-speed output"
commit
save- Saving configuration backups:
# Create a backup with a description
save /config/backup/config-with-console-$(date +%Y%m%d).bootCloud Platforms
- Yandex Cloud: Use 9600 bps for stability:
configure
set system console device ttyS0 speed 9600
commit
save- VK Cloud Bare-Metal: Use 115200 bps for IPMI SOL:
configure
set system console device ttyS0 speed 115200
commit
save- Hybrid configuration (virtual + physical):
configure
# Virtual console for the cloud
set system console device hvc0 speed 115200
# Physical console for backup access
set system console device ttyS0 speed 9600
commit
saveAdvanced Scenarios
Automatic Console Configuration During Deployment
Example of a script for automatically configuring the console depending on the platform:
#!/bin/vbash
# /config/scripts/configure-console.sh
# Automatic console configuration depending on the platform
source /opt/vyatta/etc/functions/script-template
# Detecting the platform
if [ -e /sys/hypervisor/type ]; then
HYPERVISOR=$(cat /sys/hypervisor/type)
else
HYPERVISOR="none"
fi
# Configuration depending on the hypervisor
case $HYPERVISOR in
xen)
# Yandex Cloud or another Xen platform
configure
set system console device hvc0 speed 115200
set system console device ttyS0 speed 9600
commit
save
;;
kvm)
# KVM virtualization
configure
set system console device ttyS0 speed 115200
commit
save
;;
*)
# Bare-metal or unknown platform
configure
set system console device ttyS0 speed 115200
set system console device ttyS1 speed 115200
commit
save
;;
esac
echo "Console configured for platform: $HYPERVISOR"Integration with Monitoring Systems
Example of exporting console metrics for Prometheus:
#!/bin/bash
# /config/scripts/console-metrics.sh
# Export console metrics for monitoring
METRICS_FILE="/var/tmp/console_metrics.prom"
# Check for the presence of console devices
console_present=0
if [ -e /dev/ttyS0 ]; then
console_present=1
fi
# Count the messages in the console logs (over the last hour)
console_messages=$(journalctl -u serial-getty@ttyS0.service --since "1 hour ago" | wc -l)
# Write the metrics
cat > "$METRICS_FILE" << EOF
# HELP vyos_console_present Console device presence (1=present, 0=absent)
# TYPE vyos_console_present gauge
vyos_console_present{device="ttyS0"} $console_present
# HELP vyos_console_messages_total Total console messages in last hour
# TYPE vyos_console_messages_total counter
vyos_console_messages_total{device="ttyS0"} $console_messages
EOFReferences
- VyOS Documentation: Console Configuration
- Yandex Cloud: Serial Console
- VK Cloud: Bare-Metal Servers
- Serial Console Best Practices
Conclusion
The serial console is a critically important tool for administering VyOS routers, especially in server and cloud environments. Proper console configuration provides:
- Reliable out-of-band access for emergency recovery
- The ability to diagnose system boot problems
- Convenient access through cloud platforms (Yandex Cloud, VK Cloud)
- A backup management channel during network problems
Follow the recommendations for choosing the data transfer rate, configure redundancy of console devices, and document the configuration to simplify support and troubleshooting.