Mount a mSATA partition as /var

What is the best way to use a partition of a mSATA disk as “/var” mount point ?

If I only define the mount point ‘/var’ to the dedicated ext4 partition on the mSATA disk in /etc/config/fstab the Omnia router does not work (I lost IP connectivity). I understand that the factory settings define a symbolic link of /var to /tmp which is tmpfs in RAM.

Do I need to copy the current /tmp to the new partition and to remove the symbolic link as it is explained at the end of Rootfs on External Storage [Rootfs on External Storage] and in how to mount var from msata ?

This is a bad idea. Don’t do that. Most of the OpenWRT software is written so that it expects that /tmp and /var are the same. You could and would encounter multiple bugs where paths to same file are both trough /var and /tmp as well as bugs where scripts expects that /var is emptied on every boot. So don’t do it. Rather mount it somewhere else and redirect only things you really need. And don’t redirect them using symlinks, do it by respective program configuration.

1 Like

OK, my main goal is to have persistent logs.
Is it a good practice to mount my partition as /var/log instead of the full /var ?

Or is it better to use it as an independent partition like /mnt/log and configure OpenWRT logging via /etc/config/system log_file ?


Neither. Configure syslog-ng. That is what is used in Turris.

Also best practice would be not to redirect but just do another sink. Copy the line with /var/log/messages and change it to your path.

1 Like