Force Filesystem Repair in Raspbian

Raspberry Pi

Raspberry Pi systems use microSD cards and therefore are more error prone than typical servers with hard disks or SSD. Such corruptions are especially tricky when the only storage available to Raspberry Pi is the microSD card which booted Raspbian OS.

How To Force Filesystem Check

Best thing is to update the /boot/cmdline.txt file to force filesystem repair on the next boot.

Change the file from this:

greys@becky:~ $ cat /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait plymouth.enable=0

to this:

greys@becky:~ $ cat /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes fsck.mode=force rootwait plymouth.enable=0

And then just reboot:

greys@becky:~ $ sudo shutdown -r now

See Also




Removed DHCP Daemons in Raspbian

Raspberry Pi 4

I got one of my Raspberry Pi servers attempting to obtain DHCP IP address, a behavior that ignored my static IP address configuration.

Not sure why, but it appeared I’d be getting an extra DHCP address, from the same network segment, in addition to the static IP the Raspberry Pi already had.

Normally I’d just disable the service, but since my home office network is fairly static, I figured I would just remove the DHCP package.

WARNING: do not follow my steps unless you’re in the same situation and pretty sure you’re using static IP addressing.

Double Check that You’re Using Static IP

Check your /etc/network/interfaces file, it should have something similar for your primary interface – in wired network cable case it’s eth0:

auto eth0
iface eth0 inet static
    address 192.168.1.99
    netmask 255.255.255.0
    gateway 192.168.1.1

Also, run ip a and make sure you’re seeing this same IP among the active interfaces:

greys@s7:~ $ ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:ee:66:88:ff brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.99/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever

Remove ISC DHCP Client

So I did this:

root@srv:~# apt-get remove isc-dhcp-client
 Reading package lists… Done
 Building dependency tree
 Reading state information… Done
 The following packages were automatically installed and are no longer required:
   libdns-export1104 libisc-export1100
 Use 'apt autoremove' to remove them.
 The following additional packages will be installed:
   dhcpcd5
 Suggested packages:
   dhcpcd-gtk
 The following packages will be REMOVED:
   isc-dhcp-client
 The following NEW packages will be installed:
   dhcpcd5
 0 upgraded, 1 newly installed, 1 to remove and 207 not upgraded.

All cool? Not really. If you read carefully, you’ll notice that I removed isc-dhcp-client, but automatically installed dhcpcd5 – which started making DHCP requests again.

Remove DHCPcD5

Next step then! Let’s remove DHCPcD5:

root@srv:~# apt-get remove dhcpcd5
 Reading package lists… Done
 Building dependency tree
 Reading state information… Done
 The following additional packages will be installed:
   isc-dhcp-client
 Suggested packages:
   avahi-autoipd isc-dhcp-client-ddns
 The following packages will be REMOVED:
   dhcpcd5
 The following NEW packages will be installed:
   isc-dhcp-client
 0 upgraded, 1 newly installed, 1 to remove and 207 not upgraded.

Much better!

Or is it? If you look closer, you’ll see that this command installed isc-dhcp-client back.

Delete both DHCP Client Packages

This time I specified both packages to be removed. I even used apt-get purge instead of apt-get remove – to definitely destroy any configs:

root@srv:~# apt-get purge dhcpcd5 isc-dhcp-client
 Reading package lists… Done
 Building dependency tree
 Reading state information… Done
 The following packages were automatically installed and are no longer required:
   libdns-export1104 libisc-export1100
 Use 'apt autoremove' to remove them.
 The following additional packages will be installed:
   pump
 The following packages will be REMOVED:
   dhcpcd5* isc-dhcp-client*
 The following NEW packages will be installed:
   pump
 0 upgraded, 1 newly installed, 2 to remove and 207 not upgraded.

When this installed pump (that’s apparently another BOOTP/DHCP client – I never even heard about it before), I got curious.

Having researched online, it appears one can configure static IP in Raspberry Pi using DHCP client configs. Doesn’t sound right to me! There’s also the systemd way to disable dhcpd.service, but at this stage I was not looking for half measures.

Having carefully considered this, I decided to unstall the whole lot. It also removed wicd* (Wired and Wireless Network Connection Manager) bunch which is another set of packages for managing network interfaces and connections.

I’m honestly suprised and seriously suprised how involved a network interface and IP address configuration is! Since I’m not using any of these niceties and because this is a static server-like environment where I’m not switching Wi-Fi networks or changing connection profiles all the time, I’m comfortable letting it all go.

Uninstalling DHPCP clients, pump and Wicd

WARNING: be super sure you’re using static IP addressing on your Raspberry Pi system before running the next command.

Here’s the final uninstall command:

root@s7:~# apt-get remove dhcpcd5 isc-dhcp-client pump
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package 'isc-dhcp-client' is not installed, so not removed
Package 'pump' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  libdns-export1104 libisc-export1100 openresolv python-wicd
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  dhcpcd5 wicd wicd-daemon wicd-gtk
0 upgraded, 0 newly installed, 4 to remove and 207 not upgraded.

FINALLY! No more DHCP requests from this server 🙂

pS: on a somewhat relevant note, think I’ll upgrade all them 207 packages – but first will complete a reboot to check network configuration still works for the static IP.

See Also




Using grc (Generic Colouriser) for RSyslog

Colorized output for RSyslog files

I started updating my Centralised RSyslog server on Raspberry Pi the other day, and one of the things I’ve been meaning to research was syntax highlighting for RSyslog logs. After a brief search online, I found grc: a great tool for seeing output of many common Unix commands and log files in a completely new, colorful and useful way.

Install grc in Raspbian (Debian/Ubuntu)

I did this in Raspbian OS:

$ sudo apt-get install grc

It brought quote a few dependencies with it, but installed fairly quickly.

grc for looking at RSyslog output

Simply run grc and tail the messages file or RSyslog file. It will look like this:

RSyslog output with grc colouriser

Looking and process listing with ps and grc

Many common commands are used, but I’ll show just the ps command highlighting for now:

ps output with colorized syntax

That’s it for today. I think this is a must-have command line tool – am really impressed!

See Also




Upgrading Raspbian from Jessie to Stretch

raspberry-pi-logo

I noticed that it’s been a while since I upgraded my Raspberry Pi systems. I have updated Raspberry Pi firmware on all of them recently enough, but now decided to upgrade distro. Since Raspbian OS is based on Debian released, it meant I would have to upgrade Raspbian from Jessie base to Stretch.

Step 1: Update/upgrade existing distribution

This simply means we want to upgrade all existing packages before we’ll be moving to the next releast.

Refresh package info:

greys@s7:~ $ sudo apt-get update

Upgrade all the Raspbian OS packages

greys@s7:~ $ sudo apt-get upgrade
...
greys@s7:~ $ sudo apt dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... The following packages were automatically installed and are no longer required:
libcwiid1 libjs-prettify libllvm3.7 libqscintilla2-11 libqscintilla2-l10n libqt4-network libqt4-xmlpatterns libqtwebkit4 libruby1.9.1
libruby1.9.1-dbg libtcl8.5 libtcltk-ruby1.9.1 libtk8.5 pix-icons pix-plym-splash pixel-wallpaper ri1.9.1 ruby1.9.1 ruby1.9.1-dev
ruby1.9.1-examples ruby1.9.1-full ruby1.9.3 supercollider supercollider-common supercollider-ide supercollider-language supercollider-supernova
tcl8.5 tk8.5
Use 'apt-get autoremove' to remove them.
Done
The following NEW packages will be installed:
bc coinor-libipopt1 colord colord-data cups cups-browsed cups-core-drivers cups-daemon cups-filters cups-filters-core-drivers cups-ppdc
cups-server-common ghostscript libcolorhug2 libcupscgi1 libcupsmime1 libcupsppdc1 libfile-copy-recursive-perl libfontembed1 libgmime-2.6-0 libgs9
libgs9-common libgusb2 libgutenprint2 libieee1284-3 libijs-0.35 libinput-bin libinput10 libjbig2dec0 libllvm3.9 libmumps-seq-4.10.0 liboauth0
libopenjp2-7 libpam-chksshpwd libpaper-utils libpaper1 libqpdf13 libqt5concurrent5 libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5
libqt5opengl5 libqt5printsupport5 libqt5svg5 libqt5widgets5 libraw10 libsane libsane-common libsane-extras libsane-extras-common libwacom-bin
libwacom-common libwacom2 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xkb1 libxkbcommon-x11-0
printer-driver-gutenprint python-cffi python-cryptography python-ply python-pycparser python3-cffi python3-cryptography python3-ply
python3-pycparser qpdf qttranslations5-l10n rpd-icons rpd-plym-splash rpd-wallpaper sane-utils ssl-cert update-inetd wolframscript
xserver-xorg-input-libinput
The following packages will be upgraded:
alacarte apt apt-utils bash bind9-host binutils bluez-firmware ca-certificates chromium-browser cpp-4.9 cron cups-bsd cups-client cups-common curl
dbus dbus-x11 debconf debconf-i18n debconf-utils e2fslibs e2fsprogs file firmware-atheros firmware-brcm80211 firmware-libertas firmware-ralink
firmware-realtek fuse g++-4.9 gcc-4.9 gcc-4.9-base gir1.2-gdkpixbuf-2.0 git git-core git-man gnupg gnupg-agent gnupg2 gpgv gpicview
gstreamer0.10-alsa gstreamer0.10-plugins-base gstreamer1.0-alsa gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good
gstreamer1.0-x gtk2-engines-pixbuf idle-python2.7 idle-python3.4 initramfs-tools isc-dhcp-client isc-dhcp-common libapt-inst1.5 libapt-pkg4.12
libarchive13 libasan1 libasound2 libasound2-data libatomic1 libaudiofile1 libavcodec56 libavformat56 libavresample2 libavutil54 libbind9-90
libblas-common libblas3 libbluray1 libc-ares2 libc-bin libc-dev-bin libc6 libc6-dbg libc6-dev libcaca0 libcairo-gobject2 libcairo2 libcomerr2
libcups2 libcupsfilters1 libcupsimage2 libcurl3 libcurl3-gnutls libdb5.3 libdbus-1-3 libdns-export100 libdns100 libdrm-amdgpu1 libdrm-freedreno1
libdrm-nouveau2 libdrm-radeon1 libdrm2 libdvdnav4 libegl1-mesa libelf1 libevent-2.0-5 libexpat1 libexpat1-dev libfaad2 libfcgi-perl libffi6
libfm-data libfm-extra4 libfm-gtk-data libfm-gtk4 libfm-modules libfm4 libfuse2 libgbm1 libgcc-4.9-dev libgcc1 libgcrypt20 libgd3
libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgfortran3 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgles1-mesa libgles2-mesa libgme0
libgnutls-deb0-28 libgnutls-openssl27 libgomp1 libgraphite2-3 libgssapi-krb5-2 libgstreamer-plugins-bad1.0-0 libgstreamer-plugins-base0.10-0
libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libgudev-1.0-0 libhogweed2 libicu52 libidn11
libio-socket-ssl-perl libirs-export91 libisc-export95 libisc95 libisccc90 libisccfg-export90 libisccfg90 libjasper1 libjpeg62-turbo libjs-jquery
libk5crypto3 libkrb5-3 libkrb5support0 liblapack3 liblcms2-2 libldap-2.4-2 libldb1 liblwres90 libmad0 libmagic1 libmp3lame0 libmpg123-0
libmwaw-0.3-3 libmysqlclient18 libncurses5 libncursesw5 libnettle4 libnss3 libobrender29 libobt2 libopencv-calib3d2.4 libopencv-contrib2.4
libopencv-core2.4 libopencv-features2d2.4 libopencv-flann2.4 libopencv-highgui2.4 libopencv-imgproc2.4 libopencv-legacy2.4 libopencv-ml2.4
libopencv-objdetect2.4 libopencv-video2.4 libpam-modules libpam-modules-bin libpam-runtime libpam-systemd libpam0g libpng12-0 libpng12-dev
libpolkit-agent-1-0 libpolkit-backend-1-0 libpolkit-gobject-1-0 libpoppler46 libprocps3 libpython2.7 libpython2.7-minimal libpython2.7-stdlib
libpython3.4 libpython3.4-dev libpython3.4-minimal libpython3.4-stdlib libraspberrypi-bin libraspberrypi-dev libraspberrypi-doc libraspberrypi0
librtmp1 libruby2.1 libsdl-image1.2 libsmbclient libsndfile1 libsoundtouch0 libsoup-gnome2.4-1 libsoup2.4-1 libsqlite3-0 libss2 libssh-4 libssh2-1
libssl-dev libssl-doc libssl1.0.0 libstdc++-4.9-dev libstdc++6 libswscale3 libsystemd0 libtag1-vanilla libtag1c2a libtasn1-6 libtevent0 libtiff5
libtinfo5 libtirpc1 libubsan0 libudev1 libva1 libvorbis0a libvorbisenc2 libvorbisfile3 libwayland-client0 libwayland-cursor0 libwayland-egl1-mesa
libwayland-server0 libwbclient0 libwpd-0.10-10 libx11-6 libx11-data libx11-xcb1 libxcursor1 libxfixes3 libxfont1 libxi6 libxml2 libxpm4 libxrandr2
libxslt1.1 libxtst6 libxv1 locales login lxpanel lxpanel-data man-db multiarch-support mysql-common ncurses-base ncurses-bin ncurses-term nodered
nuscratch openbox openssh-client openssh-server openssh-sftp-server openssl passwd patch pcmanfm perl perl-base perl-modules pi-bluetooth
pi-greeter piclone pigpio pipanel pishutdown pix-icons pix-plym-splash pixel-wallpaper policykit-1 poppler-utils pprompt procps python-gpiozero
python-lxml python-openssl python-picamera python-picraft python-pigpio python-werkzeug python2.7 python2.7-minimal python3-gpiozero
python3-openssl python3-picamera python3-picraft python3-pigpio python3-werkzeug python3.4 python3.4-dev python3.4-minimal raspberrypi-bootloader
raspberrypi-kernel raspberrypi-sys-mods raspberrypi-ui-mods raspi-config raspi-gpio rc-gui realvnc-vnc-server realvnc-vnc-viewer rpcbind
rpi-chromium-mods rsync ruby2.1 samba-common samba-libs sed sensible-utils sonic-pi ssh sudo systemd systemd-sysv tar tzdata udev unzip
va-driver-all wget wireless-regdb wiringpi wolfram-engine wpasupplicant x11-common xarchiver xdg-utils xserver-common xserver-xorg
xserver-xorg-core xserver-xorg-input-all xserver-xorg-input-evdev xserver-xorg-input-synaptics xserver-xorg-video-fbdev xserver-xorg-video-fbturbo
352 upgraded, 80 newly installed, 0 to remove and 0 not upgraded.
Need to get 363 MB/729 MB of archives.
After this operation, 245 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Double-check Upgrade Was Complete

If we re-run the same command, there should be no more updates pending:

greys@s7:~ $ sudo apt dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... The following packages were automatically installed and are no longer required:
libcwiid1 libjs-prettify libllvm3.7 libqscintilla2-11 libqscintilla2-l10n libqt4-network libqt4-xmlpatterns libqtwebkit4 libruby1.9.1
libruby1.9.1-dbg libtcl8.5 libtcltk-ruby1.9.1 libtk8.5 pix-icons pix-plym-splash pixel-wallpaper ri1.9.1 ruby1.9.1 ruby1.9.1-dev
ruby1.9.1-examples ruby1.9.1-full ruby1.9.3 supercollider supercollider-common supercollider-ide supercollider-language supercollider-supernova
tcl8.5 tk8.5
Use 'apt-get autoremove' to remove them.
Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Perfect! Just a few packages to be tidied up with apt-get autoremove.

Tidy Up with apt-get autoremove

greys@s7:~ $ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
libcwiid1 libjs-prettify libllvm3.7 libqscintilla2-11 libqscintilla2-l10n libqt4-network libqt4-xmlpatterns libqtwebkit4 libruby1.9.1
libruby1.9.1-dbg libtcl8.5 libtcltk-ruby1.9.1 libtk8.5 pix-icons pix-plym-splash pixel-wallpaper ri1.9.1 ruby1.9.1 ruby1.9.1-dev
ruby1.9.1-examples ruby1.9.1-full ruby1.9.3 supercollider supercollider-common supercollider-ide supercollider-language supercollider-supernova
tcl8.5 tk8.5
0 upgraded, 0 newly installed, 29 to remove and 0 not upgraded.
After this operation, 129 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 138805 files and directories currently installed.)
Removing supercollider (1:3.6.6~repack-2-1) ...
Removing supercollider-ide (1:3.6.6~repack-2-1) ...
Removing supercollider-language (1:3.6.6~repack-2-1) ...
Removing libcwiid1 (0.6.00+svn201-3.1) ...
Removing supercollider-common (1:3.6.6~repack-2-1) ...
Removing libjs-prettify (2013.03.04+dfsg-4) ...
Removing libllvm3.7:armhf (1:3.7-4~bpo8+1) ...
Removing libqscintilla2-11 (2.8.4+dfsg-1) ...
Removing libqscintilla2-l10n (2.8.4+dfsg-1) ...
Removing libqtwebkit4:armhf (2.3.4.dfsg-3) ...
Removing libqt4-xmlpatterns:armhf (4:4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1+rpi1) ...
Removing libqt4-network:armhf (4:4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1+rpi1) ...
Removing ruby1.9.1-full (1.9.3.484-2) ...
Removing ruby1.9.1-dev (1.9.3.484-2) ...
Removing ruby1.9.3 (1.9.3.484-2) ...
Removing libruby1.9.1-dbg (1.9.3.484-2) ...
Removing libtcltk-ruby1.9.1 (1.9.3.484-2) ...
Removing tk8.5 (8.5.17-1) ...
Removing tcl8.5 (8.5.17-1) ...
Removing libtk8.5:armhf (8.5.17-1) ...
Removing pix-icons (0.8) ...
Removing pix-plym-splash (0.11) ...
Removing pixel-wallpaper (0.4) ...
Removing ri1.9.1 (1.9.3.484-2) ...
Removing ruby1.9.1-examples (1.9.3.484-2) ...
Removing supercollider-supernova (1:3.6.6~repack-2-1) ...
Removing libtcl8.5:armhf (8.5.17-1) ...
Removing ruby1.9.1 (1.9.3.484-2) ...
Removing libruby1.9.1 (1.9.3.484-2) ...
Processing triggers for gnome-menus (3.13.3-6) ...
Processing triggers for desktop-file-utils (0.22-1) ...
Processing triggers for mime-support (3.58) ...
Processing triggers for man-db (2.7.5-1~bpo8+1) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Processing triggers for ruby (1:2.1.5+deb8u2) ...

All clean now!

Step 2: Upgrade Raspbian OS to the next Release

You need to do pretty much the same steps as in previous section, but AFTER you update apt sources links to use the next Raspbian OS release.

As you know, Raspbian OS is based on Debian so it uses Debian’s naming conventions.

Meaning my old release was this:

jessie

… and next one (the one I’m upgrading to) is

stretch

Update apt sources.lst with new release name

So let’s update /etc/apt/sources.list file to reference stretch, which is the Debian release we want:

greys@s7:~ $ sudo vi /etc/apt/sources.list

edit this line:

deb http://raspbian.raspberrypi.org/raspbian/ jessie main contrib non-free rpi

so it looks like this:

deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi

Refresh apt information

greys@s7:~ $ sudo apt-get update

Upgrade all the packages once again

This time they’ll be upgraded to the latest versions available for the next Raspbian OS release:

greys@s7:~ $ sudo apt-get upgrade
...
greys@s7:~ $ sudo apt dist-upgrade

That should be it. Now let’s reboot and Raspberry Pi should come back online sporting a brand new Raspbian OS release:

greys@s7:~ $ sudo shutdown -r now

Took around 1 minute for it to reboot… Then:

greys@s7:~ $ cat /etc/debian_version 
9.9

See Also




Make BIND9 named Use Only IPv4

Screen Shot 2019-05-01 at 17.41.33.pngHaving recently built a centralised log server with RSyslog on one of my Raspberry Pi systems at home office, I’m finally getting to reap the rewards: small and not so small errors get noticed and resolved at last.

Network Unreachable Resolving IPv6 in named

I notice getting lots of named errors like this:

May 1 16:13:04 becky named[545]: network unreachable resolving 'ns-1683.awsdns-18.co.uk/A/IN': 2600
:9000:5301:5200::1#53
May 1 16:13:04 becky named[545]: network unreachable resolving 'ns-1244.awsdns-27.org/A/IN': 2600:9
000:5306:5b00::1#53
May 1 16:13:04 becky named[545]: network unreachable resolving 'ns-1683.awsdns-18.co.uk/AAAA/IN': 2
600:9000:5301:5200::1#53
May 1 16:13:04 becky named[545]: network unreachable resolving 'ns-573.awsdns-07.net/AAAA/IN': 2600
:9000:5301:c800::1#53
May 1 16:13:04 becky named[545]: network unreachable resolving 'ns-1244.awsdns-27.org/AAAA/IN': 260
0:9000:5306:5b00::1#53
May 1 16:13:04 becky named[545]: network unreachable resolving 'ns-573.awsdns-07.net/A/IN': 2600:90
00:5305:4700::1#53
May 1 16:13:04 becky named[545]: network unreachable resolving 'ns-573.awsdns-07.net/AAAA/IN': 2600
:9000:5305:4700::1#53
May 1 16:13:04 becky named[545]: network unreachable resolving 'flickr.com/DS/IN': 2001:503:231d::2
:30#53
May 1 16:13:04 becky named[545]: network unreachable resolving 'yf2.yahoo.com/A/IN': 2406:8600:b8:f
e03::1003#53
May 1 16:13:04 becky named[545]: network unreachable resolving 'yf1.yahoo.com/A/IN': 2406:8600:b8:f
e03::1003#53
May 1 16:13:04 becky named[545]: network unreachable resolving 'yf2.yahoo.com/AAAA/IN': 2406:8600:b
8:fe03::1003#53
May 1 16:13:04 becky named[545]: network unreachable resolving 'yf1.yahoo.com/AAAA/IN': 2406:8600:b
8:fe03::1003#53
May 1 16:13:04 becky named[545]: network unreachable resolving 'yahoodns.net/DS/IN': 2001:503:39c1:
:30#53

Since they all looked like IPv6 addresses, I figured IPv6 would be the explanation. Since I’m not using IPv6 yet, the logical step to resolve issues was to disable IPv6.

Switch BIND9 named to using IPv4 only

By editing the /etc/default/bind9 file, it’s very easy to enfore IPv4 ONLY mode.

Change OPTIONS line from this:

OPTIONS="-u bind"

to this:

OPTIONS="-u bind -4"

Now we just need to restart named daemon. Confusingly enough, it’s done by restarting the  service:

greys@becky:/ $ sudo systemctl restart bind9

let’s quickly confirm bind9 status:

greys@becky:/ $ sudo systemctl status bind9
● bind9.service - BIND Domain Name Server
Loaded: loaded (/lib/systemd/system/bind9.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-05-01 16:33:56 UTC; 3s ago
Docs: man:named(8)
Process: 3062 ExecStop=/usr/sbin/rndc stop (code=exited, status=0/SUCCESS)
Main PID: 3067 (named)
CGroup: /system.slice/bind9.service
└─3067 /usr/sbin/named -f -u bind -4

May 01 16:33:56 becky named[3067]: automatic empty zone: EMPTY.AS112.ARPA
May 01 16:33:56 becky named[3067]: configuring command channel from '/etc/bind/rndc.key'
May 01 16:33:56 becky named[3067]: command channel listening on 127.0.0.1#953
May 01 16:33:56 becky named[3067]: managed-keys-zone: loaded serial 788
May 01 16:33:56 becky named[3067]: zone 0.in-addr.arpa/IN: loaded serial 1
May 01 16:33:56 becky named[3067]: zone 127.in-addr.arpa/IN: loaded serial 1
May 01 16:33:56 becky named[3067]: zone localhost/IN: loaded serial 2
May 01 16:33:56 becky named[3067]: zone 255.in-addr.arpa/IN: loaded serial 1
May 01 16:33:56 becky named[3067]: all zones loaded
May 01 16:33:56 becky named[3067]: running

That’s it! Problem solved – no more IPv6 errors in named logs.

See Also




RSyslog: Separate Log File for Each Host

Screen Shot 2019-03-01 at 13.14.21.png

I’m converting one of my Raspberry Pi systems, becky, into an RSyslog-based log collector, and while there’s not enough knowledge for a complete tutorial yet, I think I’ll start making short notes here in case someone comes looking for them.

Centralised RSyslog: sort logs by host name

One of the most common tasks after you configure your remote servers to ship logs into your new RSyslog collector is to start logging events into separate log files.

Specifically, you may want to have one log per each server, perhaps with the hostname in the filename.

Here’s how you do this. Add the following lines to /etc/rsyslog.conf, taking into account that your logs location may not be the /logs filesystem but some other path:

$template DynaFile,"/logs/%HOSTNAME%.log"
*.* ?DynaFile

… and restart rsyslogd:

root@becky:/logs # systemctl restart rsyslog

That’s it, I can now see that there are separate logs created in /logs for my home office systems: becky, s7 and server are the hostnames.

root@becky:/logs # ls -al
total 284
drwxr-xr-x 4 root root 4096 Mar 1 12:40 .
drwxr-xr-x 26 root root 4096 Feb 28 16:51 ..
-rw-r----- 1 root adm 9554  Mar 1 12:59 becky.log
-rw-r----- 1 root adm 370   Mar 1 12:55 s7.log
-rw-r----- 1 root adm 12786 Mar 1 12:41 server.log

See Also




Raspberry Pi OS

While you probably know that Raspbian is the official OS for Raspberry Pi systems, it’s not the only operating system you can use.

In fact, most of Raspberry Pi beginners start with NOOBSNew Out Of Box Software, which is an installer you can download or buy on an SD/microSD card from most of Raspberry Pi vendors.

In addition to this, there’s now a Raspberry Pi Desktop – special distribution that allows you to try Raspbian OS inside a virtual machine or using live USB environment.

See Also




Command to Confirm Raspberry Pi Model

Because I own a number of Raspberry Pi systems, I get roughly the same question quite regularly about each one of them: how can I confirm what this Raspberry Pi model is from the command line? The reason I usually want to know is because the model of the Raspberry Pi hints the Raspbian release that will support it (older Raspbian releases  do not have support for the most recent models of Raspberry Pi).

There’s a few hardware specs like CPU speed and generation, and also a memory size – they used to be helpful in getting the question above answered.

But turns out there’s an even better way: use the model file in the /proc/device-tree directory, like shown below:

$ cat /proc/device-tree/model
Raspberry Pi 3 Model B Rev 1.2

On another server it returns this:

cat /proc/device-tree/model
Raspberry Pi 2 Model B Rev 1.1

Once you confirm the hardware model, consult the Raspbian page on Wikipedia to see Raspbian versions supporting it.

See Also




How To Determine OS Version on Your Raspberry Pi

Someday you may realise that you had your Raspberry Pi for so long that you no longer remember what OS release it’s running.

Turns out, it’s super easy to double-check:

root@s7:~# cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums" 
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

See Also