RPi/Ubuntu with ISCSI Boot

Raspberry Pi setup to avoid SD Card failures; IScsi boot from Syno NAS.

At this point, most home automation and IoT enthusiasts have multiple rpi boxes lying around, and I'm no exception. I've considered moving my home automation projects to rpi/ubuntu, and in the past, I've always worried about SD card failure. As a solution, I'm documenting a solution to network boot the rpi over iscsi (target hosted on a synology nas).

This setup has largely been documented elsewhere - so this post is mostly links included for posterity. This post is based on Ubuntu 20.04 LTS

  • Use RPI Imager to install ubuntu server on an rpi with an SD card. I am choosing an LTS server image for this install (20.04 LTS).
  • Since this is ubuntu - you can simply insert the card, boot up and login into the rpi; Remeber to update the rpi after install
sudo apt-get update && sudo apt-get upgrade
  • iSCSI initiator uses TCP port 860 and 3260 - ensure that your rpi is on the same LAN/VLAN as the target or open the needed ports on your firewall. Remember that the client can connect from any port i.e. the firewall rule needs to allow iSCSI Client (Any ports) -> ISCSI Target (ports 860, 3260)
  • 20.04 LTS has iscsi initiator (client) installed by default. You can check/install the client using below
sudo apt install open-iscsi
  • Create the Target and LUN on the iSCSI server; copy the IQN; in my case it is
iqn.2000-01.com.synology:hulk:rpiboot
  • Follow this guide to setup iscsi initiator; detail steps below.
How to Connect to iSCSI Volume from Ubuntu 20.04 | Manjaro dot site
In the previous article, I have written a short tutorial on how to create an iSCSI Target on TrueNAS. Now in this post, I will [...]
  • Query the target and connect to it; depending on the number of targets you have setup, and if you are using IPv4 and IPv6, you'll see multiple lines of discovery results; be sure to pick the right one
$ sudo  iscsiadm --mode discoverydb --type sendtargets --portal <target-ip> --discover
192.168.200.5:3260,1 iqn.2000-01.com.synology:nas.Target-rpiboot
$ sudo iscsiadm --mode node --targetname iqn.2000-01.com.synology:nas.Target-rpiboot --portal <target-ip> --login
Logging in to [iface: default, target: iqn.2000-01.com.synology:nas.Target-rpiboot, portal: <ip>,3260] (multiple)
  • Use fdisk to partition the new device, create a new primary partition (use defaults); remember to write the partition info with "w"
sudo fdisk /dev/sda
  • Now comes the interesting part - Follow this guide to move the bootdisk to the iSCSI target so that you can boot directly from the iscsi disk (i.e. no writes/ issues on the SDHC card).
  • Find the UUID of the disk (/dev/sda1 in my case)
sudo blkid /dev/sda1
/dev/sda1: UUID="12a0cab2-6e1d-41ba-aa46-2d11f6d848ca" TYPE="ext4" PARTUUID="efbf8b02-01"
  • Follow this article to move the root folder to the iscsi drive and boot from the network.
Raspberry Pi iSCSI Root on Ubuntu 20.04
Over the holidays, I wanted to build a Kubernetes cluster on some Raspberry PisI had, which were collecting dust. I spun up a simple Rancher K3s[https://k3s.io/] cluster, but quickly discovered they were heavily IO-bound. Idecided that if I was going to use this cluster for real applications, I w…
  • Once you reboot; check the mounts; it should show the mounted boot drive /dev/sdaX
$ df -k .
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda1      515009792 3153136 485625924   1% /


All done... ! The next post in this topic will cover setting up home-assistant on this ubuntu server (Step 2: Install Home Assistant Supervised).

Amrish Kaushik

Amrish Kaushik

Bay Area