OpenWrt - Filesystem on a USB stick

Filesystem on a USB stick (Rootfs on External Storage / extroot) first we need to install basic USB support for EXT4 and FAT32 formatted USB sticks

root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install kmod-usb-storage block-mount kmod-fs-ext4 kmod-fs-vfat
kmod-nls-cp437 kmod-nls-cp850 kmod-nls-iso8859-1 kmod-nls-iso8859-15 kmod-scsi-core
e2fsprogs fdisk
check if the USB stick was recognized
root@OpenWrt:~# ls /dev/sd*
you should see one or more devices like sda1, sdb1, sdb2, … partition the USB stick
root@OpenWrt:~# fdisk
Command (m for help): m (displays actions)
Command (m for help): p (display partition table)
Command (m for help): d (delete partion - had only 1 on my stick)
Command (m for help): n (new partition)
Command action
e extended
p primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-621, default 1): RETURN
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-nnnn, default nnn):
Command (m for help): a (make partition bootable) RETURN
Partition number (1-4): 1 Command (m for help): w (write to disk)
format USB stick with ext4 filesystem
root@OpenWrt:~# mkfs.ext4 /dev/sda1
mount the USB stick and copy the flash /overlay to the USB stick
root@OpenWrt:~# mkdir -p /mnt/usb
root@OpenWrt:~# mount -t vfat /dev/sda1 /mnt/usb
root@OpenWrt:~# tar -C /overlay -cvf - . | tar -C /mnt/usb -xvf -
root@OpenWrt:~# vi /etc/config/fstab
the ‘config mount’ block should look like this
config 'mount'
        option target   /overlay
        option device   /dev/sda1
        option fstype   ext4
        option options  rw,sync
        option enabled  1
        option enabled_fsck 0
restart the router and check if everything’s ok
root@OpenWrt:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                 1962212     65100   1798716   3% /
/dev/root                 1536      1536         0 100% /rom
tmpfs                    14600        72     14528   0% /tmp
tmpfs                      512         0       512   0% /dev
/dev/sda1              1962212     65100   1798716   3% /overlay
overlayfs:/overlay     1962212     65100   1798716   3% /