Skip to content

Instantly share code, notes, and snippets.

@HarvsG
Last active September 15, 2019 14:25
Show Gist options
  • Save HarvsG/566b4e55bb2ae8e57d745ebd858cefbd to your computer and use it in GitHub Desktop.
Save HarvsG/566b4e55bb2ae8e57d745ebd858cefbd to your computer and use it in GitHub Desktop.

Ideas for network booting raspberry Pis

  1. Configure an iSCSI target on a Pi

    • install ubuntu server https://ubuntu.com/download/iot/raspberry-pi-2-3 using belena etcher
    • log in via ssh user:ubuntu pw:ubuntu - enabled by default on ubuntu server. change password
    • sudo apt update && sudo apt upgrade -y
    • sudo su
    • sudo apt -y install targetcli-fb
    • plug in s usb drive and as su fdisk -l
    • fdisk /dev/sda then commands d to delete current parition n to start new, then keep defaults. Then exit with w
    • reboot or run partprobe
    • targetcli
    • cd /backstores/block
    • create disk /dev/sda1
    • /iscsi
    • create iqn.2019-09.local.ubuntu:server
    • /iscsi/iqn.2019-09.local.ubuntu:server/tpg1/acls
    • create iqn.2019-09.local.ubuntu:pi3b1 change pi3b1 to the name of your client
    • cd iqn.2019-09.local.ubuntu:pi3b1
    • set auth userid=pi3b1 set auth password=raspberry
    • /iscsi/iqn.2019-09.local.ubuntu:server/tpg1/luns
    • create /backstores/block/disk
    • exit
    • ss -napt | grep 3260 `LISTEN 0 256 0.0.0.0:3260 0.0.0.0:*
  2. Install BerryBoot on an SD card for each pi.

    • format an SD as Fat32, partition table should be MBR/MSDOS
    • Copy the conents of the berryboot zip to the root folder
    • add vncinstall ipv4=192.168.88.88/255.255.255.0/192.168.88.1 datadev=isci qmap=gb to the end of the cmdline.txt - changing IPs as appropriate, do not put it on a newline.
    • edit iscsi.sh as apporopriate and add /sbin/iscsistart -i "iqn.2019-09.local.ubuntu:pi3b1" -g 1 -t "iqn.2019-09.local.ubuntu:server" -a "192.168.0.7" -u "pi3b1" -w "password" to iscsi.sh using the iqns and settings used in 1
    • now if all is working you may find you boot into an empty boot menu with all options greyed out. If this is the case continue
    • edit cmdline.txt once more this time delete datadev=iscsi for now. reboot berryboot
    • this time you should boot into the berryboot set up - click through the menus, set up the iscsi manually.
    • It should add a new disk sda1, select this a format the disk
    • then it take you to a bootmenu editor with the correct amount of free space availible. Install any OS from the menu.
    • It will reboot and will fail, edit cmdline.txt once more and replace datadev=<some long hexadecimal> with datadev=iscsi and reboot.
    • You should now be in the bootmenu with the single OS you installed and a valid button through to the bootmenu editor.
  3. Add new OS

  4. Switch between OSs/projects easily with this methodology -(currently untested)

  5. Edit OS root files by doing the following

    • Get the partition layout of the image
$ sudo fdisk -lu /var/lib/iscsi_disks/disk01.img
...
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Device                           Boot  Start      End  Sectors  Size Id Type
/var/lib/iscsi_disks/disk01.img1        2048   262143   260096  127M  e W95 
/var/lib/iscsi_disks/disk01.img2      262144 20971519 20709376  9.9G 83 Linu
  • Calculate the offset from the start of the image to the start of the large partition

  • Sector size * Start = (in the case) 512 * 262144 = 134217728

  • Make a mount point

sudo mkdir /mnt/iscsiDisk01/
sudo mkdir /mnt/OS1/
  • Mount it on /dev/loop98 using the offset
sudo losetup -o 134217728 /dev/loop98 /var/lib/iscsi_disks/disk01.img
  • Now the partition resides on /dev/loop0. You can fsck it, mount it etc
sudo fsck -fv /dev/loop98
sudo mount -rw /dev/loop98 /mnt/iscsiDisk01
  • Now you can browse
cd /mnt/iscsiDisk01/images
sudo mount -rw Debian_Stretch_Raspbian_2018.11.img192 /mnt/OS1
cd /mnt/OS1/
  • Make any changes

  • Unmount

cd /
sudo umount /mnt/OS1
sudo umount /mnt/iscsiDisk01
sudo losetup -d /dev/loop98
                                                                  +---+  +---+
                                                                  |SSD|  |SSD|
                                                                  |   |  |   |
 +------+            +-----------------------+                    |   |  |   |
 |ISP   |            |                       |                    +---+  +---+
 |Router|            |     8 port switch     |                        |  |
 |In    |  +------+  |                       |                        |  |
 |Modem |  |GlInet|  |                       |  +----+ +----+ +----+ ++--++
 |Mode  |  |Router|  |                       |  |pi 1| |pi 2| |pi 3| |pi 4|
 |      |  |?POE  |  |4 non poe 4 poe ports  |  |3B  | |3B  | |3B+ | |4B  |
 |      |  |VPN   |  |                       |  |Hole| |OSMC| |DATA| |NAS |
 +--+--++  +-+--+-+  +--+-+-+-+---+-+-+-+----+  +--+-+ +--+-+ +--+-+ +--+-+
    |  |     |  |       | | | |   | | | |          |      |      |      |
    |  +-----+  +-------+ | | |   | | | +----------+      |      |      |
    |                     | | |   | | +-------------------+      |      |
    |                     v | v   | +----------------------------+      |
    v                    AP | TV  +-------------------------------------+
   WAN                      |
                            v
                        x86 Laptop Server

Made on ASCIFLOW

Issues

  • Headless set up is tricky. The vncinstall ipv4=192.168.88.88/255.255.255.0/192.168.88.1 above enables VNC for berryboot. However this does not garuntee that any OS booted will be headless. Even though berryboot's /boot/ folder becomes the /boot/ of the OS adding a ssh file does not seem to carry through
  • There doesn't seem to be a way to add one's own OS to the system yet. I have tried the long press add OS button -> add from usb but it didn't recognise the USB (I havent checked the format yet).
@HarvsG
Copy link
Author

HarvsG commented Sep 6, 2019

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