Filesystems, mounts, overlay etc

This will be a very newbie question, and I am totally ashamed asking it. But I can't very well proceed with my intended improvements until I know.

So --- I still don't understand the mounts / filesystems. I mean out of the box, nothing external. Say I create a new file in /root , where will it go? Flash or RAM? Now same question in / . And /usr. And ...

If it matters, this is the One, all up to date with 24.10.

Use the "mount" command to check where the file will be written...

For simple routers, usually used:

/overlay <-- collects all your modified files
so if you create or modify a file, it will be written here (a portion of the router's flash drive).

in the case of x86 routers or those that have dedicated hardware support (internal SSD/SD card/hard disk):

If you use "ext4" partitions, they are usually saved on a hard drive (SSD, hard drive, etc.).

In any case, the "mount" command will give you the exact location.

At most, post the output of the following command if you want an interpretation of your situation:

mount; df -h

in case you miss the command:

opkg update; opkg install mount-utils; opkg files mount-utils; opkg info mount-utils

Output of mount follows. The last line is a USB external drive I connected, and I understand that --- that's just Unix / Linux. The lines before, not so much :scream:

root@OpenWrt:~# mount
/dev/root on /rom type squashfs (ro,relatime,errors=continue)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/ubi0_5 on /overlay type ubifs (rw,noatime,assert=read-only,ubi=0,vol=5)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work,xino=off)
tmpfs on /dev type tmpfs (rw,nosuid,noexec,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,noatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,noatime)
bpffs on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,noatime,mode=700)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,noatime)
/dev/sda1 on /mnt/DISUNITY type ext4 (rw,relatime)

So if you create a file within a path starting with "/mnt/DISUNITY," it's written to "/dev/sda1," your hard drive/USB key.

If you create a file in "/tmp," and all the directories below it, it's written to RAM (to be sure, you need the "df -h" command output).

If you create a file elsewhere, it'll be stored in "/dev/ubi0_5," a part of the router's flash drive.

Is that clear, or do you need more details?

A very similar example (on my router):

mount; echo; df -h
/dev/ubiblock0_0 on /rom type squashfs (ro,relatime,errors=continue)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/ubi0_1 on /overlay type ubifs (rw,noatime,assert=read-only,ubi=0,vol=1)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,noexec,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,noatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,noatime)
bpffs on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,noatime,mode=700)
/dev/sda1 on /tmp/mnt type ext2 (rw,relatime)

Filesystem                Size      Used Available Use% Mounted on
/dev/root                12.0M     12.0M         0 100% /rom
tmpfs                   121.6M     15.5M    106.2M  13% /tmp
/dev/ubi0_1               8.3M    380.0K      7.5M   5% /overlay
overlayfs:/overlay        8.3M    380.0K      7.5M   5% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1                14.2G    703.6M     12.8G   5% /tmp/mnt

I think that gets me started for now, thanks.

If you tell me or us what you want to achieve, maybe we can help you...

I was afraid you might ask that :grin:

So basically, right now the external drive, where I put a few things like logs and backups, is a big and somewhat noisy spinning rust. I want to replace it with a pen drive or a SD card, but that means I don't want to write to it all the time because they get tired. So I want to keep things in RAM and then flush them with a cronjob maybe once a day or so.

Makes any sense?

I'd say yes (make sure all logs are saved to RAM).

Create a subdirectory (usually already there) "/tmp/log" and save the logs there:

find /tmp/log/
/tmp/log/
/tmp/log/lastlog
/tmp/log/wtmp

That's roughly what I had in mind. Thanks.

1 Like

Afterwards, if you want, you can transfer them to a remote host or save them to a storage device attached to the router. The choice is yours.

You have also possibility to copy them to some network drive.

Just install proper filesystem “driver”, mount your network folder to your router and make copy.

I use myself a ramdrive on my Windows server to save some temporary files with combined size more than 1GB. It takes a cifs filesystem driver on the router to do it.

1 Like