Double mount points

OK. First problem solved, it was obvious, the issue was from the double mount points. I removed the USB stick, and now I can get online. So, can someone please help me understand why I get double mounts on the USB stick and how to fix it? As you see below, I have overlay on it.

Second question. I have a USB configured but even after reboot, it mounts twice. As seen here:

You help is highly appreciated. Thanks a lot for your considered response(s).

Do you mean the same free space showing for both /overlay and / ?

That is normal. Overlayfs takes a RO volume (/dev/root) and a RW volume (/overlay) and constructs a RW volume with changes stored in the RW volume. The available space reported is always that of the RW volume.

It is curious that you are showing /dev/sda disabled but mounted. That is likely because boot process reads the internal overlay /etc/config/fstab so you have to manually mount it and change that version to change the overlay. ( or boot with no USB and change ).

If you did reboot without USB and get behavior you want then you may want to re-initialize the USB with data from internal overlay:

@djadair yes, David, and thanks for the education. now i go to the rest of your help.

@djadair I did. I used a combination of help, your link, and this one, https://codebeta.com/pentest-lab-part-1-openwrt-with-extroot-f00ba4b6ffd5 to make the Extroot. Based on my steps below, which one should I now use to 're-initialize' the USB. A lot of work went into this and I don't want to ruin it all. So I'm just looking for exact guide that I will use and later study:

opkg update
#indentify rootfs_data:
grep -e rootfs_data /proc/mtd
# Show partitions:
block info
# Plug USB stick formatted to ext4 in router
#In Terminal issue
mount /dev/sda /mnt
# In Luci, click on “Generate Config” to have a ‘Mount Points’ created, seen below the page
# Click on “Edit” and Select “Enabled” and click “Save” then “Save and Apply”
# Run these in Terminal
eval $(block info ${DEVICE} | grep -o -e "UUID=\S*")
uci -q delete fstab.overlay
uci set fstab.overlay="mount"
uci set fstab.overlay.uuid="${UUID}"
uci set fstab.overlay.target="/overlay"
uci commit fstab
reboot
#Login via ssh
block detect > /etc/config/fstab
#Edit the fstab file with:
nano /etc/config/fstab
#Then change “target” and “enabled” on the USB stick portion of the file to:
config 'mount'
       option  target  '/overlay' (this may already be there)
       option  uuid    '01234567-89AB-CDEF-1234-567890ABCDEF'
       option  enabled '1' (but this was not)
Then issue:
/etc/init.d/fstab enable
# Reboot
# To check if the USB stick is being used as storage after reboot in Terminal issue:
df -h
# Results should be:
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 2.5M      2.5M         0 100% /rom
tmpfs                    60.8M     72.0K     60.8M   0% /tmp
/dev/sda                 14.6G     48.4M     13.8G   0% /overlay (note overlay is on USB stick)
overlayfs:/overlay       14.6G     48.4M     13.8G   0% /
tmpfs                   512.0K         0    512.0K   0% /dev
# Similarly this command “uci show fstab” shows that the “/overlay” is on USB
fstab.@mount[0]=mount
fstab.@mount[0].target='/overlay'
fstab.@mount[0].uuid='76c4f8ac-71bf-4511-80ed-85a468fd6b65'
fstab.@mount[0].enabled='1'

I have only used 21.02 and master so that seems correct but complicated. ( looks like it has 3 ways to do same thing: Luci, uci, nano/vi -- you only need one).

However it skips "Step 4 Transferring data" so the result will be a fresh factory config without any of your existing setup.
What I do:

  • Boot without USB.
  • Hotplug USB and use Luci to enable it as overlay
  • copy data
# create new FS on flash if required.  See wiki but you must already have one.
mkdir /tmp/new
# Use your device
mount /dev/sda /tmp/new
# get rid of existing data
rm -rf /tmp/new/*
# copy internal -> new
cp -f -a /overlay/. /tmp/new
# make sure data actually written
sync
umount /tmp/new
reboot

The "grep -e rootfs_data" and block info bits are to make sure you are copying with the correct source and destination -- good advice I ignore at my own risk.

I would personally NEVER run this part:

block detect > /etc/config/fstab

That will wipe out any existing mount configuration for other devices / partitions so it is only safe if you have exactly one partition on one USB. DO not do that after using Luci to configure mounts.