Author Archives: colinmac

WordPress Migration Complete

I’ve just migrated the blog from the Raspberry Pi to a VM hosted on my linux server. Migration went smoothly enough through the use of Duplicator and Search & Replace. Mails work as do all the usual plugins.

Don’t think there are any broken links adn I haven’t spotted anything obviously wrong, but let me know if you spot something that looks like it isn’t working.

Proper lock screen behaviour on OS X

I’ve been working with a MacBook for some time now, but had a constant irritation that there didn’t seem to be a way to lock the screen out of the box. Many point to ‘Sleep’ as an option, but that takes down all my SSH sessions. Likewise having a passworded screen saver is not great simply because for it to be effective e.g. when I step away, then the timer needs to be short, which is very annoying when you are working on something without moving the keyboard or mouse.

Thankfully I now found the solution, which is surprisingly well hidden. In the Keychain Access preferences, we have an interesting box we can tick:

Keychain Access PreferencesTick the box ‘Show keychain status in the menu bar’. This now gives us a handy little menu with the option ‘Lock screen’.

OS X - Lock ScreenSo there you have it, the laptop is locked but the network sessions stay up. Windows + L would be even better, but you can’t have everything.

Vodafone Ireland – SIP Ports Blocked

Was working at the parents place for a few days and was appalled to find that, on what is sold as a home broadband connection (LTE-based), they have the SIP ports blocked.

Skype worked just fine, as always, but my work phone was unable to register with the VoIP server. Tunnel everything through the corp VPN (we use split tunnels by default – a much better option) and all worked as expected.

Just need to modify the routing so that traffic to the SIP server also uses the VPN. Minor annoyance, but still, WHY?!

Storage Hardware Upgrade – Moving to a HBA

For a number of reasons, after some other upgrades, I decided to move to a HBA rather then continuing to use the 2 x Syba 4 Port SATA II PCI-Express x1 Software RAID Card that I’ve been using for some time now. They are relatively simple and cheap devices, and easy to use as they are directly supported by the linux kernel (based on the Sil3124 chipset). Since the HDDs are all in a ZFS array anyway, these cards are basically just adding SATA ports to the motherboard.

After doing some research into the different options, I decided on the LSI Internal SAS SATA 9211-8i 6Gbps 8 Ports HBA PCI-E RAID Controller Card as the most appropriate option in combination with 2 x miniSAS SFF-8087 MINI SAS TO 4 SATA Data Cable For SAS RAID Card LSI 9211-8i.

Hardware

  • Motherboard:  MSI H97 PC MATE – Socket 1150 – ATX
  • Processor: Intel i5 4460 Quad Core Processor (3.2GHz, 6MB Cache)
  • HBA: LSI Internal SAS SATA 9211-8i 6Gbps 8 Ports HBA PCI-E RAID Controller Card
  • Cables: miniSAS SFF-8087 MINI SAS TO 4 SATA Data Cable For SAS RAID Card LSI 9211-8i
  • HDDs: 8 x 2TB HDD. Mix of WD Green, Seagate, and a Toshiba

Firmware Upgrade

First step was to upgrade the firmware on the LSI card to IT mode, rather then the default IR. Basically, I want the card to just present a bunch of connected disks to Linux, and let ZFS manage everything, rather then using it as a raid controller.

The firmware upgrade was quite straightforward, with the only tricky part actually getting the MSI motherboard to give me EFI shell access. In the end I found a setting in the BIOS, under Advanced, marked Windows 8/8i Feature. This has to be set to ‘Enabled’. Apparently UEFI is only enabled when this is turned on.

With the motherboard behaving itself I could flash the card. There are lots of guides on how to do this out there, but as a quick summary, you need a small FAT32 formatted USB stick with 4 files on it.

From LSI download the latest firmware package (P20 for me) – 9211-8i_Package_P20_IR_IT_Firmware_BIOS_for_MSDOS_Windows. It doesn’t matter what OS you are using, this is bundle that you need.

From that there are two files you want:

  • 2118it.bin – located in Firmware/HBA_9211_8i_IT
  • mptsas2.rom – located in sasbios_rel

Also grab the Installer_P20_for_UEFI file from LSI – this has the:

  • sas2flash.efi located in sas2flash_efi_ebc_rel

And the 4th file you need (assuming your motherboard doesn’t have it) is the EFI Shell itself. This is also available here.

Put the 4 files onto the USB stick, and reboot. You should now get booted to the EFI shell. Assuming there is only a single LSI card present, the following commands will flash the firmware:

# Mount the usb drive
mount blk14:

# Switch to that drive
blk14

# Check that you can find your 4 files
dir

# Erase the existing firmware on the card. Note - do not reboot/lose power at this step or you have a dead card
sas2flash.efi -o -e 6

# Load the new firmware and BIOS - takes about 4 mins
sas2flash.efi -o -f 2118it.bin -b mptsas2.rom

# Check the firmware product ID in the output of the following command to verify that it is in IT mode
sas2flash.efi -list

Exit the UEFI shell and reboot. Our LSI card and all the HDDs are detected by both the LSI card itself (SAS Topology) and Linux.

9211-8i BIOS TopologyTo speed up the boot process you should disable the boot support in the cards BIOS (as long as your boot drive isn’t plugged into the HBA) as this will speed up the boot process.

 

Playing TVHeadend Streams in VLC

Just a quick note on the URLs for doing this (File -> Open Network…);

Channel playlist:

http://<TV Headend IP>:9981/playlist/channels
http://<username>:<password>@<TV Headend IP>:9981/playlist/channels

Channel Number:

http://<TV Headend IP>:9981/stream/channelid/<channel number>
http://<username>:<password>@<TV Headend IP>:9981/stream/channelid/<channel number>

Handling bad RAM in Linux

After some recent hardware upgrades, I was getting some strange crashes (different to the freeze that accompanies the intermittently-failing HDD that I’m trying to hunt down), specifically referring to Bad swap offsets and Bad page maps.

Given that I fired up memtest86+ and let it do it’s thing… and  it turns out that I have a few chunks of dodgy RAM. RMA time – though be sure to try swapping the RAM around and make sure the problem follows the stick and not the slot.!

Memtest86But to keep everything up and running in the meantime I decided to use memmap to block off that chunk of memory while linux is booting. To do this modify /etc/default/grub:

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2&amp;gt; /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet memmap=1440M\\\$2048M"
GRUB_CMDLINE_LINUX=""

Basically what we are doing here is telling linux to block off 1440M of RAM, starting at 2048M. Then run sudo update-grub, reload and you will see your ‘free -m’ memory drop to about 6.5G.

This should tide you over, and prevent some random crashes until replacement RAM arrives

Taking from /home to grow the root partition

After a recent move from Wheezy to Jessie, the root partition was looking a little full – to the point where the GUI wasn’t working due to a lack of /tmp space. So needed to take care of that while troubleshooting other issues.

# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/dm-0              9.1G  8.4G  176M  99% /
udev                    10M     0   10M   0% /dev
tmpfs                  402M  6.5M  396M   2% /run
tmpfs                 1005M   68K 1005M   1% /dev/shm
tmpfs                  5.0M  4.0K  5.0M   1% /run/lock
tmpfs                 1005M     0 1005M   0% /sys/fs/cgroup
/dev/mapper/thor-home  904G  511G  347G  60% /home
/dev/sde1              228M   47M  170M  22% /boot
tmpfs                  201M     0  201M   0% /run/user/1024
tmpfs                  201M  8.0K  201M   1% /run/user/1000

Given that there is plenty of room on the /home partition and it’s all built on LVM, reallocating space from one to the other is fairly straightforward.

While you can grow an EXT4 filesystem while it is mounted, you can’t shrink one – and given that /home is constantly in use it was easier just to reboot into maintenance mode and take care of things that way.

# Unmount the home partition
umount /mnt/home
# Check the filesystem to make sure it is clean
e2fsck -F /dev/mapper/thor-home

# Shrink the filesystem to the desired size - in this case I'm reducing it to 880G
resize2fs -p /dev/mapper/thor-home 880G

# Shrink the logical volume to match
lvreduce -L 880G /dev/mapper/thor-home

# Check the file system again. If there are problems because the partition is too small, we
# can still recover by using lvextend until it succeeds e.g. lvextend -L +1G /dev/mapper/thor-home
e2fsck -F /dev/mapper/thor-home

That was the dangerous part. Extending the root filesystem to use the newly freed space is quite simple, but this time we are first growing the logical volume, then expanding the filesystem

# Extend the logical volume to use all the free space
lvextend -l +100%FREE /dev/mapper/thor-root
# Expand the filesystem
resize2fs -p /dev/mapper/thor-root

At this point a scan of the filesystem is a good idea, but unfortunately we can’t do that to a mounted filesystem, so instead we can trigger the check on reboot

touch /forcefsck

But in the meantime we can see that the root partition now has plenty of space

# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/dm-0               47G  8.8G   36G  20% /
udev                    10M     0   10M   0% /dev
tmpfs                  402M  6.5M  396M   2% /run
tmpfs                 1005M   68K 1005M   1% /dev/shm
tmpfs                  5.0M  4.0K  5.0M   1% /run/lock
tmpfs                 1005M     0 1005M   0% /sys/fs/cgroup
/dev/mapper/thor-home  867G  506G  317G  62% /home
/dev/sdb1              228M   47M  170M  22% /boot
tmpfs                  201M     0  201M   0% /run/user/1024
tmpfs                  201M  4.0K  201M   1% /run/user/1000

Realtek RTL2832U on Linux (Debian)

So, now that I’d dipped my toe in the water with the RTL2832U on Win10, I actually planned on permanently integrating it into my media setup with is based on a RPI3 running OpenElec and a Debian server providing backend storage.

This turned out to be one of those good news bad news situations. The good news is that the dongle has kernel support, the bad news was that Wheezy was still on 3.2 which was lacking this support. After a failed attempt to compile the driver, followed by a failed attempt to compile the kernel (stupid linux-headers not found!) I just went ahead and upgraded the box to Jessie (Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-1 (2016-03-06) x86_64 GNU/Linux).

A long update, upgrade, dist-upgrade later and the dongle was in and recognised

[    1.196017] usb 8-1: Manufacturer: Realtek
[   19.650428] usb 8-1: dvb_usb_v2: found a 'Realtek RTL2832U reference design' in warm state
[   19.717623] usb 8-1: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer
[   19.717658] DVB: registering new adapter (Realtek RTL2832U reference design)
[   19.721246] usb 8-1: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))...
[   20.007861] i2c i2c-9: rtl2832_sdr: Realtek RTL2832 SDR attached
[   20.015340] input: Realtek RTL2832U reference design as /devices/pci0000:00/0000:00:1d.7/usb8/8-1/rc/rc0/input6
[   20.015348] rc0: Realtek RTL2832U reference design as /devices/pci0000:00/0000:00:1d.7/usb8/8-1/rc/rc0
[   20.104268] input: MCE IR Keyboard/Mouse (dvb_usb_rtl28xxu) as /devices/virtual/input/input7
[   20.104356] usb 8-1: dvb_usb_v2: schedule remote query interval to 400 msecs
[   20.117509] usb 8-1: dvb_usb_v2: 'Realtek RTL2832U reference design' successfully initialized and connected
[   20.117602] usbcore: registered new interface driver dvb_usb_rtl28xxu
[   20.160507] rc rc0: lirc_dev: driver ir-lirc-codec (dvb_usb_rtl28xxu) registered at minor = 0

Next step…

Installing tvheadend

My original plan was to just have the dongle running directly connected to the RPI but power was a concern (no powered hub) and since my linux server is always running anyway, why not install the backend software there and have the tvheadend client running on the RPI/OpenELEC side of things?

Installation isn’t actually that straightforward but can be broken down into a few steps

  1. Install the package
    This involves adding the tvheadend repository to your sources list and you will add a user account/password as part of the install process

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
    echo "deb https://dl.bintray.com/tvheadend/deb <strong>jessie stable</strong>" | sudo tee -a /etc/apt/sources.list
    sudo apt-get update
    sudo apt-get install tvheadend
  2. Configure via the web interface at <IP Address>:9981
    1. Check that your dongle shows up under Configuration -> DVB Inputs -> TV Adapters
    2. Under Configuration -> DVB Inputs -> Networks, add a DVB-T network (for Ireland) and select from the list of Pre-defined MUXs (Ireland-WoodcockHill for me)
      create-dvbT-network
    3. Back under Configuration -> DVB Inputs -> Networks, map the newly created network to the dongle
      hardware-network-mapping-DVB-T
    4. Under Muxes, the scan status for the added muxes will start at ‘Idle’ then eventually start scanning and find your channels
    5. You should see the Services start to be listed as they are discovered, and at this point under Configuration -> Channel, you can map the service to a channel
      channel-config-DVB-T
    6. Last step on the backend side is to enable the EPG. I have both the OTA grabber and the Radio Times for UK/Ireland enabled and we are doneEPG-grabber-DVB-T
      EPG-DVB-T

On the OpenELEC frontend, much simpler.

Install the add-on from under PVR, configure it with the hostname, username, and password, and under Settings -> TV, Enable live TV. Sorted!

Realtek RTL2832U TV USB Dongle and Windows 10

I recently got RTL2832U+R820T USB2.0 Digital DVB-T SDR+DAB+FM HDTV TV Tuner Receiver Stick from eBay. For about €6 it was worth a punt.

Had an interesting problem with windows 10 and the drivers though. Microsoft insist on installing an out-of-date driver (version 64.0001.0220.2009) which looks like it is working, but when scanning for DVB channels, it finds nothing.

The correct version should be 64.1.801.2012 and this is what is provided on the included CD. The problem is that Windows 10, in its wisdom decides to ‘update’ to the older driver as soon as it can.

The current (nasty) workaround is to;

  1. Uninstall the device and delete the driver (Device Manager)
  2. Block device driver updates (System -> System Properties -> Hardware -> Device Installation Settings
  3. Set ‘Never install driver software from Windows Update
  4. Install the driver from the CD
  5. Insert the dongle and scan

All channels were found and working perfectly (FM, and DAB also appeared as devices now).

ZFS One Year On – First Repair

Having moved to ZFS after my little RAID/XFS problem last year, with weekly scrubs of the array, I’ve just had my first read error and repair. From the system log;

[1691578.161114] ata7.00: exception Emask 0x0 SAct 0x3 SErr 0x0 action 0x0
[1691578.161121] ata7.00: irq_stat 0x40000008
[1691578.161128] ata7.00: failed command: READ FPDMA QUEUED
[1691578.161138] ata7.00: cmd 60/b0:00:d8:c8:1b/00:00:66:00:00/40 tag 0 ncq 90112 in
[1691578.161140]          res 41/40:b0:e0:c8:1b/00:00:66:00:00/00 Emask 0x409 (media error) <F>
[1691578.161146] ata7.00: status: { DRDY ERR }
[1691578.161150] ata7.00: error: { UNC }
[1691578.162924] ata7.00: configured for UDMA/133
[1691578.162945] sd 6:0:0:0: [sdf] Unhandled sense code
[1691578.162949] sd 6:0:0:0: [sdf]  Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[1691578.162955] sd 6:0:0:0: [sdf]  Sense Key : Medium Error [current] [descriptor]
[1691578.162963] Descriptor sense data with sense descriptors (in hex):
[1691578.162967]         72 03 11 04 00 00 00 0c 00 0a 80 00 00 00 00 00
[1691578.162982]         66 1b c8 e0
[1691578.162989] sd 6:0:0:0: [sdf]  Add. Sense: Unrecovered read error - auto reallocate failed
[1691578.162998] sd 6:0:0:0: [sdf] CDB: Read(10): 28 00 66 1b c8 d8 00 00 b0 00
[1691578.163013] end_request: I/O error, dev sdf, sector 1713096928
[1691578.163040] ata7: EH complete

And looking at ZFS;

sudo zpool status
[sudo] password for :
pool: storage
state: ONLINE
scan: scrub repaired 88K in 11h7m with 0 errors on Sun May  1 12:37:48 2016
config:

NAME        STATE     READ WRITE CKSUM
storage     ONLINE       0     0     0
raidz1-0  ONLINE       0     0     0
sdf     ONLINE       0     0     0
sdc     ONLINE       0     0     0
sdh     ONLINE       0     0     0
sdj     ONLINE       0     0     0
raidz1-1  ONLINE       0     0     0
sdb     ONLINE       0     0     0
sdd     ONLINE       0     0     0
sdi     ONLINE       0     0     0
sdk     ONLINE       0     0     0

errors: No known data errors

Kind of wondering how much life that drive has left – should I replace now??