What is the purpose of /etc/fstab on OpenWrt?

I don't see /etc/fstab mentioned anywhere in the documentations. By default it is empty, and the documentations always discuss the usage of block command and its configuration file /etc/config/fstab instead.

Nonetheless, manually invoking the command mount -a do work, and it mounts all entries in /etc/fstab. But the filesystem must be identified by name /dev/sdX (UUID does not work), for example:

/dev/sda /mnt/mount_point btrfs subvol=/,autodefrag 0 0

Is there any use of the file /etc/fstab in OpenWrt? Why does it not accept UUID? How does it interact with fstab subsystem of uci? And which one takes precedence on boot?

/etc/config/fstab

I'm not a OpenWrt developer nor an expert so I don't have answers to your specific questions.

As for choosing a filesystem to mount by UUID, that is available with the uci way but note that the UUID is of the filesystem and not the containing partition UUID. blkid is useful to see the UUIDs and some other info.
OpenWrt Fstab Configuration which you may have already looked at has more info and links to further details.

My understanding of OpenWrt is that uci is used heavily for configuration management and it replaces many of the "standard" linux configurations on boot and with dynamic changes after boot. It is often advised on the forum to use Luci or uci commands to make changes, especially changes you want to survive a reboot or system upgrade. Some config files in a typical *nix installation are present and can be used interactively or in your own scripts but you may need to add a call to each in the init system to have them be used on boot. Some of the binaries you may expect to use might not be included in the system installation but a package may be available pre-built and can be added with opkg. Some programs have limited functionality, likely to save storage and ram usage, and quite a few are implemented in busybox. If your router platform has the ram and storage space, some full programs can be added to replace that feature of busybox.

I know uci is integrated very well with OpenWrt and is the recommended way to go. However, it introduces 2 disadvantages:

  1. To use block command, you must download block-mount package, which is not built-in by default. Why not just use something which is already available (mount command) instead?
  2. I make heavy use of shell scripting. Relying on OpenWrt tools makes my code less portable, and requires modification when I use it with another distro.

Unless it is absolutely necessary or convenient, I avoid writing an if or switch-case statement just to apply different commands to different distros.

I understand your goal of writing portable scripts. I have the same (minor) constraint with OpenWrtScripts that need to run on OpenWrt, Linux, macOS, Windows.

I can't help you with block vs mount, but to get a good answer to your question, perhaps you could re-phrase the subject line. ("What is the purpose of..." will get you all sorts of answers, but may not address your issue.)

I would suggest changing to "How can I ...", and then describe the problem that you're trying to solve. Good luck, and best regards.

2 Likes