Friday, May 12, 2017

Lede Extroot Configuration


Extroot configuration

How to use a storage device (usb or sata or sdcard or whatever) to expand your LEDE device's space in root filesystem, to install freely all the packages you need.
In most supported devices, the LEDE firmware splits the internal storage in two partitions, a highly-compressed read-only partition which is the actual root filesystem (/), the second partition is writable, called “overlay” (/overlay).
The overlay partition is merged with the root filesystem using the overlayfs feature of linux kernel, showing a single “whole” read-write filesystem to applications.
This way LEDE fits even in tiny amounts of internal storage (as low as 4 MiB), but still allows to write settings and install some packages in the writable partition without changing all linux programs used.
Extroot works by setting another overlay partition in the external storage device, and during boot this new overlay partition will be mounted over the internal storage's overlay partition. This approach allows easy fallback in case the external storage device is removed, as your LEDE device will still have its own overlay partition and thus will load all configuration from there.
Which means that it will behave exactly the same as just before you set up extroot.
These devices should have enough space to install the packages we need. Remove all packages you have installed to add functionality, as they are only wasting space now. After you made the extroot you will have all space you need.
From the command line interface write (on a single line):
opkg update && opkg install block-mount  kmod-fs-f2fs kmod-usb-storage mkf2fs f2fsck kmod-usb-ohci kmod-usb-uhci fdisk
On TL-1043ND v2 due to errors on F2FS extroot, router started freezing up. Running fsck.f2fs from f2fstools 1.7.0 on ar71xx corrupts valid f2fs partitions. For ar71xx with 8MiB or more flash, use ext4 for extroot instead.
opkg update && opkg install block-mount kmod-fs-ext4 kmod-usb-storage e2fsprogs kmod-usb-ohci kmod-usb-uhci fdisk
Connect with ssh to the device.
See what partitions you have:
root@lede:/# block info 
/dev/mtdblock2: UUID="9fd43c61-c3f2c38f-13440ce7-53f0d42d" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"
/dev/mtdblock3: MOUNT="/overlay" TYPE="jffs2"
/dev/sda1: UUID="fdacc9f1-0e0e-45ab-acee-9cb9cc8d7d49" VERSION="1.4" TYPE="f2fs"
here we see mtdblock devices (partitions in internal flash memory), and a partition on /dev/sda1 that is on a usb flash drive (in the example it is already formatted as f2fs)
We now first format the external drive as f2fs or ext4.
For f2fs:
root@lede:/# mkfs.f2fs /dev/sda1
For ext4:
root@lede:/# mkfs.ext4 /dev/sda1
Then we transfer the content of the current overlay inside the external drive
root@lede:/# mount /dev/sda1 /mnt ; tar -C /overlay -cvf - . | tar -C /mnt -xf - ; umount /mnt
Now we create automatically the fstab uci subsystem and fill it with the right configuration to have /dev/sda1 as new overlay
root@lede:/# block detect > /etc/config/fstab; \
   sed -i s/option$'\t'enabled$'\t'\'0\'/option$'\t'enabled$'\t'\'1\'/ /etc/config/fstab; \
   sed -i s#/mnt/sda1#/overlay# /etc/config/fstab; \
   cat /etc/config/fstab;
 
If you have a swap partition it will also get recognized and added automatically.
let's try manually mounting to see if everything is OK
root@lede:/# mount /dev/sda1 /overlay 
now we see mount point sizes:
root@lede:/# df 
this is an example output:
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                     896       244       652  27% /
/dev/root                 2048      2048         0 100% /rom
tmpfs                    14708        64     14644   0% /tmp
/dev/mtdblock6         7759872    477328   7221104   6% /overlay
overlayfs:/overlay         896       244       652  27% /
tmpfs                      512         0       512   0% /dev
/dev/sda1              7759872    477328   7221104   6% /overlay
Note that only /overlay has grown but not the /
  1. Reboot the router
  2. Verify that the partitions were mounted properly:
    • via LuCI
      • System - Software should show free space of overlay partition
      • System - Mount Points should show USB partition mounted as overlay
    • via CLI
      • mount should show USB partition mounted as /overlay
root@lede:~# mount
/dev/root           on /rom               type squashfs (ro,relatime)
proc                on /proc              type proc     (rw,noatime)
sysfs               on /sys               type sysfs    (rw,noatime)
tmpfs               on /tmp               type tmpfs    (rw,nosuid,nodev,noatime)
/dev/mtdblock6      on /overlay           type jffs2    (rw,noatime)
overlayfs:/overlay  on /                  type overlay  (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs               on /dev               type tmpfs    (rw,relatime,size=512k,mode=755)
devpts              on /dev/pts           type devpts   (rw,relatime,mode=600)
/dev/sda1           on /overlay           type ext4     (rw,relatime,data=ordered)
/dev/sda3           on /data              type ext4     (rw,relatime,data=ordered)
debugfs             on /sys/kernel/debug  type debugfs  (rw,noatime)
  • df should show free space available on your /overlay and / partition, all the storages mounted to /overlay and / (the rootfs in the first place) should look the same increased capacity:
root@lede:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                 7759872    477328   7221104   6% /
/dev/root                 2048      2048         0 100% /rom
tmpfs                    14708        64     14644   0% /tmp
/dev/mtdblock6         7759872    477328   7221104   6% /overlay
overlayfs:/overlay     7759872    477328   7221104   6% /
tmpfs                      512         0       512   0% /dev
/dev/sda1              7759872    477328   7221104   6% /overlay
/dev/sda3            242846048    163864 230323224   0% /data

Lede Extroot Configuration Rating: 4.5 Diposkan Oleh: Rumah Minimalis

0 komentar: