Enabling Serial Console on MikroTik RouterOS x86
MikroTik RouterOS has piqued my interest lately, but before committing to buying some hardware I’d like to dabble. Fortunately MikroTik offers RouterOS x86, which allows you to install their OS on any x86 box. I have a PCEngines APU3 lying around which is the perfect little device for this. One problem though, the APU3 does not have a VGA out which is what RouterOS expects the user to use to install the OS.
However, there are a couple of ways we can get around this
Obtain Image
You can download RouterOS from MikroTik’s website here: https://mikrotik.com/download/routeros I chose the Long-Term x86 IMG Install Image, not the ISO.
Once it’s downloaded, you’ll need to unzip it, then open the image. This will depend on the OS you’re on — I’ve included instructions for macOS and Linux
macOS
-> hdiutil attach install-image-7.21.5.img
/dev/disk5 /Volumes/NO NAME
-> cd /Volumes/NO\ NAME
-> ls
1.npk 10.npk 12.npk 14.npk 15.npk 17.npk 2.npk 3.npk 4.npk
8.npk 9.npk autorun.scr CHOOSE EFI ldlinux.c32 ldlinux.sys linux syslinux.cfgLinux
-> mkdir /mnt/routeros
-> sudo mount -o loop install-image-7.21.5.img /mnt/routeros
-> cd /mnt/routeros
-> ls
1.npk 10.npk 12.npk 14.npk 15.npk 17.npk 2.npk 3.npk 4.npk
8.npk 9.npk autorun.scr CHOOSE EFI ldlinux.c32 ldlinux.sys linux syslinux.cfgEnable Serial Console
You’ll need to edit two lines to make serial console primary while also allowing VGA to continue working
syslinux.cfg
LABEL system
KERNEL linux
- APPEND load_ramdisk=1 -install -hdd
+ APPEND load_ramdisk=1 -install -hdd console=tty0 console=ttyS0,115200n8 earlyprintk=ttyS0,115200
EFI/BOOT/refind.conf
menuentry "Install RouterOS" {
loader /linux
- options "load_ramdisk=1 root=/dev/ram0 -install -hdd"
+ options "load_ramdisk=1 root=/dev/ram0 -install -hdd console=tty0 console=ttyS0,115200n8 earlyprintk=ttyS0,115200"
}
Prepare Bootable USB
Once you’ve modified the files above, you can unmount/eject the disk. Then you’ll need to write it to a USB flash drive
sudo dd if=install-image-7.21.5.img of=/dev/disk7 bs=1M status=progressBoot Installer
Once dd finishes in the previous step, you can take the flash drive and plug it into your device and boot from that USB. You should land on a screen like below
Booting from Hard Disk...
SYSLINUX 6.02 EDD 2013-10-13 Copyright (C) 1994-2013 H. Peter Anvin et al
Loading linux... o
Looking for harddrives......
Welcome to MikroTik Router Software installation
Select 'Output Disk' using arrow keys. Press ENTER to confirm.
[X] I189971632(119 GB) [ ] 4C530001251015101233(29 GB)*
Welcome to MikroTik Router Software hard disk installation 7.21.5
Press Ctrl-Alt-Delete to abort
Welcome to MikroTik Router Software installation
Move around menu using 'p' and 'n' or arrow keys, select with 'spacebar'.
Select all with 'a', minimum with 'm'. Press 'i' to install locally or 'q' to
cancel and reboot.
[X] system [ ] gps [ ] tr069-client
[ ] calea [ ] iot [ ] ups
[X] container [ ] openflow [X] wireless
[X] dude [ ] rose-storage
dude (depends on system):
network monitoring and management
Reading: system-7.21.5....
Reading: wireless-7.21.5...
Reading: dude-7.21.5...
Reading: container-7.21.5...
Creating partitions...+(122070 MB)...
Formatting 'RouterOS' 100%ng 'RouterOS'
Formatting 'RouterOS Boot' 100%
readMBR: could not open /dev/mtdblock2: 2
open /dev/panics failed
Software installed.
Rebooting...You can continue through the installer, then reboot when it’s complete.
Connecting via WinBox
The installer does not enable serial on the installation on your disk — you will be unable to see anything on serial after it boots the disk. Fortunately, using MikroTik’s WinBox, you can still gain access to the device. You can then use this access to enable serial permanently.
Open a terminal by clicking “New Terminal” on the left navigation. You can run the commands below to check the status of the console, set its speed, and enable it.
[admin@MikroTik] > /system/console print
Flags: * - DEFAULT; X - DISABLED, F - FREE
Columns: PORT, VCNO, TERM
# PORT VCNO TERM
0 *X serial0 vt102
1 *F 1 linux
2 *F 2 linux
3 *F 3 linux
4 *F 4 linux
5 *F 5 linux
6 *F 6 linux
7 *F 7 linux
8 *F 8 linux
[admin@MikroTik] > port set serial0 baud-rate=115200 data-bits=8 parity=none stop-bits=1
[admin@MikroTik] > /system/console enable 0
[admin@MikroTik] > /system/console print
Flags: * - DEFAULT; F - FREE
Columns: PORT, VCNO, TERM
# PORT VCNO TERM
0 *F serial0 vt102
1 *F 1 linux
2 *F 2 linux
3 *F 3 linux
4 *F 4 linux
5 *F 5 linux
6 *F 6 linux
7 *F 7 linux
8 *F 8 linuxIf you enable it, serial should start working right away. You may need to hit enter 1 or 2 times to get it to show up.
Alternative Method
If you don’t want to go through the hassle of modifying files, you can simply write the image to a USB drive, insert it into your device, then plug in a USB keyboard. When you boot it, it will go through the install process seen above — you’ll just need to do it blind and hit the necessary keys on your keyboard
For simplicity, you can just hit the following
Enter(to select the first drive)ito install just system
If it finishes installing, it will reboot automatically. You can pick up from the WinBox step to connect to it and set up the serial console permanently.