Looking for tutorial for extroot, /mnt, /overlay, etc


#1

I never quite figured out how Linux files systems relate to the underlying hardware. I see references to the terms below, but can't really tell how they fit together.

  • extroot
  • /mnt
  • /overlay
  • /dev/mtdblock3
  • USB drivers
  • where opkg saves its files
  • other "storage-related" terms

I see many "extroot tutorials" on the internet and on the LEDE & OpenWrt sites, but don't quite understand if they are going to work for me.

Specifically, here's my question:

  • I'm using YAMon to collect traffic statistics from my router
  • It currently writes to a 4GByte USB stick that I installed using the USB Quick Start, then configured its mount point to /opt.
  • I have run out of space to install new packages, and I have read that setting up an extroot will make more space available to opkg.
  • I'm willing to blow away any data collected by YAMon (and re-install it) in order to share the USB stick between it and the opkg data

My questions:

  1. Can anyone point to a good tutorial that explains the relationship between the items in the list above?
  2. I frequently see the following steps: what do each of the commands do?
    mount /dev/sda1 /mnt ; tar -C /overlay -cvf - . | tar -C /mnt -xf - ; umount /mnt
  3. What is a good procedure for giving opkg more space on the USB stick?

Many thanks.


#2
  1. Can anyone point to a good tutorial that explains the relationship between the items in the list above?
    All the tutorials I know about are those in the OpenWrt's and LEDE's wiki...

  2. I frequently see the following steps: what do each of the commands do?
    mount /dev/sda1 /mnt ; tar -C /overlay -cvf - . | tar -C /mnt -xf - ; umount /mnt

  • Mount the /dev/sda1 filesystem at /mnt
  • Copy (preserving all parameters) all files from the old overlay to the new overlay at /mnt
  • Un-mount the /dev/sda1 filesystem from /mnt
  1. What is a good procedure for giving opkg more space on the USB stick?
    AFAIK, extroot overlay is the best (the only?) option.

#3

This post from @angelos helped me, Hopefully it will help you too

Edit:
Misread your question I thought you wanted to create USB extroot, that link does not explain the meanings you wanted.


#4

Thanks for these responses. Yes, I'd like a tutorial/explainer for the concepts for how this stuff works. Links to other docs (even generic Linux docs) are fine - I just haven't found any...

Also, I didn't phrase my third question quite right... I realize I'll probably need to set up a extroot, but I also want to install YAMon on that USB storage. The question should say,

Thanks.


#5

I don't have any great links off hand, but if you wanted to read a book on the subject, I think this book is quite a good introduction to the general concepts. Embedded Linux by Craig Hollabaugh


#6

@richb-hanover Feel free to create two partitions on the USB drive:

  1. extroot partition
  2. user-partition to store any stuff you like

#7

LEDE on embeded devices with low flash it uses two filesystems.
one is SquashFs, that allow to put tight all the ROM part, that is basically the firmware.
and when it boot for first time it put the initial configuration files on OverlayFS, this is the freespace portion of the flash...
usually you have 8mb of flash, 3.8mb is ROM, and the rest if available for OverlayFS.

OverlayFS as the name indicate is a "overlay" is on-top of the ROM filesystem, if you try to change a file existing in ROM, it will created an entry with that same file on the same path on Overlay in "upper" location.
if delete that file it wil be set a special flag indicating that the file does not exist, (overlay will hide the existence of the file in ROM)... if you delete a file from the upper it will bring back again the ROM version of the file.

mtdblock3 it points to the 3rd "partition" of the mtd, imagine that is like a partition on a hardrive, but just in flash, usually there is the ROM if I am not wrong.

/mnt is commonly by-choice location to mount filesystems (additional to the root one) like USB drive, etc...

extroot is the term for define that the system will use an external root filesystem instead of the bootloader defined one, OpenWRT and LEDE boots to a main ROM with a root filesystem, and in the process it look for a configured extroot (external root) on the fstab table or config file, as the system reads from /overlay and not directly from ROM, then the fstab entry it says /overlay on path.

USB drivers are needed, on LEDE, the system is so so tight and small some things like usb drivers (for the hardware part) and block storage (software part) both are needed to be installed to be able to set up correctly the extroot.

opkg saves it files on /overlay... as well al changes done to any file on the system. (ROM as the name intends is Read Only Memory, the only way to modify the ROM is that you build a new image for the device and flash/sysupgrade it again (overlayFS part will be copied to RAM temporary in order to re-adjust the usage of that freespace location)

please tell me what are your other "storage-related" terms that you need help about.

If you only need some space just for saving file you should mount additional USB stick like you already do, in /opt or even better in the common choice location of /mnt... you create your mount point there, example /mnt/usb-stick
if you need to install more packages and you don't have enough space you NEED to use extroot.

the tar command that you describe is very common, we use tar because it preserves well filesystem metadata like dates, permissions, etc....

Basically the process of extroot explained is this:

You should put and storage location like a usb drive...
use dmesg and logread to see if it was detected, install usb and block storage packages, install ext4 or f2fs packages.
set up your partitions on the usb drive, usually one uses 2 or 3... one for extroot, one for swap (if it is needed) and the rest for data storage not related to the system (example your YAMon statistics crap)
depending on your need you could use 100-500mb for system, that would be more than necesary since even if you installl a lot of packages you never gonna consume more than that.
you format your extroot partition, mount temporary and perform the tar command and unmount...
set up fstab mount entry (you could test it rebooting )... if it works well, change the mount point path to /overlay.
when you reboot you should be able to see more free space on the device when running df -Th

Hope it clarifies a little more the info about.


#8

An extroot replaces both /rom and /overlay with a writeable (usually ext4) filesystem on the external drive. The files in the internal flash are accessed only during boot until the extroot is mounted. During the process of setting up an extroot, the entire existing filesystem with your configuration and installed packages is copied to the external drive.

A package is basically a tarfile. The files it contains will be placed in several places in the filesystem as appropriate. Typical locations are /sbin (binaries and scripts) /lib (libraries) and /etc (configurations). With internal flash, any additional files added under / are in the jffs /overlay. With external root they are simply in the ext4, merging with the copy of /rom made when the extroot was set up.

The opkg files command will show the files installed by a package and their location. The package must be installed first.


#9

Hi folks, All these explanations are incredibly helpful.

I'm going to go away now and write this out in my own words to see if I can convince myself that I understand it. Once I have something, I'll come back to the forum to see how you all grade me :slight_smile: Thanks again.


#10

The best way to understand and learn is to try and experiment hands on...
I recommend you to buy some TP-Link router Lede capable with USB port and learn just doing it.
If you need help let me know I could dig up in my notes, I had hundred of text files with steps to do different things.


#11

That's a good plan. Thanks!


#12

basically you copy files to a usb storage you have formatted and change the /etc/config/fstab for the desired boot format, if you have all the proper modules installed should be a piece of cake. fstab = file system table, so whatever you have that set as, is what the operating system mounts and configures. Understanding how the system is configured is a good starting point for both windows and linux this is a good read.


#13

I already know well these devices all with USB ports, all work very well with LEDE.
it reads: CPU clock speed, flash size, and ram size:

WDR3600 V1.x 560mhz	8mb	128mb, gigabit, two usb, dual band, 2 antenna
WDR4300 V1.x 560mhz	8mb	128mb, gigabit, two usb, dual band, 3 antenna
WR842ND V2.1  535mhz	8mb	32mb, 2 antena
MR3020 400mhz?	4mb	32mb, small, button and 3 positions slider
MR3040 400mhz?	4mb	32mb, portable, 3 positions slider, battery
WR1043ND V1.x  400mhz	8mb	32mb, gigabit, 3 antena
WR1043ND V2.x 720mhz	8mb	64mb, gigabit, 3 antena
# there is too but I didn't tested it:
WR1043ND V3.x 720mhz	8mb	64mb, gigabit, 3 antena
WR1043ND V4.x 720mhz	16mb	64mb, gigabit, 3 antena

If you need a full powered go with the WDR4300 or WDR3600, nowadays it is usefull to have a 5Ghz capable router, since there is too much 2.4Ghz congestion in very populated areas, if you need something cheap and well made go for WR1043.
If you want to do one or two test and leave as as a cheap home router later, pick the WR842ND, if you need something for your backpack or purse, pick the MR3020, the mr3040 is has a battery, but is usually expensive and it is just useful if you want to conceal somewhere. it does not have the useful button of the mr3020, but at least has the slider, that button is useful, you could capture the press event and trigger things, the other desktop router also have multipurpose button too (originary intended for wps).
WDR4300 tend to get their ethernet switch chipset circuit broken (I had 3 with that problem it just work their wifi). WDR3600 support well ONE usb notebook size harddrive connected (there is no enough current for two)... there is a hardware hack to have that I alredy tested on mr3020.
There is other LEDE hardware capable that you can find, but I recommend you to read some time about it on Internet before you acquire it in order to choice one better for your needs.

Hope it helps you to decide.


#14

Do you guys, what is the best for an overlay? Is a stick is good for like swap, backup and the more stuff or just go for a USB3 HDD? What is the best?


#15

@patrikx3 -- as this is off topic, would you open a new thread for your question?


#16

A stick should be enough but try to use a well known brand like Sandisk or Kingston and be sure that is an original stick in order to be fast and reliable. A USB3 HDD could work but keep in mind that your device should be able to supply the needed current for the drive... Sometimes writings stall and fail becouse of this problems. USB HDD or SSD should only be used if you want them to act as a NAS.


#17

thanks for the answer!