Read-only filesystem (OpenWrt on VirtualBox)

I've been creating OpenWrt VMs (of the latest stable version) on Virtualbox and I always encounter the same problem.

First boot, I don't install anything on them and suddenly, a few boots after, they become a read-only filesystem and I cannot create or write in files. The df output before the issue is:

vm1@OpenWrt:~$ df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root               252.0M     34.0M    212.9M  14% /
tmpfs                   246.1M     68.0K    246.1M   0% /tmp
/dev/sda1                15.7M      3.2M     12.2M  21% /boot
/dev/sda1                15.7M      3.2M     12.2M  21% /boot
tmpfs                   512.0K         0    512.0K   0% /dev

and when the problem appears:

vm1@OpenWrt:/dev$ df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root               252.0M    159.7M     87.1M  65% /
tmpfs                   246.1M     72.0K    246.1M   0% /tmp
/dev/sda1                15.7M      3.2M     12.2M  21% /boot
/dev/sda1                15.7M      3.2M     12.2M  21% /boot
tmpfs                   512.0K         0    512.0K   0% /dev

Sometimes, /dev/root %Use will go up to 100%.

I decided I should take a look into dmesg:

vm1@OpenWrt:~$ sudo dmesg | grep error
[    8.247885] EXT4-fs error (device sda2): ext4_mb_generate_buddy:757: group 1, block bitmap and bg descriptor inconsistent: 32209 vs 32208 free clusters
vm1@OpenWrt:~$ sudo dmesg | grep read-only
[    0.340195] Write protecting the kernel read-only data: 12288k
[    8.252252] EXT4-fs (sda2): Remounting filesystem read-only

I don't know how to interpret the errors, but it's obvious there is a serious problem here.

I've also done sudo mount -o remount,rw /dev/root / to see if it would help. It didn't.

Also, as you can see in the dmesg output, it talks about a sda2, which according to the df -h results, I don't have.

I don't know if it has anything to do with it, but I created a user (without root access) in the VMs (added a user in /etc/passwd, gave it a password, gave it a /home folder and gave root access with /etc/sudoers file) and everything works perfectly (regarding this new configuration).

What is the issue here?

You need to pad the image.

1 Like

I did, just now,

dd if=openwrt-18.06.4-x86-64-combined-ext4.img of=openwrt-18.06.4-x86-64-combined-ext4.img bs=128000 conv=sync

and then:

inesmll@inesmll:~/Downloads/OpenWrt$ VBoxManage convertfromraw --format VDI openwrt-18.06.4-x86-64-combined-ext4.img openwrt-18.06.4-x86-64-combined-ext4.vdi
Converting from raw image file="openwrt-18.06.4-x86-64-combined-ext4.img" to file="openwrt-18.06.4-x86-64-combined-ext4.vdi"...
Creating dynamic image with size 0 bytes (0MB)...
VBoxManage: error: Cannot create the disk image "openwrt-18.06.4-x86-64-combined-ext4.vdi": VERR_INVALID_PARAMETER

Also, in the link you sent it says "If you receive an error similar to..." then I should pad the image. But I did not have any of those errors... why pad, then?

I haven't used virtualbox in about a decade by now, but dd or qemu-img resize owrt.img +1g are working for me using qemu-kvm.

Well, with virtualbox tools, only the section "Enlarge the image to a useful size (size is in MB)" of the link you sent works, so I managed to resize the .vdi file.

But the problem persists. What did you see in my errors that made you think I would need to pad the image?

would have me checking the host's logs for evidence of read/write issues as well.