Proxmox enable SOL access to ASRock Rack

I had some trouble enable the SOL (Serial-Over-LAN) access to my ASRock Rack motherboard. Here’s how I finally managed to get it working.

First start off by configuring “Serial Console Redirection” in the BIOS with the following settings (credit to pvalkone at GitHub):

/----------------------------------------------------+-------------------------\
|  SOL                                               |Emulation: ANSI:         |
|  Console Redirection Settings                      |Extended ASCII char      |
|                                                    |set. VT100: ASCII char   |
|  Terminal Type           [VT100]                   |set. VT100+: Extends     |
|  Bits per second         [115200]                  |VT100 to support color,  |
|  Data Bits               [8]                       |function keys, etc.      |
|  Parity                  [None]                    |VT-UTF8: Uses UTF8       |
|  Stop Bits               [1]                       |encoding to map Unicode  |
|  Flow Control            [None]                    |chars onto 1 or more     |
|  VT-UTF8 Combo Key Sup   [Enabled]                 |-------------------------|
|  Recorder Mode           [Disabled]                |<>: Select Screen        |
|  Resolution 100x31       [Disabled]                |^v: Select Item          |
|  Legacy OS Redirection   [80x24]                   |Enter: Select            |
|  Putty KeyPad            [VT100]                   |+/-: Change Option       |
|  Redirection After BIO   [Always Enable]           |F1: General Help         |
|                                                    |F7: Discard Changes      |
|                                                    |F9: Load UEFI Defaults   |
|                                                    |F10: Save and Exit       |
|                                                    |ESC: Exit                |
\----------------------------------------------------+-------------------------/

From your client (where you have installed ipmitools ):

➞ ipmitool -I lanplus -H <bmc-mgmt-ip> -U admin -e \& sol info 1
Password: 
Set in progress                 : set-complete
Enabled                         : true
Force Encryption                : false
Force Authentication            : false
Privilege Level                 : USER
Character Accumulate Level (ms) : 60
Character Send Threshold        : 96
Retry Count                     : 7
Retry Interval (ms)             : 500
Volatile Bit Rate (kbps)        : 115.2
Non-Volatile Bit Rate (kbps)    : 115.2
Payload Channel                 : 1 (0x01)
Payload Port                    : 623

Make sure that Volatile Bit Rate (kbps) and Non-Volatile Bit Rate (kbps) is set to 115.2 (115200).

Restart the server and login. Edit /etc/default/grub and change GRUB_CMDLINE_LINUX_DEFAULT, GRUB_TERMINAL and GRUB_SERIAL_COMMAND:

GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS1,115200n8 console=tty0"
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --speed 115200 --unit=1 --word=8 --parity=no --stop=1"

After saving the file, do not forget to run update-grub.

Then we need to tell systemd to start serial ttyS1 on boot.

Optional, it can be worth changing the default serial-getty@.service to only accept 115200 as baud-rate, as according to Roger Irvin. Do this by coping the default service to /etc/systemd/system/.

cp /lib/systemd/system/serial-getty@.service /etc/systemd/system/

Then change the ExecStart line from:

ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,38400,9600 %I $TERM

To:

ExecStart=-/sbin/agetty -o '-p -- \\u' 115200 %I $TERM'

Save the file, reload systemd daemon, start and enable ttyS1:

systemctl daemon-reload
systemctl start serial-getty@ttyS1
systemctl enable serial-getty@ttyS1

Reboot the server, and use ipmitool to get a SOL session:

ipmitool -I lanplus -H <bmc-mgmt-ip> -U admin -e \& sol activate

To exit the session type &. (no enter!) and the session is terminated.

Packet history in Ubuntu

Trying to figure out what packages has been changed since a specific date. A quick hack.

package_history() {
    local since="${1}"
    local action="${2:-install}"
    action=${action,,}
    action=${action^}

    [[ -z "${since}" ]] && { echo "Need a valid date as first argument"; exit -1; }

    sed -n '/^Start-Date: '"${since}"' /,$p' /var/log/apt/history.log | awk '/Start-Date:/ || /'"${action}"':/' | sed -r 's|\),|\)\n|g; s|('"${action}"': )|\1\n |'
}

Examples, if you want to know all packages installed since 2016-05-17:
package_history "2016-05-17"

If you want to know all packages removed since 2016-05-09:
package_history "2016-05-17" remove

Building the Darwin Streaming Server in Ubuntu

Me and a colleague tried building the Darwin Streaming server on Ubuntu Server 13.10 with the help of this guide [instructables.com].

It did not go as well as we were hoping due to build errors. After some troubleshooting (all credit goes to my colleague), it turned out that the linking of libraries was not done recursively. So even though the correct libraries was included in LDFLAGS it wouldn’t work.

With the following two changes, we got rid of the build errors:

$ cd lstoll*
$ find . -name "Makefile.*" -exec sed -i 's/-lQTFileExternalLib/-lQTFileExternalLib -lpthread/' {} \;
$ sed -i 's/-lQTFileLib/-lQTFileLib -ldl/' Makefile.POSIX

Automagically build load modules when updating the kernel

I bought a new wireless network card to my parents, and it turned out that there wasn’t support in the generic Ubuntu kernel for it. The last month they haven’t been able to use their computer since the card stopped working after updating the kernel, and hence missing the custom built load module.

After rebuilding the load module I was following the output when installing about 200 updates and saw that after updating the kernel there were some scripts from /etc/kernel/postinst.d running.

I then realized that it should be possible to solve the problem by adding a custom script that would rebuild the load module when updating the kernel.

Step 1 was to create a script in both /etc/kernel/postinst.d and /etc/kernel/header_postinst.d that I named build_wifi_driver:

#!/bin/bash
# We're passed the version of the kernel being installed
inst_kern=$1

cd /root/DPO_RT3070_LinuxSTA_V2.3.0.4_20100604/
make KERNEL_VERSION=$inst_kern
make KERNEL_VERSION=$inst_kern install

The second problem was that the Makefiles for the load module had to be updated to use $(KERNEL_VERSION) instead of $(shell uname -r). I had to update three different Makefiles:

DPO_RT3070_LinuxSTA_V2.3.0.4_20100604/Makefile:

--- DPO_RT3070_LinuxSTA_V2.3.0.4_20100604/Makefile    2009-12-28 13:38:34.000000000 +0100
+++ DPO_RT3070_LinuxSTA_V2.3.0.4_20100604.new/Makefile    2011-01-05 19:17:14.000000000 +0100
@@ -117,11 +117,14 @@
endif

ifeq ($(PLATFORM),PC)
+ifndef KERNEL_VERSION
+    KERNEL_VERSION := $(shell uname -r)
+endif
# Linux 2.6
-LINUX_SRC = /lib/modules/$(shell uname -r)/build
+LINUX_SRC = /lib/modules/$(KERNEL_VERSION)/build
# Linux 2.4 Change to your local setting
#LINUX_SRC = /usr/src/linux-2.4
-LINUX_SRC_MODULE = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless/
+LINUX_SRC_MODULE = /lib/modules/$(KERNEL_VERSION)/kernel/drivers/net/wireless/
CROSS_COMPILE =
endif

@@ -234,7 +237,7 @@
endif

cp -f os/linux/Makefile.4 $(RT28xx_DIR)/os/linux/Makefile
-    $(MAKE) -C $(RT28xx_DIR)/os/linux/
+    $(MAKE) KERNEL_VERSION=$(KERNEL_VERSION)-C $(RT28xx_DIR)/os/linux/

ifeq ($(OSABL),YES)
cp -f os/linux/Makefile.4.netif $(RT28xx_DIR)/os/linux/Makefile
@@ -279,7 +282,7 @@
ifeq ($(PLATFORM),FREESCALE8377)
$(MAKE) ARCH=powerpc CROSS_COMPILE=$(CROSS_COMPILE) -C  $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
else
-    $(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
+    $(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux KERNEL_VERSION=$(KERNEL_VERSION) modules
endif
endif

DPO_RT3070_LinuxSTA_V2.3.0.4_20100604/os/linux/Makefile.4

--- DPO_RT3070_LinuxSTA_V2.3.0.4_20100604/os/linux/Makefile.4    2009-12-30 02:12:06.000000000 +0100
+++ DPO_RT3070_LinuxSTA_V2.3.0.4_20100604.new/os/linux/Makefile.4    2011-01-05 19:01:56.000000000 +0100
@@ -13,6 +13,9 @@

OBJ := $(MOD_NAME).o

+ifndef KERNEL_VERSION
+KERNEL_VERSION := $(shell uname -r)
+endif

#ifdef CONFIG_STA_SUPPORT
RT28XX_STA_OBJ := \
@@ -200,9 +203,9 @@
cp $(RT28xx_DIR)/$(DAT_FILE_NAME) $(DAT_PATH)/.
install -d $(LINUX_SRC_MODULE)
install -m 644 -c $(addsuffix .o,$(MOD_NAME)) $(LINUX_SRC_MODULE)
-    /sbin/depmod -a ${shell uname -r}
+    /sbin/depmod -a $(KERNEL_VERSION)

uninstall:
#    rm -rf $(DAT_PATH)
rm -rf $(addprefix $(LINUX_SRC_MODULE),$(addsuffix .o,$(MOD_NAME)))
-    /sbin/depmod -a ${shell uname -r}
+    /sbin/depmod -a $(KERNEL_VERSION)

DPO_RT3070_LinuxSTA_V2.3.0.4_20100604/os/linux/Makefile.6

--- DPO_RT3070_LinuxSTA_V2.3.0.4_20100604/os/linux/Makefile.6    2009-12-30 02:12:13.000000000 +0100
+++ DPO_RT3070_LinuxSTA_V2.3.0.4_20100604.new/os/linux/Makefile.6    2011-01-05 19:02:29.000000000 +0100
@@ -12,6 +12,10 @@

obj-m := $(MOD_NAME).o

+ifndef KERNEL_VERSION
+KERNEL_VERSION := $(shell uname -r)
+endif
+

#ifdef CONFIG_STA_SUPPORT
rt$(CHIPSET)sta-objs := \
@@ -198,9 +202,9 @@
cp $(RT28xx_DIR)/$(DAT_FILE_NAME) $(DAT_PATH)/.
install -d $(LINUX_SRC_MODULE)
install -m 644 -c $(addsuffix .ko,$(MOD_NAME)) $(LINUX_SRC_MODULE)
-    /sbin/depmod -a ${shell uname -r}
+    /sbin/depmod -a $(KERNEL_VERSION)

uninstall:
#    rm -rf $(DAT_PATH)
rm -rf $(addprefix $(LINUX_SRC_MODULE),$(addsuffix .ko,$(MOD_NAME)))
-    /sbin/depmod -a ${shell uname -r}
+    /sbin/depmod -a $(KERNEL_VERSION)

I’m no expert when it comes to Makefiles, but these changes solved the issue and the load module now builds automagically every time the kernel was updated.