Skip to content
Tarik Viehmann edited this page Jun 18, 2024 · 2 revisions

This repository contains everything you need in order to network mount a linux OS for a raspberry pi.

OS Setup

This repository already contains the OS, hence usually nothing to be done here. However, in case you want to make this from scratch, download the image of the OS you want to use (e.g., latest Raspbian OS). Assuming the image is called netboot-os.img

Get image content

First, as OS images contain disk setups, we need to find out the corresponding loop devices:

sudo losetup -Pf netboot-os.img --show

This returns something like: /dev/loop<i>, e.g., let's use /dev/loop9 here

The first partition of that device is the boot partition, the second is the OS itself. With this information, we can mount it:

mkdir ~/os
mkdir -p ~/boot/firmware
sudo mount /dev/loop9p2 os
sudo mount /dev/loop9p1 boot/firmware

Delete old image

In order to replace the OS stored in this repository, first we need to delete the old OS, e.g., by deleting all directories. Assuming you cloned this repository to ~/gripper-pi-img, a useful find command for that is (no copy-and-paste ready command to delete all directories will be provided here, if you perform these kind of operations, you should know what to do):

find . -maxdepth 1 -not -path '*/.*' -type d

Afterwards, copy the mounted os over:

sudo cp -r ~/os/* ~/gripper-pi-img/
sudo cp -r ~/boot ~/gripper-pi-img/

Update boot options to network boot

In order to use network booting, the content of the ~/gripper-pi-img/boot/firmware/cmdline.txt should be something like this (where of course the nfsroot needs to point to the address of the netboot provider:

selinux=0 dwc_otg.lpm_enable=0 console=tty1 rootwait rw nfsroot=192.168.0.12:/rpi ip=dhcp root=/dev/nfs systemd.log_level=info systemd.log_target=console systemd.debug-shell=1

Update mounting options to network boot

The content of ~/gripper-pi-img/etc/fstab likewise needs to point to the nfs provider

proc            /proc           proc    defaults          0       0
192.168.0.12:/rpi / nfs defaults,noatime 0 1

Update permissions

Run the get-permissions.sh script as your regular user (NOT AS ROOT):

./get-permissions.sh

Push changes

Try to add the OS to the git worktree and check if it complains, if yes -> run the permission fixer script (NOT AS ROOT):

./fix-permissions.sh

Then you are ready to commit and push your changes.

Host Setup

Clone this repository on the host that should provide the OS for network booting the raspberry and then run the apply-permissions.sh script (NOT AS ROOT):

./apply-permissions.sh