BelaPlatform / bela-image-builder

Scripts to build a Bela image from scratch
MIT License
37 stars 16 forks source link

partition table #41

Closed giuliomoro closed 7 years ago

giuliomoro commented 7 years ago

Add a large-ish FAT32 partition for the ~ folder
This will allow:

  1. faster boot time by mounting the rootfs as ro
  2. easy access to the partition through a file browser on the host.
  3. a first step towards potential security improvements (e.g.: if the ~ is of a non-root user), though for now it should be /root otherwise nothing will work :)

with the following drawbacks:

  1. partition need to be mounted before the Bela program is started at boot
  2. users may easily modify the examples folder without realizing they are making a permanent change
LBDonovan commented 7 years ago

After doing some research on this I have realised it's not such a good idea.

It's quite a lot more complicated than it sounds to mount the rootfs read-only, as several folders need to be written-to by the system during use. This means you have to mount a bunch of read-write tempfs file-systems on top of the rootfs, and it can get quite messy (https://wiki.debian.org/ReadonlyRoot). It doesn't actually gain much in terms of boot time, the main reason to do it is to prevent data corruption. As FAT32 partitions are much more prone to data corruption than EXT4, this doesn't really make much sense for us.

As a side note, the kernel actually mounts the rootfs as read-only at boot, then later systemd reads /etc/fstab, runs fsck on the rootfs if it was not unmounted properly, and remounts it read-write. Running fsck can add a few seconds to the boot time, so its good to shut your board down properly!

One thing we could do is wipe the emmc, format it to FAT32, mount it to /data and expose it as a USB mass-storage device. That would give people a nicely accessible 4GB of extra storage...