Subject: [alpine-user] What is the best install type for embedded projects on the Raspberry Pi Zero?

From: East <[email-masked]>
Date: Sun, 19 May 2019 11:54:20 +0000

Hello,

I am working on a project that I want to use Alpine as the base for, however I am running into problems with resource usage. Specifically, I have limited constraints on RAM. Normally, a diskless install just loads everything into memory. Now, that may work for some platforms, but I only have 512MB of RAM, and I need to install relatively large dependencies and an X server. 512MB goes by fast.

Normally, I would just do a sys install. The problem is, this is complicated on the Pi 1/Zero. From [here](https://wiki.alpinelinux.org/wiki/Raspberry_Pi#Traditional_disk-based_.28sys.29_installation):

"Beware, though, that the contents of /boot will be ignored when the Pi boots: it will use the kernel, initramfs, and modloop images from the FAT32 boot partition. To update the kernel, initfs or modules, you will need to manually (generate and) copy these to the boot partition or you could use bind mount so that manually copy the files to boot partition is not needed."

I am dealing with relatively low level stuff, and while I can't be sure, having the kernel and other core components not existing on the same partition as the rest of the filesystem is likely to cause problems. For example: how do I enable I2C with a setup like that? IIRC that requires a kernel module to be enabled, and if the wiki is to be believed, then that means I have to copy over files to the FAT32 partition if I do that. It just seems messy, and that is a headache I would like to avoid. It also throws a wrench into the works when--once I finally have a way to build the images that I will ship--this kludgy method randomly breaks.

Maybe I am misunderstanding this. Nonetheless:

How exactly does diskless mode work? I know that it loads everything into RAM, but if I create an APKOVL and then use it to store state, that loads everything into RAM on boot, right? Is there a way to reduce the RAM footprint by only loading the Alpine base into RAM, while storing the contents of the APKOVL on disk? If so, that is the most convenient solution.

Is there a better way to handle a sys install on RPi Zero than is documented in the wiki?

Is there a better way to achieve this, period?

---

From: East <[email-masked]>
Date: Mon, 20 May 2019 00:43:53 +0000

On an unrelated note: does Alpine even support the Pi Zero? Because based on some research I just did, it looks like there is only an image for armhf, and the Pi 1 and Zero do not support armhf.

Maybe I am mistaken. [The Alpine downloads page](https://alpinelinux.org/downloads/) lists the Pi 1 as being supported, and the Pi Zero uses the same processor. But the Pi 1 can't run the armhf build, nor aarch64 or armv7 AFAIK.

I have followed the instructions in the wiki to try to get the Pi Zero to work with armhf, so I know for a fact that it fails. I get 7 LED blinks, which indicates that it can't find the kernel, which I am assuming means that it doesn't like armhf. I could be wrong though.

Sent with [ProtonMail](https://protonmail.com) Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

---

From: Paul Zillmann <[email-masked]>
Date: Mon, 20 May 2019 12:41:20 +0200

Hello East,

loadable Kernel modules are stored in /lib/modules and don't have to be 
in the in the /boot/ folder like in FreeBSD. If that would be the case, 
you can easyli mount a folder onto another (mount bind).

Same is true for mounting a fat32 formatted partition (/dev/mmcblk0 if 
I'm not mistaked) to /boot/ if you are used to work with the Linux 
Filesystem Structure.

I'll take a look into the wiki.

- Paul

Am 19.05.19 um 13:54 schrieb East:
> Hello,
>
> I am working on a project that I want to use Alpine as the base for, 
> however I am running into problems with resource usage. Specifically, 
> I have limited constraints on RAM. Normally, a diskless install just 
> loads everything into memory. Now, that may work for some platforms, 
> but I only have 512MB of RAM, and I need to install relatively large 
> dependencies and an X server. 512MB goes by fast.
>
> Normally, I would just do a sys install. The problem is, this is 
> complicated on the Pi 1/Zero. From here 
> <https://wiki.alpinelinux.org/wiki/Raspberry_Pi#Traditional_disk-based_.28sys.29_installation>:
>
> "Beware, though, that *the contents of /boot will be ignored when the 
> Pi boots*: it will use the kernel, initramfs, and modloop images from 
> the FAT32 boot partition. To update the kernel, initfs or modules, you 
> will need to manually (generate and) copy these to the boot partition 
> or you could use bind mount so that manually copy the files to boot 
> partition is not needed."
>
> I am dealing with relatively low level stuff, and while I can't be 
> sure, having the kernel and other core components not existing on the 
> same partition as the rest of the filesystem is likely to cause 
> problems. For example: how do I enable I2C with a setup like that? 
> IIRC that requires a kernel module to be enabled, and if the wiki is 
> to be believed, then that means I have to copy over files to the FAT32 
> partition if I do that. It just seems messy, and that is a headache I 
> would like to avoid. It also throws a wrench into the works when--once 
> I finally have a way to build the images that I will ship--this kludgy 
> method randomly breaks.
>
> How exactly does diskless mode work? I know that it loads everything 
> into RAM, but if I create an APKOVL and then use it to store state, 
> that loads everything into RAM on boot, right? Is there a way to 
> reduce the RAM footprint by only loading the Alpine base into RAM, 
> while storing the contents of the APKOVL on disk? If so, that is the 
> most convenient solution.
>