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
parted <device>- Verify you are access the right device and it doesn’t have data you need.
mklabel gptmkpart primary 1 -1print- Verify partition was created correctly.
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
parted <device>- Verify you are access the right device and that it is empty except for OpenWrt on the first partition.
mkpart primary 500M -1NB: 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.print- Verify partition was created correctly.
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.
block detect | uci import fstabmkdir -p /srv- Edit
/etc/config/fstabto change thetargetfor your new filesystem to/srv. This is usually the only file system besides/romand/overlay, and for some devices/boot. - Now, set
enabled 1for that filesystem. block mount- 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.