Contents
Voir aussi ConsoleSérieMaintenance.
Connecter au serveur de console
Required
- SSH Client
- Access Credentials
Connecting
Connect to the console switch using your username, password and port number
Using your SSH client, connect to the desired serial console and port.
ssh user@cs2.koumbit.net -p 3101
Enter your password.
user@cs2.koumbit.net's password:
Assuming your password is correct, you will be re-directed and automatically connected to the port specified earlier.
Hewlett-Packard HPSCS16 S/W Version 1.9 Connected to Port: 2 115200,8,N,1,NONE 61 bytes available in history buffer Debian GNU/Linux 5.0 shell.koumbit.net tty1 shell.koumbit.net login:
You may have to send some input to trigger a response from the console.
You may not be able to use vi properly... If the screen is garbled, try to reset your TERM variable, like this:
export TERM=screen
Disconnecting
Disconnecting from your session
When you wish to disconnect, you may either close your SSH client (the serial console will eventually figure out the hanging terminal and end the session) or press Control+D, then enter quit at the > prompt.
shell.koumbit.net login: <Control+D> Entering Command Mode > quit Session Terminated
For additional information, refer to ConsoleSérieService/hp-scs-users-guide.pdf
Hard resets
Sending the Skinny Elephants signals can be done by sending a break signal to the serial console. On the HP serial console devices, you can send a break signal with ctrl-D followed by port break followed by resume. Do these in rapid succession so you can send the control character quickly thereafter. You might prefer to write all your commands into a text file and then copy/paste to the ssh session.
Here is an example of serial console output sending h after the magic sysrq (to get a help listing):
monkey login: Entering Command Mode > port break > resume Connected to Port: 1 115200,8,N,1,NONE 63310 bytes available in history buffer [ 1268.051544] SysRq : HELP : loglevel(0-9) reBoot Crash terminate-all-tasks(E) memory-full-oom-kill(F) kill-all-tasks(I) thaw-filesystems(J) saK show-backtrace-all-active-cpus(L) show-memory-usage(M) nice-all-RT-tasks(N) powerOff show-registers(P) show-all-timers(Q) unRaw Sync show-task-states(T) Unmount show-blocked-tasks(W) dump-ftrace-buffer(Z) Debian GNU/Linux 6.0 monkey ttyS0 monkey login:
See HardReset for the details of the specific signals you can send.
How to configure your server to be accessible through the a serial console
Linux servers
There is an excellent howto about remote serial consoles, however it covers more stuff than what we actually need. The breakdown is actually quite simple. there are three different parts (ignoring the BIOS here): the console (the login prompt you usually see when you boot your OS), the kernel (linux here) and the boot loader (grub).
Debian Jessie is using systemd to manage services, it also changes how to enable the serial console!
There is a bug in the jessie installer, when the install is done from the serial console, the parameter to enable stoutput to serial console is not activated... Debian bug 769406
Operating system with systemd
If the serial port connected is ttyS0, you can run the following commands, but make sure that the kernel has already been configure to output to the serial console.
# systemctl enable serial-getty@ttyS0.service # systemctl start serial-getty@ttyS0.service
To get the status on the port:
# systemctl status serial-getty@ttyS0.service
We can specified the speed of the port in this file
/etc/systemd/system/getty.target.wants/serial-getty\@ttyS0.service
Console with systemd gives out garbage with proprietary console server
This is because the proprietary console servers don't like terminal type vt102, which is set by default by systemd and require type vt100.
In order to change that you need to create a "drop-in". In this example the terminal port that's used is ttyS1, you should adapt to the device that's right for your setup.
First create a directory:
mkdir /etc/systemd/system/serial-getty@ttyS1.service.d
then create file /etc/systemd/system/serial-getty@ttyS1.service.d/force-term-type.conf set its contents to the following:
# Redefine service call to force terminal speed. [Service] Environment=TERM=vt100
Finally to make that effective, run systemctl daemon-reload. Then when running systemctl status serial-getty@ttyS1.service the output should tell you that there is an effective drop-in at the path where you just created the file. Restart the service and the console should be showing getty's output correctly.
Operating system without systemd
Configure the console tty
This configures a login terminal to popup on the serial console port.
Add this line (or uncomment) in /etc/inittab:
T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100
Then use the traditionnal kill -1 1 to tell init to reload inittab.
Vérifier avec la commande :
# ps -ax | grep getty
Here you should already have your login console on the serial console, this allows you to quickly test without rebooting
Configure the kernel
Then you configure the kernel to also show up on the serial console. The argument to pass the kernel is console=tty0 console=ttyS0,115200n8, for the console to appear both on the serial console and regular VGA console. This is differently done in Grub 1 and 2.
In grub 1
In /boot/grub/menu.list, you need to add console=tty0 console=ttyS0,115200n8 on the kernel line:
kernel /vmlinuz-2.4.9-21 ro root=/dev/hda6 console=tty0 console=ttyS0,115200n8
For this to survive Debian kernel upgrades, you also need to add those to the kopt line in /boot/grub/menu.list:
# kopt=root=/dev/mapper/ceres-root ro console=tty0 console=ttyS0,115200n8
Then run update-grub to apply the new parameters to the current kernel installed in the grub menu.lst
In grub 2
Make sure those lines are present in /etc/default/grub:
On the servers that the console works on ttyS0, like vandales, there is:
# next line for single user mode (recovery) GRUB_CMDLINE_LINUX="console=ttyS0,115200n8" # for normal boot GRUB_CMDLINE_LINUX_DEFAULT="console=hvc0 console=tty0 earlyprintk=xen" # for normal boot GRUB_CMDLINE_XEN_DEFAULT="dom0_mem=1024M,max:1024M com1=115200,8n1 console=com1,vga"
Then rerun update-grub2.
Configure the bootloader
To configure grub to show up on the serial console, add this on top of /boot/grub/menu.list:
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 terminal --timeout=10 serial console
Grub 2
# Uncomment to disable graphical terminal (grub-pc only) GRUB_TERMINAL="serial console" GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
Les options pour GRUB_TERMINAL
serial pour avoir le menu de grub sur le port serie
console pour avoir le menu de grub AUSSI sur l'écran
Si c'est le COM2 qu'on utilise, changez pour --unit=1:
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=1 --word=8 --parity=no --stop=1"
Configure the BIOS
Configuring the BIOS and other operating systems is not covered here yet.
Ensuite, certains serveurs offrent la possibilité d'envoyer le output du bios vers le port série, c'est a vérifier cas par cas dans le bios de chaque machine.
FreeBSD
As documented in the advanced guide, we can easily configure FreeBSD to boot from the serial console, which will just show up in the terminal in qemu, very handy.
Enable serial console in /etc/ttys by editing the ttyu0 entry. The ttyu0 line should appear like the following;
ttyu0 "/usr/libexec/getty std.115200" vt100 on secure
Be sure to disable the other tty's listed by changing the value on to off otherwise you'll see errors when booting.
Edit /boot/loader.conf (It may be empty) and add the following;
boot_multicons="YES" boot_serial="YES" comconsole_speed="115200" console="comconsole,vidconsole"
add the following line to /boot.config:
-D -S115200
memtest86
To run memtest86+ on the serial console, you need to add this parameter: console=ttyS0,115200n8, for example, in grub:
menuentry "Memory test (memtest86+, serial console 115200)" { linux16 /boot/memtest86+.bin console=ttyS0,115200n8 }
How to access a console using the USB port
In Linux command line:
screen /dev/ttyUSB0 115200
To exit and kill the screen:
<CTRL+a> <k>
Having two screen sessions connected to the same serial console device creates weird conflits that break screen feedback and keyboard interactivity. In order to avoid those issues you can use the following command, which will create a screen session only if there's none, otherwise you'll be reconnected to the current screen session:
devnum=2; if fuser -s /dev/ttyUSB$devnum; then screen -x; else screen /dev/ttyUSB$devnum 115200; fi
Add a user to cereal
How to get the PTY of a xen serial console // general thoughts on cereal
Its possible to find where the hell in the cluster the pts/X is. I think this is the first step to get some bridging between cereal and ganeti.
inst=marky.office.koumbit.net; gnt-cluster command -n `gnt-instance list --separator ',' | grep $inst | cut -d ',' -f 4` 'xenstore-ls /local/domain/`xm domid '$inst'`/console'
The magic could be happening anywhere ; we'd need a script running on reboot that would create the different mappings between all the cereal stuff and the actual serial console, and one that checks that the serials are at the right place once an hour.
However cereal doesn't do the magic between ssh and the PTYs. We'd need some mysql database of the mappings between server+pts and instance and instance ID, and we'd need to have a bootup scripts for user that would check the "$SSH_CONNECTION" environment variable so we can check if they have access to the specified port and we'd give access to ssh:22000-22999 for serial console to users.