Skip to content

Instantly share code, notes, and snippets.

@HarvsG
Last active September 30, 2020 03:22
Show Gist options
  • Save HarvsG/7d1674e7aadc719d4a82da26731a1501 to your computer and use it in GitHub Desktop.
Save HarvsG/7d1674e7aadc719d4a82da26731a1501 to your computer and use it in GitHub Desktop.
A method to develop a server that allows you to run your Pis SD-less and switch easily between projects

Based on this hands-on

  1. Install piserver on a debian or ubuntu system from source using the tutorial there
    • sudo apt-get install build-essential devscripts debhelper cmake libldap2-dev libgtkmm-3.0-dev libarchive-dev libcurl4-openssl-dev intltool git binfmt-support qemu-user-static
    • git clone --depth 1 https://github.com/raspberrypi/piserver.git
    • cd piserver
    • debuild -uc -us
    • cd ..
    • sudo dpkg -i piserver*.deb
    • If dnsmasq -v is <2.77 then you will need to update it (see link above)
  2. Run sudo -H piserver and run through the set up wizard. Don't bother with adding users too much, avoid creating a pi user - it could complicate things later
  3. If the Pis do not boot see if dnsmasq is actually running sudo netstat -lnp | grep ":53 " if not run sudo dnsmasq -C /etc/dnsmasq.d/piserver to start it then do sudo -H piserver
  4. Allow root filesystem access
    • on the piserver sudo nano /etc/exports
    • in /var/lib/piserver/os *(ro,no_subtree_check,no_root_squash,fsid=1055) change ro to rw this is really insecure as it allows anybody on the network to read or write to the share
    • sudo exportfs -ra
    • you must ensure that each OS is only ever loaded by a single Pi!
    • select each OS, open the shell in piserver to chroot into it then mv /etc/security/pam_mount.conf.xml /etc/security/pam_mount.disabled to disable the LDAP authetication
    • adduser pi run through the commands
    • nano /etc/fstab
    • add rw write access sudo nano /boot/cmdline.txt add rw after the nfs command (include 1 whitespace)
    • Modify: tmpfs /home tmpfs defaults,mode=755 0 0 to tmpfs /home/pi tmpfs defaults 0 0
  5. Now try booting the network Pis, if using a pi3B you will need to use this guide to prime it
    • log in as the pi user you created earlier. run sudo touch /boot/ssh to enable ssh access and confirm you have write acess.
    • shutdown
    • Now clone the OS for each pi, naming it xx-xx-xx-yyyy-mm-os-or-project-name where xx-xx-xx is the last 3 couplets of the inteded pi's MAC address, this will allow you to keep track of which OS is for which pi. You may want to include the model type of the pi in the name as well, to keep track of cross-compatibility.
  6. To install a custom OS or image then use this guide. I have made some modifications. In my case sdX was sdc
sudo bash
mkdir /tmp/mnt_boot /tmp/mnt_root

# i used ubuntu which auto-mounted the drive so i had to do:
umount /dev/sdX1
umount /dev/sdX1

mount -o ro /dev/sdX1 /tmp/mnt_boot
mount -o ro /dev/sdX2 /tmp/mnt_root
cd /tmp/mnt_boot
#this was fast
bsdtar --numeric-owner --format gnutar --one-file-system -cpf ../boot.tar .
cd /tmp/mnt_root
#this was slow
bsdtar --numeric-owner --format gnutar --one-file-system -cpf ../root.tar .
cd /tmp
umount /tmp/mnt_boot
umount /tmp/mnt_root
#this was fast
xz -v boot.tar
# this was slow (i did it without -v for verbose and it was slooow)
xz -v root.tar
/var/lib/piserver/scripts/convert.sh boot.tar.xz root.tar.xz Your_custom_OS.tar.xz
rm boot.tar.xz root.tar.xz

Other links: MyGithub issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment