bc-bd.org

Not a blog

Immediate Shutdown After Boot

Is your linux configured to shut down on power button press and immediately shuts down after the next boot?

Use acpi_listen to check if you are getting two events for each button press:

button/power PBTN 00000080 00000000
button/power LNXPWRBN:00 00000080 0000001c

Hack around it by passing the event information to your script /etc/acpi/events/powerbtn:

...
action=/etc/acpi/powerbtn.sh %e

And reacting only on one /etc/acpi/powerbtn.sh:

...
[ "$2" == "PBTN" ] || exit 0

Bash, Glob and Case

Is Bash matching lower- and uppercase files seemingly not caring about shopt -u nocaseglob, e.g.:

$ touch foo FOO
$ echo [a-z]*
foo FOO

then set LC_COLLATE to C, see man bash / Pattern Matching / LC_COLLATE:

The sorting order of characters in range expressions is determined by the current locale and the values of the LC_COLLATE or LC_ALL shell variables, if set. To obtain the traditional interpretation of range expressions, where [a-d] is equivalent to [abcd], set value of the LC_ALL shell variable to C, or […]

Apt-secure and Stretch

Has your own repository stopped working for stretch with something like this:

W: GPG error ... Release: The following signatures were invalid: ...
W: The repository ... Release' is not signed.

Check that your Release.gpg files contain sha256 signatures (Hint: --cert-digest-algo,), not sha1.

Ccache and Cowbuilder

Install ccache on your host, and setup cache folder to 1GiB maximum size:

sudo apt-get install ccache
sudo mkdir /var/cache/ccache
sudo CCACHE_DIR=/var/cache/ccache ccache -M 1G

Prepare hook to install ccache and fixup permissions:

# cat /tmp/ccache/D01ccache
#!/bin/bash

apt-get install ccache

chown -R pbuilder /var/cache/ccache

Prepare config file

# cat /tmp/ccache/env
export CCACHE_DIR=/var/cache/ccache
export PATH=/usr/lib/ccache:$PATH

Build a source package

sudo cowbuilder --build dtach_0.8-2.1.dsc --basepath
/tmp/jessie.amd64.cow --hookdir /tmp/ccache --buildplace /tmp
--bindmounts /var/cache/ccache --configfile /tmp/ccache/env

The --bindmounts option will provide the host’s ccache to cowbuilder, --hookdir installs ccache inside and --configfile actually enables ccache.

Use CCACHE_DIR=/var/cache/ccache ccache -s to checkout cache usage, e.g.

cache directory                     /var/cache/ccache
primary config                      /var/cache/ccache/ccache.conf
secondary config      (readonly)    /etc/ccache.conf
cache hit (direct)                  3492
cache hit (preprocessed)             227
cache miss                          2483
cache hit rate                     59.96 %
called for link                      466
called for preprocessing             114
compile failed                        23
preprocessor error                    36
bad compiler arguments                 6
autoconf compile/link                 85
no input file                         73
cleanups performed                     0
files in cache                      4835
cache size                         567.8 MB
max cache size                       1.0 GB

Kvm, Trim and the Discard Operation Is Not Supported

Getting the discard operation is not supported when running fstrim on a kvm guest? Make sure to

  • use virtio-scsi
  • pass discard='unmap' to the disk driver
  • use a machine type >= 2.1, e.g. pc-i440fx-2.3

Stretch Without Systemd

Following http://without-systemd.org/wiki/index.php/Debian_Stretch and adding a pin on *systemd* will lead to libvirt-daemon-system being uninstalled though (dependency chain: libvirt-daemon-system -> polkit -> libpam-systemd).

It is possible to build rebuild polkit without systemd, see https://github.com/bidaian/no-systemd, but that means tracking another package diversion.

An alternative solution is to just not use systemd as init, put keep the other packages installed:

apt-get install sysvinit-core sysvinit-utils
apt-get remove --purge systemd-sysv

Windows 7 Qlx BSOD

A recent Windows 7 installation started crashing with a Bluescreen of Death after installing the qlx driver inside the guest. Switching back to the vga model allowed me to boot it again:

<video>
  <model type='vga' vram='16384' heads='1' primary='yes'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>