Tool tip: “vbetool” runs real-mode video BIOS code to alter hardware state

This is so damn useful to turn on and off remote displays through SSH, for wall-mounted information screens and similar.

Available in your friendly neighbourhood Linux distribution.

VBETOOL(1) User Commands VBETOOL(1)

NAME
  vbetool - run real-mode video BIOS code to alter hardware state

SYNOPSIS
  vbetool [[vbestate save|restore]|[vbemode set|get]|[vgamode]|[dpms on|off|standby|suspend|reduced]|[post [romfile]]|[vgastate on|off]|[vbefp pan‐
  elid|panelsize|getbrightness|setbrightness|invert]]

DESCRIPTION
  vbetool uses lrmi in order to run code from the video BIOS. Currently, it is able to alter DPMS states, save/restore video card state and attempt
  to initialize the video card from scratch.

OPTIONS
  vbetool takes the following options:

  vbestate
    vbetool will use the VESA 0x4f0f extensions to save or restore hardware state. This will be sent to or read from stdin. This information is
    highly hardware specific - do not attempt to restore state saved from a different machine. This command will not work unless you are at a
    text console, as it interferes badly with X.
 
  dpms
    vbetool will use the VESA 0x4f10 extensions to alter the power management state of your screen. "On", "off", "standby", "suspend" and
    "reduced" are acceptable further options and determine which state will be activated.
 
  vbemode
    vbetool will get or set the current VESA mode. "get" will return the current mode number on stdout - "set" will set the mode to the next
    argument.
 
  vgamode
    vbetool will set the legacy VGA mode to the following numeric argument.
 
  post
    vbetool will attempt to run BIOS code located at c000:0003. This is the code run by the system BIOS at boot in order to intialise the video
    hardware. Note that on some machines (especially laptops), not all of this code is present after system boot - as a result, executing this
    command may result in undefined behaviour. This command must be run from a text console, as it will otherwise interfere with the operation
    of X. This command takes an optional argument which is the location of a file containing a ROM image. If provided, this image will be mapped
    to the c000 segment and used instead of the system's video BIOS.
 
  vgastate
    vbetool will enable or disable the current video card. On most hardware, disabling will cause the hardware to stop responding until it is
    reenabled. You probably don't want to do this if you're using a framebuffer.
 
  vbefp
    vbetool will execute a VESA flat panel interface call.
      panelid will provide information about the panel
      panelsize will provide the size of the panel
      getbrightness will provide the current screen brightness as an integer
      setbrightness accepts an integer as an argument and will set the screen brightness to that
      invert will invert the colours of the screen
 
BUGS
  Switching dpms modes may interact badly with X on some systems.
 
  The vbestate command may behave in strange ways.
 
  The post command may result in the execution of arbitrary code that happens to be lying around in the area where chunks of your video BIOS used to
  be.
 
  The VESA specification does not require that "vbemode get" provides the correct mode if the current mode was set via some means other than the VESA
  BIOS extensions.
 
  The VESA flat panel interface ceased development at the proposal stage. panelid and panelsize will work on many machines, but the other arguments
  are unlikely to be implemented on available hardware.
 
AUTHOR
  vbetool was written by Matthew Garrett <mjg59@srcf.ucam.org>, based on code from read-edid by John Fremlin <john@fremlin.de>, LRMI (http://source‐
  forge.net/projects/lrmi/) and XFree (http://www.xfree86.org). It is released under the terms of the GNU General Public License.

vbetool 0.2 31 December 2004 VBETOOL(1)

Solution: Using ProxyPass from http to https in apache2 causes AH02032 SNI error

I got this error message on the internal.server.host when forwarding an URL from an extrernal HTTP server to an internal HTTPS server:

AH02032: Hostname internal.server.host provided via SNI and hostname external.server.host provided via HTTP are different

The problem turned out to be that the internal server was trusting the external one’s X-Forwarded- headers, a feature which was crucial to other parts of the setup and couldn’t be disabled. The solution was to disable sending of X-Forwarded- for this particular proxy URL by disabling ProxyAddHeaders.

The “fixed” config, as follows:

SSLProxyEngine on
SSLProxyCheckPeerCN on
SSLProxyCheckPeerExpire on
ProxyPass /nice/page.php https://internal.server.host/nice/page.php min=1 max=5 retry=10
ProxyPassReverse /nice/page.php https://internal.server.host/nice/page.php
ProxyAddHeaders off
ProxyPreserveHost off

Hope this helps someone 🙂

The fastest way to extend disk image files on Linux

So the VM is using too much space, and the disk image needs to grow. Previously I used dd with a bunch of options to do this. However, the truncate tool makes the whole ordeal a lot easier.

A simple command, such as the following, will grow the file disk.img by 10 gigabytes:

truncate -s +10G disk.img

Read the manual for truncate for more options.

Happy resizing.

Aeon Cobra 50cc (GOES 50s) service manuals and parts lists

Something completely unrelated to this blog thing, but I feel I have to put it somewhere. I recently did some mechanical work on an Aeon Cobra 50cc (AT70 in the registration) and spent a few evenings looking up information about it.

The Aeon Cobra 50cc is sold in several Nordic countries as the GOES 50s.

I no longer have access to said vehicle, but in case anyone else needs it, here are my findings.

Parts lists, relevant to stores like LandQuad in France, who do worldwide shipping at a reasonable price:

Service manuals for the AT70 and related vehicles:

Have fun getting your hands dirty 🙂

Using MERGE to insert/update in SQL Server

After finding various useless references on how to use the MERGE statement in SQL Server 2008, I found this one that I could use, so I copied it here for personal reference:

MERGE tablename AS target
USING (VALUES ('new value', 'different value'))
    AS source (field1, field2)
    ON target.idfield = 7
WHEN MATCHED THEN
    UPDATE SET
    field1 = source.field1,
    field2 = source.field2,
    ...
WHEN NOT MATCHED THEN
    INSERT ( idfield, field1, field2, ... )
    VALUES ( 7,  source.field1, source.field2, ... )

How to use a gateway outside of the local subnet on Linux

An interesting situation occurs when you have a very limited range of public IP addresses and want to pass all traffic through a common gateway without “wasting” a public IP on that – you may find yourself wanting to use a gateway with a private IP even through your network uses public ones.

So, in my case I was dealing with a /29 subnet, providing space for only 6 hosts, all of which were needed to host various services. The gateway, as a result of this, could not occupy one of the precious IP’s. The solution was to put the gateway on a static, but local, IP address, and create a route to it in /etc/network/interfaces.

iface eth0 inet static
    address 1.2.3.4
    netmask 255.255.255.248
    up   route add -host 172.30.0.1 dev eth0
    up   route add -net 0.0.0.0 netmask 0.0.0.0 gw 172.30.0.1 dev eth0
    down route del -net 0.0.0.0 netmask 0.0.0.0 gw 172.30.0.1 dev eth0
    down route del -host 172.30.0.1 dev eth0

While 1.2.3.4 has obviously been replaced for privacy reasons, this is pretty much the setup. The gateway is at 172.30.0.1, a private IP. Each time the interface is brought up or down, a default route to the gateway is automatically added and removed as appropriate.

MSSQL Mass Delete

To avoid holding up everything else when deleting massive amounts of data from an SQL Server table, you can use the TOP() function to delete the data in chunks.

SELECT 1
WHILE @@ROWCOUNT > 0
BEGIN
DELETE TOP(1000) FROM [dbo].[mytable]
WHERE timestampUtc < '2015-05-29'
END

The “SELECT 1” primes the @@ROWCOUNT variable, so the while loop will run. Yes, there are indeed prettier ways of doing this, but it doesn’t really matter.

dovecot: master: Error: systemd listens on port 143, but it’s not configured in Dovecot. Closing.

Upgrading a mail server from Debian Wheezy (7) to Debian Jessie (8), the following errors were observed in the mail.error log:

dovecot: master: Error: systemd listens on port 143, but it’s not configured in Dovecot. Closing.
dovecot: master: Error: systemd listens on port 993, but it’s not configured in Dovecot. Closing

Looking for solutions, I found two pages talking about it:
https://sowhatisthesolution.wordpress.com/2015/04/27/upgrading-dovecot-debian-wheezy-to-jessie/ (local archive)
http://appbead.com/blog/fix-errors-reported-in-syslog-for-debian-8-jessie.html (local archive)

Seeing as this install of dovecot wasn’t supposed to be started by socket connections, but rather run all the time, and that it wasn’t actually listening to POP3 and IMAP, but rather their SSL equivalents, we simply disabled the dovecot.socket config, as suggested by the first of the two links:

# systemctl disable dovecot.socket
Removed symlink to /etc/systemd/system/sockets.target.wants/dovecot.socket.

Installing Windows Live Essentials on Windows XP – Error: OnCatalogResult: 0x80190194

wlsetup-all-en_GB

wlsetup-all-en_USSupport for Windows XP from Microsoft has long since ended, and although Windows Update still kind of works (you have to run the “Express” option a few times, and install Microsoft Update, before “Custom” works), attempts to install Windows Live Essentials fail miserably with the cryptic error message “OnCatalogResult: 0x80190194”.

wlsetup

Downloading the installer manually was suggested on a few sites, however, downloading and running wlsetup-web.exe from Microsoft gave me the same error message on install. Cue the offline installer. However, the previous links to download the offline installer, such as http://g.live.com/1rewlive3/en/wlsetup-all.exe, are now dead. The Internet Archive came to the rescue, and I was able to download it from there.

I’ve archived my copy of it here, for future reference. Feel free to grab it, or use the archive.

UPDATE:
Someone asked be about the version for Windows Vista. I personally haven’t tried these, as I don’t run Windows Vista anywhere, but the latest version of Windows Essentials, 16.4.3528.0331, is available here:
English (United States) ==> (local archive)
English (United Kingdom) ==> (local archive)