Skip to content

Partitions

Calin Crisan edited this page Mar 30, 2023 · 17 revisions

SD Card Partition Layout

thingOS uses three partitions on the SD card:

  • a boot partition, FAT, about 20M, mounted read-only at /boot
  • a root partition, EXT4, about 180M, mounted read-only at /
  • a data partition, EXT4, fills up the entire remaining card space, mounted read-write at /data

Partition Sizes

The size of the boot and root partitions are set in mkimage.sh. By default they are set to 30MB and 200MB, respectively. The offsets at which they live on the card are set in such a way that some spare space remains between them, for future partition enlargements. By default, boot start depends on the board, while root start is set to 100MB. Data partition will start at 1024MB, as dictated by S00datapart init script.

Read-only Mounts

The boot and root partitions are normally mounted read-only to reduce the chances of filesystem corruptions. If you really want to edit stuff on these partitions, run the following commands to make them writable:

mount -o remount,rw /
mount -o remount,rw /boot

If the OS_DEBUG variable is set to true, these partitions are automatically mounted as read-write at boot, to allow debugging.

Keep in mind that boot and root partitions are both overwritten when performing a firmware update (except for some board-specific files which are preserved).

The Data Partition

The data partition is created and formatted at first boot in such a way that it fills up all remaining space on the SD card.

The data partition contains all the editable configuration files, logs and all other files that need to be persisted. This is the only partition on the SD card that is normally writable. Wiping out the data partition is equivalent to a factory reset.

Overlay Filesystems

To circumvent the read-only state of root and boot partitions when user changes really need to me made to these partitions, the power of OverlayFS is leveraged. S01mountall will mount all overlay filesystems defined in /etc/fstab.overlay, if the running kernel supports OverlayFS.

By default, the following overlay filesystems are mounted:

  • /data/usr over /usr
  • /data/varlib over /var/lib
  • /data/log over /var/log

Just add more entries to /etc/fstab.overlay to cover other parts of the root or boot filesystems structure.

fstab Files

Different fstab files are used to mount the various available filesystems, as follows:

External Drives

Common partitions found on any connected drives are automatically mounted at /data/media. These partition types include ext2, ext3, ext4, fat32 and ntfs. The mount point is built based on the block device name (e.g. /data/media/sdb2).

This job is done by udev and its storage rules file.

Clone this wiki locally