First of all I must say I am a newbie in this fascinating world of LEDE so I apologize just in case I writing any stupidity or nonsense idea.
Well, after read Using storage devices and Extroot configuration and check that I was be able extend the root filesystem of my Linksys WRT160NL, automatic mount included, I wondered whether it would not be better to use LVM, especially when the router has only one USB port as is my case. And here I am, sharing my experience and asking for help because I have been able to do almost process except auto mount of overlay
logical volume.
Yes I know, the Linksys WRT160NL is an old router but I had it and I think it's enough to learn LEDE.
The goal
Set up a USB storage device for
- expand the firmware space of the router
- create a swap space
- create a storage space for file sharing
using logical volume manager (LVM).
The environment
These are the logical volumes to create.
- Volume Group:
sandisk
- Logical Volume:
swap
- 64MiB (2 x 32MiB) - Locical Volume:
overlay
- 128MiB - Logical Volume:
cifs
- 2048MiB
- Logical Volume:
The actions
jabberwock:~ tabad$ ssh root@192.168.10.1
root@192.168.10.1's password:
BusyBox v1.25.1 () built-in shell (ash)
_________
/ /\ _ ___ ___ ___
/ LE / \ | | | __| \| __|
/ DE / \ | |__| _|| |) | _|
/________/ LE \ |____|___|___/|___| lede-project.org
\ \ DE /
\ LE \ / -----------------------------------------------------------
\ DE \ / Reboot (17.01.4, r3560-79f57e422d)
\________\/ -----------------------------------------------------------
These firsts steps have been taken from Using storage devices documentation.
I am starting updating the list of available packages.
root@LEDE:~# opkg update
Afterwards I am installing the kernel support for USB Mass Storage devices (kmod-usb-storage
package) and USB devices listing utilities (usbutils
package)
root@LEDE:~# opkg install kmod-usb-storage usbutils
Installing kmod-usb-storage (4.4.92-1) to root...
Installing kmod-scsi-core (4.4.92-1) to root...
Installing usbutils (007-6) to root...
Installing librt (1.1.16-1) to root...
Installing libusb-1.0 (1.0.21-1) to root...
Configuring kmod-scsi-core.
Configuring kmod-usb-storage.
Configuring librt.
Configuring libusb-1.0.
Configuring usbutils.
and I am checking the USB storage device is detected by operating system.
root@LEDE:~# lsusb -t
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
|__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M
root@LEDE:~# ls -l /dev/sd*
brw------- 1 root root 8, 0 Oct 17 19:23 /dev/sda
It seems all is correct. I am installing the block device mounting and checking utilities (block-mount
package) to get more information about block devices.
Without
block-mount
package the configuration sectionfstab
does not exist.root@LEDE:~# uci show fstab uci: Entry not found
root@LEDE:~# opkg install block-mount
Installing block-mount (2017-06-30-bdcb075f-1) to root...
Configuring block-mount.
this file has been obsoleted. please call "/sbin/block mount" directly
Now with
block-mount
package installed the configuration sectionfstab
is present.root@LEDE:~# cat /etc/config/fstab 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' root@LEDE:~# uci show fstab fstab.@global[0]=global fstab.@global[0].anon_swap='0' fstab.@global[0].anon_mount='0' fstab.@global[0].auto_swap='1' fstab.@global[0].auto_mount='1' fstab.@global[0].delay_root='5' fstab.@global[0].check_fs='0'
Now, I am trying to get more information about the /dev/sda
storage device
root@LEDE:~# block info | grep /dev/sda
root@LEDE:~#
but no information is shown. That is because /dev/sda
is empty, it has not any partition table defined. It is time to configure /dev/sda
but for that I need the GPT partition table manipulation utility (gdisk
package).
root@LEDE:~# opkg install gdisk
Installing gdisk (1.0.1-1) to root...
Installing libstdcpp (5.4.0-1) to root...
Installing libuuid (2.29.2-1) to root...
Installing libpopt (1.16-1) to root...
Configuring libstdcpp.
Configuring libuuid.
Configuring libpopt.
Configuring gdisk.
Once that gdisk
is installed I am going to create a new partition with the complete size of the device for the physical volume.
root@LEDE:~# gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.1
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help):
Even though
gdisk
has created a new partition, I'm going to delete it to start from scratch.
Command (? for help): x
Expert command (? for help): z
About to wipe out GPT on /dev/sda. Proceed? (Y/N): Y
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
Blank out MBR? (Y/N): Y
root@LEDE:~#
root@LEDE:~# gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.1
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-31266782, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-31266782, default = 31266782) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8e00
Changed type of partition to 'Linux LVM'
Command (? for help): p
Disk /dev/sda: 31266816 sectors, 14.9 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): D6C966E5-4910-46A3-B153-0DAD0F38D94A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 31266782
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 31266782 14.9 GiB 8E00 Linux LVM
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.
All is ready to create the sandisk
volume group. To create it first I need the LVM2 userspace toolset (lvm2
package).
root@LEDE:~# opkg install lvm2
Installing lvm2 (2.02.165-1) to root...
Installing kmod-crypto-hash (4.4.92-1) to root...
Installing kmod-crypto-null (4.4.92-1) to root...
Installing kmod-crypto-aead (4.4.92-1) to root...
Installing kmod-crypto-pcompress (4.4.92-1) to root...
Installing kmod-crypto-manager (4.4.92-1) to root...
Installing kmod-dm (4.4.92-1) to root...
Installing libdevmapper (2.02.165-1) to root...
Installing libblkid (2.29.2-1) to root...
Installing libreadline (7.0-1) to root...
Installing terminfo (6.0-1) to root...
Installing libncurses (6.0-1) to root...
Configuring terminfo.
Configuring kmod-crypto-hash.
Configuring kmod-crypto-null.
Configuring kmod-crypto-aead.
Configuring kmod-crypto-pcompress.
Configuring kmod-crypto-manager.
Configuring kmod-dm.
Configuring libdevmapper.
Configuring libblkid.
Configuring libreadline.
Configuring libncurses.
Configuring lvm2.
File descriptor 3 (/tmp/lock/opkg.lock) leaked on lvm invocation. Parent PID 3308: /bin/sh
Reading all physical volumes. This may take a while...
File descriptor 3 (/tmp/lock/opkg.lock) leaked on lvm invocation. Parent PID 3308: /bin/sh
Well, I am creating the physical volume
root@LEDE:~# pvcreate --yes /dev/sda1
Physical volume "/dev/sda1" successfully created.
and the volume group sandisk
.
root@LEDE:~# vgcreate --physicalextentsize 16M --yes sandisk /dev/sda1
Volume group "sandisk" successfully created
Now is the turn of logical volumes.
root@LEDE:~# lvcreate --size 64M --name swap sandisk
Logical volume "swap" created.
root@LEDE:~# lvcreate --size 128M --name overlay sandisk
Logical volume "overlay" created.
root@LEDE:~# lvcreate --size 2048M --name cifs sandisk
Logical volume "cifs" created.
root@LEDE:~# lvscan
ACTIVE '/dev/sandisk/swap' [64.00 MiB] inherit
ACTIVE '/dev/sandisk/overlay' [128.00 MiB] inherit
ACTIVE '/dev/sandisk/cifs' [2.00 GiB] inherit
root@LEDE:~# lvdisplay | egrep '(---|LV (Name|UUID|Size))' -
--- Logical volume ---
LV Name swap
LV UUID 3TxG1p-2MxX-htV6-Z4mo-R2Zq-IeHU-O2nxWn
LV Size 64.00 MiB
--- Logical volume ---
LV Name overlay
LV UUID mOieBO-cTRS-y2xu-CRDo-f6DO-UlFb-lVRM8z
LV Size 128.00 MiB
--- Logical volume ---
LV Name cifs
LV UUID AsHiwm-1JRe-DjrJ-9ZyR-1Qox-nZuO-PzS2W3
LV Size 2.00 GiB
root@LEDE:~# vgdisplay | egrep '(---|VG (Name|UUID|Size))' -
--- Volume group ---
VG Name sandisk
VG Size 14.91 GiB
VG UUID XhRNZd-9rch-xt6t-lXlt-vlkT-OxO7-fQAwHS
root@LEDE:~# pvdisplay | egrep '(---|(PV|VG) (Name|UUID|Size))' -
--- Physical volume ---
PV Name /dev/sda1
VG Name sandisk
PV Size 14.91 GiB / not usable 1.98 MiB
PV UUID d0zv8P-VSSE-vQdE-upLJ-NFYz-49PB-K1CzyN
For the filesystems other than swap I am going to use Flash-Friendly File System (F2FS) so I will need the f2fs-tools
and kmod-fs-f2fs
packages.
root@LEDE:~# opkg install f2fs-tools kmod-fs-f2fs
Installing f2fs-tools (1.8.0-3) to root...
Installing libf2fs (1.8.0-3) to root...
Installing mkf2fs (1.8.0-3) to root...
Installing f2fsck (1.8.0-3) to root...
Installing kmod-fs-f2fs (4.4.92-1) to root...
Configuring libf2fs.
Configuring mkf2fs.
Configuring f2fsck.
Configuring f2fs-tools.
Configuring kmod-fs-f2fs.
Well, It seems all is ready to create the filesystems.
root@LEDE:~# mkswap -L swap /dev/sandisk/swap
Setting up swapspace version 1, size = 67104768 bytes
root@LEDE:~# mkfs.f2fs -l overlay /dev/sandisk/overlay
F2FS-tools: mkfs.f2fs Ver: 1.8.0 (2017-02-03)
Info: Debug level = 0
Info: Label = overlay
Info: Trim is enabled
...
...
Info: format successful
root@LEDE:~# mkfs.f2fs -q -l cifs /dev/sandisk/cifs
1.264C532000060715103220
root@LEDE:/# block info
/dev/mtdblock2: UUID="b9987b6c-6483eae0-ddc9a928-146c8265" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"
/dev/mtdblock3: MOUNT="/overlay" TYPE="jffs2"
/dev/sda1: UUID="d0zv8P-VSSE-vQdE-upLJ-NFYz-49PB-K1CzyN" TYPE="LVM2_member"
/dev/mapper/sandisk-cifs: UUID="b9b5f909-58ee-428c-9c74-e425730e1aad" VERSION="1.8" TYPE="f2fs"
/dev/mapper/sandisk-overlay: UUID="89eda2a9-f0b0-4e27-8bca-04d0870445fd" VERSION="1.8" TYPE="f2fs"
/dev/mapper/sandisk-swap: LABEL="swap" VERSION="1" TYPE="swap"
Once the file systems are created I am going configure the fstab section to test their auto-mount at boot time.
root@LEDE:/# 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 '/mnt/sda1'
option uuid 'd0zv8P-VSSE-vQdE-upLJ-NFYz-49PB-K1CzyN'
option enabled '0'
config 'mount'
option target '/mnt/sandisk-cifs'
option uuid 'b9b5f909-58ee-428c-9c74-e425730e1aad'
option enabled '0'
config 'mount'
option target '/mnt/sandisk-overlay'
option uuid '89eda2a9-f0b0-4e27-8bca-04d0870445fd'
option enabled '0'
config 'swap'
optiondevice'/dev/mapper/sandisk-swap'
optionenabled'0'
root@LEDE:/# block detect > /etc/config/fstab
root@LEDE:/# uci show fstab
fstab.@global[0]=global
fstab.@global[0].anon_swap='0'
fstab.@global[0].anon_mount='0'
fstab.@global[0].auto_swap='1'
fstab.@global[0].auto_mount='1'
fstab.@global[0].delay_root='5'
fstab.@global[0].check_fs='0'
fstab.@mount[0]=mount
fstab.@mount[0].target='/mnt/sda1'
fstab.@mount[0].uuid='d0zv8P-VSSE-vQdE-upLJ-NFYz-49PB-K1CzyN'
fstab.@mount[0].enabled='0'
fstab.@mount[1]=mount
fstab.@mount[1].target='/mnt/sandisk-cifs'
fstab.@mount[1].uuid='b9b5f909-58ee-428c-9c74-e425730e1aad'
fstab.@mount[1].enabled='0'
fstab.@mount[2]=mount
fstab.@mount[2].target='/mnt/sandisk-overlay'
fstab.@mount[2].uuid='89eda2a9-f0b0-4e27-8bca-04d0870445fd'
fstab.@mount[2].enabled='0'
fstab.@swap[0]=swap
fstab.@swap[0].device='/dev/mapper/sandisk-swap'
fstab.@swap[0].enabled='0'
Even though
block detect
detects it, there is not sense to mount/dev/sda1
because it is a physical volume.
root@LEDE:/# uci delete fstab.@mount[0]
Note that after delete a section the other ones are re-indexed.
root@LEDE:/# uci set fstab.@mount[0].enabled='1'
root@LEDE:/# uci set fstab.@mount[1].enabled='1'
root@LEDE:/# uci set fstab.@swap[0].enabled='1'
root@LEDE:/# uci changes fstab
-fstab.cfg044d78
fstab.cfg064d78.enabled='1'
fstab.cfg084d78.enabled='1'
fstab.cfg0a2640.enabled='1'
root@LEDE:/# uci commit fstab
root@LEDE:/# mkdir /mnt/sandisk-{overlay,cifs}
root@LEDE:~# reboot
root@LEDE:~# packet_write_wait: Connection to 192.168.10.1 port 22: Broken pipe
jabberwock:~ tabad$ ssh root@192.168.10.1
root@192.168.10.1's password:
BusyBox v1.25.1 () built-in shell (ash)
_________
/ /\ _ ___ ___ ___
/ LE / \ | | | __| \| __|
/ DE / \ | |__| _|| |) | _|
/________/ LE \ |____|___|___/|___| lede-project.org
\ \ DE /
\ LE \ / -----------------------------------------------------------
\ DE \ / Reboot (17.01.4, r3560-79f57e422d)
\________\/ -----------------------------------------------------------
root@LEDE:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 2.3M 2.3M 0 100% /rom
tmpfs 13.8M 72.0K 13.7M 1% /tmp
/dev/mtdblock3 4.1M 3.0M 1.1M 73% /overlay
overlayfs:/overlay 4.1M 3.0M 1.1M 73% /
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mapper/sandisk-cifs
2.0G 188.0M 1.8G 9% /mnt/sandisk-cifs
/dev/mapper/sandisk-overlay
126.0M 50.0M 62.0M 45% /mnt/sandisk-overlay
root@LEDE:~# swapon -s
Filename Type Size Used Priority
/dev/mapper/sandisk-swap partition 65532 0 -1
Now that everything seems to be going well, I'm going to configure extroot.
These lasts steps have been taken from Extroot configuration documentation.
root@LEDE:~# uci set fstab.@mount[1].target='/overlay'
root@LEDE:~# uci commit fstab
root@LEDE:~# tar -C /overlay -cf - . | tar -C /mnt/sandisk-overlay -xf -
root@LEDE:~# umount /mnt/sandisk-overlay/
root@LEDE:~# mount /dev/mapper/sandisk-overlay /overlay
root@LEDE:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 2.3M 2.3M 0 100% /rom
tmpfs 13.8M 1.0M 12.8M 7% /tmp
/dev/mtdblock3 126.0M 60.0M 52.0M 54% /overlay
overlayfs:/overlay 4.1M 3.5M 640.0K 85% /
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mapper/sandisk-cifs
2.0G 188.0M 1.8G 9% /mnt/sandisk-cifs
/dev/mapper/sandisk-overlay
126.0M 60.0M 52.0M 54% /overlay
It seems extroot works sucessfuly. Now /overlay
has 52MiB of free space instead of 1.1MiB.
root@LEDE:~# reboot
root@LEDE:~# packet_write_wait: Connection to 192.168.10.1 port 22: Broken pipe
The problem
After reboot I am hoping the logical volume overlay
be mounted over /overlay
directory at boot time automatically, but this not happens.
jabberwock:~ tabad$ ssh root@192.168.10.1
root@192.168.10.1's password:
BusyBox v1.25.1 () built-in shell (ash)
_________
/ /\ _ ___ ___ ___
/ LE / \ | | | __| \| __|
/ DE / \ | |__| _|| |) | _|
/________/ LE \ |____|___|___/|___| lede-project.org
\ \ DE /
\ LE \ / -----------------------------------------------------------
\ DE \ / Reboot (17.01.4, r3560-79f57e422d)
\________\/ -----------------------------------------------------------
root@LEDE:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 2.3M 2.3M 0 100% /rom
tmpfs 13.8M 324.0K 13.4M 2% /tmp
/dev/mtdblock3 4.1M 3.5M 620.0K 85% /overlay
overlayfs:/overlay 4.1M 3.5M 620.0K 85% /
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mapper/sandisk-cifs
2.0G 188.0M 1.8G 9% /mnt/sandisk-cifs
root@LEDE:~# swapon -s
Filename Type Size Used Priority
/dev/mapper/sandisk-swap partition 65532 0 -1
The logical volume overlay
has not been mounted at boot time over /overlay
directory. Does anybody know why?. Please, could you help me?