I've been meaning to write this up properly for a while now but never seem to find the time. Until then, here's some notes and example scripts to assist with the process of booting a rootfs over NFS via USBNet. You definitely want to have a device with a soldered/permanently attached serial connection before attempting this.
Prerequisites:
You need to build a kernel using a custom initramfs entrypoint script to mount the NFS share early in the boot process:
A means of automatically configuring the USBNet interface is also necessary:
Setting up NFS share:
A "stock" rootfs image won't boot successfully and it's useful to be able to make changes that can be removed later, so we need to set up a fairly complicated mount point:
TL;DR it's a unionfs with 3 layers:
Once that's done, we can export the directory structure as an NFS share:
These options are probably not great/are insecure but if it's stupid and it works... :cool:
We also need a way of letting the device know which share to mount - this is a cut down version of the server that I use for this:
... and also a config file containing serial number/mount paths:
Bootmods:
As alluded to, a stock rootfs image won't boot by default - upstart scripts will need to be tweaked and the like. Here's what the structure of my KT2 bootmods folder looks like:
All things combined, this will allow the device to boot fully and bring up an SSH server and x11vnc instance (yes, I've also been sitting on an x11vnc KUAL plugin that I really should release...). A couple of these are stock upstart scripts with minor tweaks, diff the originals from a stock rootfs image if you want to see the differences.
dropbear.conf:
filesystems_userstore.conf
langpicker.conf
x11vnc.conf
We also need to blank the root password:
... and edit /usr/bin/mntroot so that it doesn't break now that we're booting from NFS
Prerequisites:
You need to build a kernel using a custom initramfs entrypoint script to mount the NFS share early in the boot process:
Spoiler:
A means of automatically configuring the USBNet interface is also necessary:
Spoiler:
Setting up NFS share:
A "stock" rootfs image won't boot successfully and it's useful to be able to make changes that can be removed later, so we need to set up a fairly complicated mount point:
Code:
mkdir -p /data/kindle-rootfs/KT2
mkdir -p /srv/{rootfs,union,bootmod}/KT2-5.12.2.1
kindletool extract update_kindle_5.12.2.1.bin /tmp/update
gzip -d /tmp/update/rootfs.img.gz
mv rootfs.img /data/kindle-rootfs/KT2/5.12.2.1.img
# We use unionfs-fuse as standard unionfs doesn't play nice over NFS
sudo unionfs-fuse -o cow,max_files=32768 \
-o allow_other,noforget,suid,dev,nonempty \
/srv/user/KT2-5.12.2.1=RW:\
/srv/bootmod/KT2-5.12.2.1=RO:\
/srv/rootfs/KT2-5.12.2.1=RO \
/srv/union/KT2-5.12.2.1
- user - temporary changes made on device
- bootmod - read only layer containing files and binaries needed on device
- rootfs - mount point for "stock" image
Once that's done, we can export the directory structure as an NFS share:
Spoiler:
These options are probably not great/are insecure but if it's stupid and it works... :cool:
We also need a way of letting the device know which share to mount - this is a cut down version of the server that I use for this:
Spoiler:
... and also a config file containing serial number/mount paths:
Spoiler:
Bootmods:
As alluded to, a stock rootfs image won't boot by default - upstart scripts will need to be tweaked and the like. Here's what the structure of my KT2 bootmods folder looks like:
Spoiler:
All things combined, this will allow the device to boot fully and bring up an SSH server and x11vnc instance (yes, I've also been sitting on an x11vnc KUAL plugin that I really should release...). A couple of these are stock upstart scripts with minor tweaks, diff the originals from a stock rootfs image if you want to see the differences.
dropbear.conf:
Spoiler:
filesystems_userstore.conf
Spoiler:
langpicker.conf
Spoiler:
x11vnc.conf
Spoiler:
We also need to blank the root password:
Spoiler:
... and edit /usr/bin/mntroot so that it doesn't break now that we're booting from NFS
Spoiler: