Temp to disable/cancel the usb drive overlay

I want to temp to disable/umount the usb drive overlay extension, the fstab config mount option 0, after rebooted, the usb drive space is still mounted.

what is the best way to cancel/disable the overlay usb drive?

root@OpenWrt:/etc/config# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 3.8M      3.8M         0 100% /rom
tmpfs                    59.0M     20.9M     38.1M  35% /tmp
/dev/sda1                 3.6G     63.1M      3.3G   2% /overlay
overlayfs:/overlay        3.6G     63.1M      3.3G   2% /
tmpfs                   512.0K         0    512.0K   0% /dev
root@OpenWrt:/etc/config#
root@OpenWrt:/etc/config# more fstab
config global
        option anon_swap '0'
        option anon_mount '0'
        option auto_swap '1'
        option auto_mount '1'
        option check_fs '0'
        option delay_root '15'

config mount 'rwm'
        option device '/dev/ubi0_1'
        option target '/rwm'
        option enabled '0'

config mount
        option uuid 'be67433e-4442-4e0f-82f8-0e75d0650534'
        option target '/overlay'
        option enabled '0'
 
root@OpenWrt:/etc/config# block detect
config 'global'
        option  anon_swap       '0'
        option  anon_mount      '0'
        option  auto_swap       '1'
        option  auto_mount      '1'
        option  delay_root      '5'
        option  check_fs        '0'

config 'mount'
        option  target  '/overlay'
        option  uuid    'be67433e-4442-4e0f-82f8-0e75d0650534'
        option  enabled '0'

root@OpenWrt:/etc/config#

If you have your extroot overlay mounted and then change the fstab config, you are changing the fstab config on the mounted extroot, which will have no effect since it is not the config responsible for mounting the extroot in the first place.

To disable extroot you have to mount the original rootfs and change the original fstab config there.

2 Likes

I'm a newbie, is it to follow the following steps and perform a reboot? Thanks.

DEVICE="$(sed -n -e "/\s\/overlay\s.*$/s///p" /etc/mtab)"
uci -q delete fstab.rwm
uci set fstab.rwm="mount"
uci set fstab.rwm.device="${DEVICE}"
uci set fstab.rwm.target="/rwm"
uci commit fstab 

Yes, although a reboot should not be necessary, a simple

block mount

would probably suffice to get the fstab mounts mounted. The rest is described in the link.

It still reminds the same,

root@OpenWrt:/etc/config#
root@OpenWrt:/etc/config# DEVICE="$(sed -n -e "/\s\/overlay\s.*$/s///p" /etc/mtab)"
root@OpenWrt:/etc/config# uci -q delete fstab.rwm
root@OpenWrt:/etc/config# uci set fstab.rwm="mount"
root@OpenWrt:/etc/config# uci set fstab.rwm.device="${DEVICE}"
root@OpenWrt:/etc/config# uci set fstab.rwm.target="/rwm"
root@OpenWrt:/etc/config# uci commit fstab
root@OpenWrt:/etc/config# block mount
block: /dev/sda1 is already mounted on /overlay
root@OpenWrt:/etc/config# 

The above commands don't turn off the extroot. Once an extroot is enabled it is, to all intents and purposes, not possible to turn it off again.

What the commands do is mount the original root filesystem into a directory so you can access and edit it, even after an extroot replaced the original root filesystem (which is the purpose of the extroot after all). As the instructions say, you can then

edit /rwm/upper/etc/config/fstab to change your extroot configuration (or temporarily disable it)

After you edit the original fstab configuration and set enabled to 0 in that manner, then you need to reboot, and the extroot will be disabled.

1 Like

I have still had no luck removing the USB drive overlay extension, in the event of a user needing to change the new drive.

I think sudo would help with it, however, the sudo isn't in the box and it is to make a router more secure by using the non-priv user by default.

I understand your frustration, but "doesn't work" (or its smaller cousin "no luck") is rather little to go on and help you further. What did you try, what was the effect? Was the original overlay filesystem properly mounted, i.e. can you access /rwm, can you edit /rwm/upper/etc/config/fstab?

Nope, you're barking up the completely wrong tree there. By default, the only user on OpenWrt is the all-powerful root. Sudo will not give you any further rights than that.

I mean if you're desperate to disable the overlay, there's always the sledgehammer version: remove the USB drive before the router starts up. No extroot to mount results in no extroot being mounted.

My current /rwm has nothing in the folder, but I located the fstab file in the /etc/config folder.

root@OpenWrt:/rwm# ls -al
drwxr-xr-x    2 root     root          4096 Oct  4 02:59 .
drwxr-xr-x    1 root     root          4096 Oct  4 02:59 ..
root@OpenWrt:/rwm#
root@OpenWrt:~# more /etc/config/fstab
config global
        option anon_swap '0'
        option anon_mount '0'
        option auto_swap '1'
        option auto_mount '1'
        option check_fs '0'
        option delay_root '15'

config mount
        option uuid 'be67433e-4442-4e0f-82f8-0e75d0650534'
        option target '/overlay'
        option enabled '0'

config mount 'rwm'
        option device '/dev/sda1'
        option target '/rwm'

If the extroot overlay is mounted, then that is the version on the overlay, i.e. useless for your purposes.

That is most definitely not the correct path to the rootfs overlay in flash memory. And I don't think it is necessarily your fault, the script on the wiki page is supposed to run before the usb extroot is mounted at startup, i.e. when setting up the extroot. After the extroot is created and running, it does nothing.

I would suggest that you pull your USB drive before starting your router, therefor not initializing the extroot, and then run the script in the instructions again. This should then create the necessary mount and mount it at startup before everything is handed over to the extroot.