Netboot

Netboot describes the means of booting a device when the rootfs is not on the device but accessed via network, in this implementation via USB networking.

Preparations
Make sure your kernel has the necessary kernel config options for netboot.

If not you need to adjust your kernel config otherwise netboot won't work.

Usage
First prepare a rootfs for your device. It is advisable to use the  argument to increase the size of your rootfs (in the example you will get 1000MB of extra space) as no image resize will happen at runtime. Also, some devices are configured to be flashed with a sparse image, but that is not compatible with netboot currently.

Then prepare your boot.img and flash it to the device:

After booting the device a network interface should appear over USB networking.

Finally you need to start the netboot server on your computer with the following command:

Make sure to open up tcp port 9999 on your computer's firewall so the phone can connect to your netboot service.

If you've never used netboot for the current device, then the image from the previous  will get copied to   and will persist normal   calls as you will probably have data in your rootfs.

Note: For android devices, you may need to run  before flashing/booting the kernel. If you are running an a/b slot device, make sure to add the correct suffix (dtbo_a or dtbo_b).

Replacing persisted rootfs
You can replace the persisted rootfs image with a fresh image from :

Deleting all netboot images
You can delete all persisted rootfs images:

Resizing a netboot image
When you run out of space in your netbooted rootfs, you can increase the size of the image! The following example increases the size of the image  by 1 GiB.

Troubleshooting
As of 01/31/2022, there are a couple known issues:


 * The initfs netboot hook currently expects a boot sector size of 512 bytes, but many android devices may be configured with a sector size of 4096 using the  property.  This will give an error like "unable to find boot partition".  Using debug-shell (add to install with  ) to modify the   file and setting the nbd-client sector size to 4096 should fix this.
 * Some android devices may set  to true and this causes the generated block device to be unusable by netboot.  You can pass "--no-sparse" to your   command to override this.