How can I mount var as ramfs at my developing device?

Hi all,

I'm using OpenWrt 19.07.7 to develop firmware for my own device.
Since /var is soft link to /tmp, we want to change it to ramfs.
Following is my changes.

diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 87393a397e9..99fc1693795 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -173,8 +173,8 @@ define Package/base-files/install
        mkdir -p $(1)/www
        mkdir -p $(1)/root
        $(LN) /proc/mounts $(1)/etc/mtab
-       rm -f $(1)/var
-       $(LN) tmp $(1)/var
+       rm -rf $(1)/var
+       mkdir -p $(1)/var
        mkdir -p $(1)/etc
        $(LN) /tmp/resolv.conf /tmp/TZ /tmp/localtime $(1)/etc/
diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot
index 09b7f44c794..2dd9ffda0e9 100755
--- a/package/base-files/files/etc/init.d/boot
+++ b/package/base-files/files/etc/init.d/boot
@@ -22,6 +22,7 @@ boot() {
        [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
        [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD
+       grep -q ramfs /proc/filesystems && /bin/mount -t ramfs ramfs /var
        mkdir -p /var/run
        mkdir -p /var/log
        mkdir -p /var/lock

When my device boot up, it always stock here.

[   13.440000] procd: - early -
[   13.448000] procd: - watchdog -
[   14.100000] procd: - watchdog -
[   14.104000] procd: - ubus -

Anyone can help me out? Thanks a lot.

Not an answer but a question.

Isn't /tmp already ramfs, and by linking var and others to tmp you are pooling the limited ram


Hi mobo2o,

Yes, currently, var is linking to tmp and tmp is tmpfs.
But, on my device, var is specific folder for driver's operation, like share memory, ....
We just want to try if var is isolated folder with ramfs, not tmpfs, does this change can improve performance. Thanks.

1 Like

Anyone can help? Thanks.