Mounting an mtdblock (rootfs_data) as rw partition

Hi All,

New to openWRT filesystems and partitions, Any suggestions on the below would be helpful.
For development purposes I would want the root "/" directory to be read write,
thus allowing any file creation.

Since root dir / is mounted as ro, facing a lot of issues while exection of some scripts, errors similar to below one:

mkdir: can't create directory '/cfg/': Read-only file system
cp: can't create directory '/cfg/default/': No such file or directory
cp: can't stat '/cfg/default/ini/global.ini': No such file or directory
sed: can't create temp file '/ini/global.iniXXXXXX': Read-only file system
/sbin/wifi: eval: line 1: can't create /ini/global.ini: Read-only file system

As of now, not able to modify the squashfs /dev/mtdblock18 as a rw partition.
Below is the log from device, displaying mount and partitions.

root@RuckusAP:/# mount
/dev/mtdblock18 on / type squashfs (ro,noatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,noatime,mode=700)
ubi2:data on /writable type ubifs (rw,sync,relatime,assert=read-only,ubi=2,vol=0)
root@RuckusAP:/# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 0c000000 00020000 "rcks_wlan.main"
mtd1: 0c000000 00020000 "rcks_wlan.bkup"
mtd2: 08000000 00020000 "datafs"
mtd3: 00800000 00010000 "NOR"
mtd4: 00050000 00010000 "SBL1"
mtd5: 00010000 00010000 "MIBIB"
mtd6: 00020000 00010000 "BOOTCONFIG"
mtd7: 00080000 00010000 "ART"
mtd8: 00040000 00010000 "RPM"
mtd9: 00010000 00010000 "CDT"
mtd10: 00010000 00010000 "APPSBLENV"
mtd11: 000a0000 00010000 "APPSBL"
mtd12: 00020000 00010000 "BOOTCONFIG1"
mtd13: 00180000 00010000 "QSEE"
mtd14: 00010000 00010000 "DEVCFG"
mtd15: 00010000 00010000 "APDP"
mtd16: 00010000 00010000 "Board Data"
mtd17: 003e0000 0001f000 "kernel"
mtd18: 03546000 0001f000 "ubi_rootfs"
mtd19: 00410000 0001f000 "kernel"
mtd20: 02ef6000 0001f000 "ubi_rootfs"
mtd21: 06e13000 0001f000 "data"

Below is the snippet from image Makefile:

define Image/Build
echo "...................Image/Build/127....................." >&2
#$(call Image/Build/$(1),$(1))
dd if=$(KDIR)/root.squashfs of=$(BIN_DIR)/squashfs-root.img bs=2k conv=sync
endef

Other similar errors:
touch: /etc/config/network: Read-only file system

Thanks in adv!
DR

1 Like

kmod-mtd-rw ?

Hey @frollic , its not enabled in the configs, will try it out once. Ty for the quick revert :slight_smile:

squashfs is a read-only filesystem, you can't write to it, regardless of what you do - but OpenWrt spans an overlayfs over it, so it appears to be (virtually) writable (later on in the boot process).

1 Like

yes @slh , i also came across that yhere needs to be an overlay that sits on top of squashfs to make it writeable. Will need to explore on the same to understand the changes that i need to make.

Thanks,
DR

And you didn't fix the failure but supplying the required safety argument for insmod????

insmod mtd-rw.ko i_want_a_brick=1

Ps. But like others have already said, you likely want the normal r/o ROM + r/w overlay, like most OpenWrt routers do.

i did try this out, but it kept throwing subsequent errors and insmod failed.
And yea, have enabled overlayfs in configs, will need to look at other changes required.

errors like:


[   77.128241] ubi2 error: 0x806aefe8: cannot open device 2, volume 0, error -16
[   77.128267] mtd-rw: mtd21: error -16
[   77.134340] mtd-rw: no partitions to unlock
failed to insert /lib/modules/5.4.164/mtd-rw.ko

Which hardware and which version/release of OpenWrt are you running?

Did you configure the read-write overlay to end up in /writable?! For things to work as intended, the read-write filesystem should end up in /overlay...

I'm sorry, but this is Qualcomm SDK and not OpenWrt, and it's a total mess. I have never touched it, and if you asked me, nobody ever should :wink: