Prepare storage for Zabbix

Details on preparing storage for use for the database and logging for a Zabbix system on OpenWrt, for a fresh install.

Prepare Storage for PostgreSQL database and system and Zabbix logging

For PostgreSQL, as well as for robust logging, storage which is persistent, large, and can be written often is required.

Ideally this is on a separate device than the OpenWrt image, however this guide also covers using the space after the OpenWrt image (for example if OpenWrt is installed on the only, large, SSD in the system).

Partition the storage

This guide assumes you have installed any drivers needed for your storage, as outlined in the preparing firmware step.

In either case, identify the device (e.g. /dev/nvme0n1 for the first NVME SSD, or /dev/sdb for the second SATA drive) in /dev which you wish to use.

It may help to use block info blkid, or dmesg here to identify devices discovered by the kernel during boot.

Option 1: On a separate device

  1. parted <device>
  2. print
  3. Verify you are access the right device and it doesn’t have data you need.
  4. mklabel gpt
  5. mkpart primary 1 -1
  6. print
  7. Verify partition was created correctly.
  8. quit

If you now ls /dev/<device>* you should see /dev/<device>p1.

For the rest of this guide we call this <datapartition>.

Option 2: On the same device as OpenWrt

  1. parted <device>
  2. print
  3. Verify you are access the right device and that it is empty except for OpenWrt on the first partition.
  4. mkpart primary 500M -1 NB: If used the 300MB root partition size recommended in the firmware creation step, this leaves ~200MB of space between the root partition and the data partition.
  5. print
  6. Verify partition was created correctly.
  7. quit

If you now ls /dev/<device>* you should see /dev/<device>p2 (or /dev/<device>p3 on a device with a separate /boot partition, such as a Raspberry Pi 5).

For the rest of this guide we call this <datapartition>.

On a Raspberry Pi 5 this procedure will change the partition id the system uses to find the root device. You would therefore need to use blkid and copy the value after PARTUUID for your root partition to /boot/cmdline. In addition, you need to copy the part of the PARTUUID before the - to /boot/partuuid.txt.

Format the storage for use

For most devices, the author recommends the use of F2FS, which is a modern log filesystem designed for flash filesystems (including USB sticks and SSDs, although it is less important for a modern SSD).

Option 1: Using F2FS

mkfs.f2fs /dev/<datapartition>

Option 2: Using Ext4

mkfs.ext4 /dev/<datapartition>

Mount the storage on boot

By default on OpenWrt, the fstab is managed by UCI in /etc/config/fstab and the block-mount package, which adds the block command.

  1. block detect | uci import fstab
  2. mkdir -p /srv
  3. Edit /etc/config/fstab to change the target for your new filesystem to /srv. This is usually the only file system besides /rom and /overlay, and for some devices /boot.
  4. Now, set enabled 1 for that filesystem.
  5. block mount
  6. If you now df -h, you should see <datapartition> current usage and mounted on /srv.

See Fstab configuration on the OpenWrt Wiki for more information.