UCI – Unified configuration interface is a tool used in openwrt in order to configure the system. You can either change the configuration files by hand or change the full configuration with UCI. I strongly recommend to use it instead of using the configuration files directly. Here I list the basic commands and I will give some examples of usage:
$ uci show | Shows the full list of entries in UCI. |
$ uci show SECTION | Shows an specific section’s entries inside UCI. |
$ uci set section.attribute=value | Sets the attribute of the section to one value. |
$ uci commit | Commits all the changes and save them. |
$ uci export file.conf | Saves UCI’s configuration inside a configuration file. |
$ uci import file.conf | Loads UCI’s configuration from a configuration file. |
The first example about how to use UCI was in the section where we configured the usb as root file system. Here I attach the example we made:
Configure the fstab to mount the usb drive as default mount point:
$ uci set fstab.@mount[0].target=
$ uci set fstab.@mount[0].fstype=ext2
$ uci set fstab.@mount[0].enabled=1
$ uci set fstab.@mount[0].is_rootfs=1
$ uci set fstab.@mount[0].options=rw,noatime,async
$ uci commit |
In this case to see the fstab configuration inside uci we should use “$ uci show fstab”:
root@OpenWrt:~# uci show fstab
fstab.automount=global fstab.automount.from_fstab=1 fstab.automount.anon_mount=1 fstab.autoswap=global fstab.autoswap.from_fstab=1 fstab.autoswap.anon_swap=0 fstab.@mount[0]=mount fstab.@mount[0].target=/home fstab.@mount[0].device=/dev/sda1 fstab.@mount[0].fstype=ext4 fstab.@mount[0].options=rw,sync fstab.@mount[0].enabled=0 fstab.@mount[0].enabled_fsck=0 fstab.@swap[0]=swap fstab.@swap[0].device=/dev/sda2 fstab.@swap[0].enabled=0 |
Then we just set the configuration as we want and finally commit the changes with “$ uci commit”.
There are other configuration options such as the wireless and the network. I strongly recommend you to take a look with “$uci show” and see what is in there.
Again, I hope you found this article useful.
David.