Saturday, August 5, 2017

Building debian packages for Raspberry PI on Jenkins in Ubuntu


  • Set up Jenkins on Ubuntu
  • Set up jenkins debian glue
  • Install raspbian-archive-keyring.deb
  • Make sure debian-archive-keyring is not installed
  • Make a copy of /etc/pbuilder as /etc/pbuilder.raspi and add
    • DEBOOTSTRAP=--keyring=/usr/share/keyrings/raspbian-archive-keyring.gpg
  • Either create a new job for raspbian-binaries or configuration for existing job
  • Configure variables as
    • architecture=armhf
    • distribution=jessie
    • COMPONENTS="main contrib non-free"
    • COWBUILDER_BASE=/var/cache/pbuilder/base-raspbian-jessie-armhf.cow
    • PBUILDER_CONFIG=/etc/pbuildderrc.raspi
    • ARCHITECTURES="amd64 i386 armhf source"
    • REPOSITORY=/srv/repository-raspi

Saturday, July 15, 2017

nbd fails with "Negotiation: Error: Server closed connection"

While experimenting with nbd (network block device) on Linux, I ran into connection failures, where both my server and client died:

** Message: virtstyle ipliteral
** Message: connect from 127.0.0.1, assigned file is /home/user/fs/image
** Message: Authorized client
** Message: Starting to serve
** Message: Size of exported file/device is 33554432
Negotiation: Error: Server closed connection
Exiting.
Error: Read failed: Connection reset by peer

Exiting.

Turned out, this was due to me starting the server using the command line options specifying the file to serve.
./nbd-server localhost:10809 /home/user/fs/image 

Apparently this simply does not work.

Solution was to create the server config file and leave out the server command line options completely.

[export]
        exportname = /home/user/fs/image
authfile = /etc/nbd-server/allow

 

Then run the client with the name specified in the config.

sudo ./nbd-client -name export 127.0.0.1 10809 /dev/nbd1

I could have saved some time debugging this if I just had read the this bug report thoroughly enough:

Saturday, December 10, 2016

debugging systemd service in Raspbian 8 through core dumps


Taking notes on what I did to enable core dumps from a service running under systemd. Not sure which of these were strictly necessary, though.

Added to /etc/security/limits.conf
* soft core unlimited
* hard core unlimited

Added to /etc/sysctl.d/core.conf
kernel.core_pattern = core-%e-sig%s-user%u-group%g-pid%p-time%t
kernel.core_uses_pid = 1

fs.suid_dumpable = 2

Added to /lib/systemd/system/my-service.service [Service] -section
LimitCORE=infinity

created world-writable dump directory
sudo mkdir -p /var/lib/coredumps
sudo chown nobody:nogroup /var/lib/coredumps
sudo chmod a+w /var/lib/coredumps/

Verified that limits are ok
grep core /proc/$(pgrep damon-process-name-here)/limits

Verified that core gets dumped
sudo kill -SIGABRT $(pgrep damon-process-name-here)
gdb /bin/my-daemon /var/lib/coredumps/core*

Tuesday, December 6, 2016

HP network printing in Ubuntu fails with m_Job initialization failed with error = 48

Note to self: next time my HP network printer fails to work properly in Linux, use hpsetup -i to install the printer. Don't rely on the easy looking graphical user interface to install the printer.

D [06/Dec/2016:22:20:54 +0200] [Job 5] Processing page 1...
D [06/Dec/2016:22:20:54 +0200] [Job 5] Set job-printer-state-message to "Processing page 1...", current level=INFO
D [06/Dec/2016:22:20:54 +0200] [Job 5] prnt/hpcups/Hbpl1.cpp 52: Hbpl1 constructor : m_szLanguage = HBPL1STATE: +hplip.plugin-error
D [06/Dec/2016:22:20:54 +0200] [Job 5] prnt/hpcups/HPCupsFilter.cpp 486: m_Job initialization failed with error = 48
D [06/Dec/2016:22:20:54 +0200] [Job 5] PID 3860 (/usr/lib/cups/filter/hpcups) stopped with status 1.
D [06/Dec/2016:22:20:54 +0200] [Job 5] Hint: Try setting the LogLevel to "debug" to find out more.
D [06/Dec/2016:22:20:54 +0200] [Job 5] prnt/backend/hp.c 919: ERROR: null print job total=0

Monday, March 14, 2016

Macports Octave build hangs on El Capitan

While trying to install Octave from Macports on El Capitan, the build hangs during atlas compilation. Existing bug reports don't really provide a solution.

Luckily, Octave wiki provides a solution in 4.3.1 Simple Installation Instructions

  sudo port install atlas +gcc5
  sudo port install arpack -acclerate +atlas
  sudo port install octave


Wednesday, February 10, 2016

Personal streaming music server

Idea

I would like to have a private Spotify / Google Music / Apple music like setup. For free. As I already have bought the music once in the past.

Music files would be stored at home, but accessible anywhere. This way I could listen to all my favourite songs on the go. And do this with low end smartphones which have limited storage capacity but flat fee 3G/4G network access.

Server

Hardware

Raspberry PI to start with.

Software

  • Both the server and the mobile application keep on crashing
  • Depends on Tondo servers to be available. I can only hope their freemium business model is sustainable forever.
  • Implemented in Java
    • Needs to be configured for low ram from defaults
#MADSONIC_INIT_MEMORY=192
#MADSONIC_MAX_MEMORY=384
MADSONIC_INIT_MEMORY=32
MADSONIC_MAX_MEMORY=128

    • You need patience to start it up on a Raspi model B 
  • Auto start for now
    /etc/rc.local:
    su -c /var/madsonic/standalone/madsonic.sh pi

    Mobile application

    TBD

    General host/network setup

    • Public IP - attach to a VLAN outside the firewall
    • Dynamic DNS from changeip.com
    • Set up DNS update in /lib/dhcpcd/dhcpcd-hooks/60-changeip.com
    #!/bin/sh
    case "$reason" in
    BOUND|RENEW|REBIND|REBOOT)
    curl -u user:pass 'http://nic.ChangeIP.com/nic/update?cmd=update&hostname=hostname.xyz.com'
    ;;
    esac

    • Set up usbmount to automatically mount USB sticks

     sudo aptitude install usbmount

    • Set up NAT from a privileged port to an user process
    /etc/rc.local: 
    iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 4040 


    Saturday, December 5, 2015

    make-bcache: Device or resource busy

    When setting up bcache, I ended up being halfway there. Bcache could not be set up, because it's not a blank block device.

    sudo make-bcache -C /dev/sda3 -B /dev/sdb1 --wipe-bcacheDevice /dev/sda3 already has a non-bcache superblock, remove it using wipefs and wipefs -a

    Wiping up the partition would not work as bcache is already using it for something

    sudo wipefs -a /dev/sda3
    wipefs: error: /dev/sda3: probing initialization failed: Device or resource busy

    Also detaching the device from bcache won't work, since the bcache0 is not really there yet.

    echo eb99feda-fac7-43dc-b89d-18765e9febb6 > /sys/block/bcache0/bcache/detach
    cd /sys/block/bcache0 bash: cd: /sys/block/bcache0: No such file or directory
    Seems the solution was to stop the bcache instead:

    cd /sys/fs/bcache/eb99feda-fac7-43dc-b89d-18765e9febb6
    sudo sh -c "echo 1 > stop"