This is quite a useful tip: if you have used Win32DiskImager or similar to clone a Raspberry Pi SD card and you want to mount the resulting .img file in Linux, you need to use the ‘offset’ argument to cater for the .img file including multiple partitions.
Details are here, but the summary would be:
Welcome to GNU Parted! Type 'help' to view a list of commands.
Unit? [compact]? B
The output should look something like:
Model: ATA ST3160815AS (scsi)
Disk /dev/sda: 160041885696B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32256B 10733990399B 10733958144B primary ext4
2 10733990400B 21500881919B 10766891520B primary ext3
3 21500881920B 158961761279B 137460879360B primary ext4
4 158961761280B 160039272959B 1077511680B primary linux-swap(v1)
type q to exit from parted.
Now to mount a partition, you have to run something like:
sudo mount -o loop,offset=32256 picked.img mount/point
A useful tip, if ever having to export and renumber DHCP leases on your Windows Server network, check out this link: https://blogs.technet.microsoft.com/teamdhcp/2012/11/20/bulk-load-dhcp-reservations-using-dhcp-powershell/
If you want to add a large list of reservations, an input text file in CSV format can be used to provide the list of reservations to be configured on the DHCP server. This data can be easily pipelined to Add-DhcpServerv4Reservation cmdlet to add the complete list to the DHCP Server. The input text file (Reservations.csv in the command line used later) containing the reservations should be of the following format –
10.10.10.0,10.10.10.10,Computer1,1a-1b-1c-1d-1e-1f,Reserved for Computer1
18.104.22.168,22.214.171.124,Computer2,2a-2b-2c-2d-2e-2f,Reserved for Computer2
126.96.36.199,188.8.131.52,Computer3,3a-3b-3c-3d-3e-3f,Reserved for Computer3
Note that the client id for most clients including Windows computers is the MAC address.
The following command adds all these reservations to the DHCP Server.
Import-Csv Reservations.csv | Add-DhcpServerv4Reservation
When you are using older Raspberry Pi devices and Kodi, sometimes it helps to cache locally the media previews and data.
A great little utility to help with this is TextureCache. Just download it, expand it, edit the .cfg file to make sure the port is right (usually 80), and then use a command like:
./texturecache.py c movies
For a quick start:
In my quest to continually improve my multi-room audio setup, one thing that has bothered me is getting Spotify to play in multiple rooms. My current solution has been to run a Windows VM with the Spotify client, capture the audio using TuneBlade, and then play it out to the various Raspberry Pi’s on the network that are running shairport-sync so they can receive AirPlay signals.
Works pretty well – but means I need to have that Windows VM working all the time. This isn’t a scalable solution to locations where the VM/Windows machine on-all-the-time isn’t an option.
So, I’m now trialling using Mopidy – an extensible music server written in Python. Mopidy will run on a Raspberry Pi, and has an extension that allows it to connect to Spotify…no Windows machine needed!
To get it up and running, I followed the installation instructions, with a few key call-outs as I was getting this running on a Raspberry Pi as the server as well:
- Install raspbian-lite (Jessie) on the Raspberry Pi of choice and get it all set up.
- Follow these instructions – specifically:
wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/jessie.list
sudo apt-get update
sudo apt-get install mopidy
/etc/mopidy/mopidy.conf file looks like:
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy
config_file = /etc/mopidy/logging.conf
debug_file = /var/log/mopidy/mopidy-debug.log
enabled = false #Note: this is just because I wasn't setting up local music at this point
media_dir = /var/lib/mopidy/media
playlists_dir = /var/lib/mopidy/playlists
enabled = true
hostname = ::
enabled = true
username = **** #My Spotify username
password = **** #My Spotify password
enabled = true
hostname = ::
port = 6680
static_dir = ""
zeroconf = Mopidy HTTP server on $hostname
enabled = true
musicbox = false
config_file = /etc/mopidy/mopidy.conf
#output = autoaudiosink
output = audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! wavenc ! filesink location=/tmp/snapfifo
- To get Mopidy working as a service, I used
sudo systemctl enable mopidy but you can use
sudo dpkg-reconfigure mopidy for any Debian-based system.
- Then, I needed to install
pip – but, it needed to be the Python 2.7 version. To install that, I used
apt-get install python-pip2.
pip, I could now install the various add-ins for using and supporting Spotify, namely:
pip2 install Mopidy-Mopify
pip2 install Mopidy-Moped
pip2 install Mopidy-WebSettings
pip2 install Mopidy-Iris
To pipe the audio across the network, I needed to install Snapcast server on the same Raspberry Pi, and then Snapclient on the various clients. So, that looks like:
- Get the latest compiled release for ARM (RPi) with
on the client and then on the server:
- Install, with dependencies:
dpkg -i snapserver_0.11.1_armhf.deb
sudo apt-get -f install
on the server, and then on the client:
dpkg -i snapclient_0.11.1_armhf.deb
sudo apt-get -f install
- The addition to the
mopidy.conf file of the
output section will pipe the audio from
mopidy to any Snapclient that is listening.
snapclient -l will list the USB devices and other sound cards on the client, and then your
/etc/default/snapclient should look something like
# defaults file for snapclient
# start snapclient automatically?
# Allowed options:
# --help produce help message
# -v, --version show version number
# -h, --host arg server hostname or ip address
# -p, --port arg (=1704) server port
# -l, --list list pcm devices
# -s, --soundcard arg (=default) index or name of the soundcard
# -d, --daemon [=arg(=-3)] daemonize, optional process priority [-20..19]
# --user arg the user[:group] to run snapclient as when daemonized
# --latency arg (=0) latency of the soundcard
# -i, --instance arg (=1) instance id
The Tivo service is coming to an end in my part of the world, so I’m trying to create an equally wife/child-friendly option for recording free-to-air, over-the-air TV and playing it back.
I already have Raspberry Pi’s connected to the various TVs in the house, and I know that Kodi has good support for tvheadend, so I figured I’d give that a go.
I bought a Hauppauge dual tuner USB stick as I thought that it is a good brand, with good Linux support, and I was keen to run the whole thing on an old Raspberry Pi (model B+, 1st generation) if I could.
Good idea, but a bit tricky in the end, because while Raspbian (and LibreElec) detected the card just fine, they would only detect one tuner on the card.
The fine people over in the LibreElec forums helped me out with patching the kernel to allow for dual tuner support. To do this, I set up a virtual machine running Ubuntu 16.04 and got it ready to act as a cross-compiler for Raspberry Pi. The instructions to do so are here – just make sure that you remember what kind of Raspberry Pi you are building for!
The summary of steps I took:
- I got the toolchain and copied the right (64-bit) bin path into my
- I then downloaded the 4.9 kernel with
git clone --depth 1 -b rpi-4.9.y https://github.com/raspberrypi/linux
- I then got patch from a user called Puffin Chunks and followed their instructions
- I applied the patch as per instructions (i.e.
patch -p1 < ../hauppage_winTV_dualHD_DVB_PuffinChunks_4.9.y.diff)
- I then followed the rest of the Raspberry Pi instructions for cross-compiling, paying attention to when to use sudo and when not to!
- Because my VM (Hyper-V) won’t do USB pass-through, I put the SD card in a USB card reader and plugged it into another Linux machine on my network. I then mounted it using
On the machine with the USB card plugged in:
mount /dev/sdc1 /mnt/fat32/ -o umask=000
mount /dev/sdc2 /mnt/ext4-2
bindfs -u -g users /mnt/ext4-2/ /mnt/ext4
(That last bindfs was due to the fact that
ext4 partitions don’t mount with read/write permissions properly.)Then, on the cross-compiling machine:
sudo sshfs @:/mnt/ext4 mnt/ext4
sudo sshfs @:/mnt/fat32 mnt/fat32
This was all in the
linux/ folder that I was working within.)
- After doing this, the modules install line worked fine:
sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install
- Then, making sure that I had put
KERNEL=kernel, I copied the kernel across:
sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.imgI actually called the kernel a new name and then added
sudo cp arch/arm/boot/zImage mnt/fat32/$KERNEL.img
sudo cp arch/arm/boot/dts/*.dtb mnt/fat32/
sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/
sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/
sudo umount mnt/fat32
sudo umount mnt/ext4
- Put the card in, booted it up and we were away to the races! I was now able to boot the RPi, run
raspi-config to get things set up, then SSH on and load all the firmwares from the forum into the
- Installing tvheadend was pretty simple – instructions are here, but
apt-get worked for me after adding
deb http://apt.tvheadend.org/unstable/ jessie main to
Things have moved along quite a way since my first forays into getting AirPlay-compatible Raspberry Pi devices on my home network!
Thanks to Rui’s post here, it was pretty easy to get going on my old Raspberry Pi B+ with a USB Creative Live DAC. All I did was follow the instructions using W32 Disk Imager to put a Raspbian Lite image on a 4GB sound card. Then, I followed Rui’s instructions, which are truncated below:
# NOTE:run these as root (or prefixed with sudo)
# install required packages
apt-get install git automake alsa-utils autoconf libtool libdaemon-dev libasound2-dev libpopt-dev libconfig-dev avahi-daemon libavahi-client-dev libssl-dev make g++
# grab the source
git clone https://github.com/mikebrady/shairport-sync.git
# build it
autoreconf -i -f
./configure --with-alsa --with-avahi --with-ssl=openssl --with-metadata --with-systemd
# create a user account for it and add it to the audio group
groupadd -r shairport-sync
useradd -r -M -g shairport-sync -s /usr/bin/nologin -G audio shairport-sync
# install and enable service
systemctl enable shairport-sync
Then I edited
/usr/local/etc/shairport-sync.conf and added in the name of my AirPlay device that I wanted to appear on the network, and added in these two lines (which I got from using
aplay -l to figure out what my USB sound card was coming in as):
alsa = section)
output_device = "hw:1";
mixer_control_name = "USB Audio";
Done. I also tried adding in the
dwc_otg.speed=1 line to
/boot/cmdline.txt but found that there was no real need for it as I don’t have any crackling or popping like I used to (after making sure the mic input was muted using
alsamixer). Plus, when I do have that line in, USB keyboards and the like don’t work, so be careful with that one.
Some good links that are needed to navigate this minefield: