OpenWRT extroot - and multiple configuration profile.
My GL-MT300A has 16GB mmc card installed inside. So I decided to create three swap-able extroots. That way, I can use various configuration "profiles", as well as have a "fail-back" configuration. First I partitioned my mmc card in the following way:
root@OpenWrt:~# fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 14.5 GiB, 15560867840 bytes, 30392320 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x080b255d
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 1050623 1048576 512M 83 Linux
/dev/mmcblk0p2 1050624 2099199 1048576 512M 83 Linux
/dev/mmcblk0p3 2099200 3147775 1048576 512M 83 Linux
/dev/mmcblk0p4 3147776 30392319 27244544 13G 83 Linux
root@OpenWrt:~# fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 14.5 GiB, 15560867840 bytes, 30392320 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x080b255d
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 1050623 1048576 512M 83 Linux
/dev/mmcblk0p2 1050624 2099199 1048576 512M 83 Linux
/dev/mmcblk0p3 2099200 3147775 1048576 512M 83 Linux
/dev/mmcblk0p4 3147776 30392319 27244544 13G 83 Linux
Then I've formatted all four partitions:
root@OpenWrt:~# mkfs.ext4 -L MMC1 /dev/mmcblk0p1
root@OpenWrt:~# mkfs.ext4 -L MMC1 /dev/mmcblk0p1
root@OpenWrt:~# mkfs.ext4 -L MMC2 /dev/mmcblk0p2
root@OpenWrt:~# mkfs.ext4 -L MMC3 /dev/mmcblk0p3
root@OpenWrt:~# mkfs.ext4 -L MMC4 /dev/mmcblk0p4
root@OpenWrt:~# blkid
/dev/mtdblock5: TYPE="squashfs"
/dev/mmcblk0: PTUUID="080b255d" PTTYPE="dos"
/dev/mmcblk0p1: LABEL="MMC1" UUID="11111111-1111-1111-1111-111111111111" TYPE="ext4" PARTUUID="88888888-01"
/dev/mmcblk0p2: LABEL="MMC2" UUID="22222222-2222-2222-2222-222222222222" TYPE="ext4" PARTUUID="88888888-02"
/dev/mmcblk0p3: LABEL="MMC3" UUID="33333333-3333-3333-3333-333333333333" TYPE="ext4" PARTUUID="88888888-03"
/dev/mmcblk0p4: LABEL="MMC4" UUID="44444444-4444-4444-4444-444444444444" TYPE="ext4" PARTUUID="88888888-04"
mkdir /mnt/mmc1 /mnt/mmc2 /mnt/mmc3 /mnt/mmc4
Then I mounted all FS to be able to create a copy of default /overlay:
root@OpenWrt:/etc/config# 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'
config 'mount'
option target '/mnt/mmc1'
option label 'MMC1'
option fstype 'ext4'
option options 'noatime,nodiratime'
config 'mount'
option target '/mnt/mmc2'
option label 'MMC2'
option fstype 'ext4'
option options 'noatime,nodiratime'
config 'mount'
option target '/mnt/mmc3'
option label 'MMC3'
option fstype 'ext4'
option options 'noatime,nodiratime'
config 'mount'
option target '/mnt/mmc4'
option label 'MMC4'
option fstype 'ext4'
option options 'noatime,nodiratime'
After reboot, I've cloned /overlay:
root@OpenWrt:~# tar -C /overlay -cvf - . | tar -C /mnt/mmc1 -xf -
root@OpenWrt:~# tar -C /overlay -cvf - . | tar -C /mnt/mmc1 -xf -
And finally modified a banner a bit:
root@OpenWrt:~# echo "Boot from /dev/mtdblock6" >> /etc/banner
root@OpenWrt:~# echo "Boot from /dev/mtdblock6" >> /etc/banner
root@OpenWrt:~# cp /rom/etc/banner /mnt/mmc1/upper/etc/
root@OpenWrt:~# echo "Boot from MMC1" >> /mnt/mmc1/upper/etc/banner
Last step is change MMC1 target in fstab to /overlay
Results:
root@OpenWrt:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 2.0M 2.0M 0 100% /rom
tmpfs 61.4M 76.0K 61.3M 0% /tmp
/dev/mmcblk0p1 487.9M 3.8M 448.3M 1% /overlay
overlayfs:/overlay 487.9M 3.8M 448.3M 1% /
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mmcblk0p2 487.9M 780.0K 451.3M 0% /mnt/mmc2
/dev/mmcblk0p3 487.9M 780.0K 451.3M 0% /mnt/mmc3
/dev/mmcblk0p4 12.7G 40.0M 12.0G 0% /mnt/mmc4
root@OpenWrt:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 2.0M 2.0M 0 100% /rom
tmpfs 61.4M 76.0K 61.3M 0% /tmp
/dev/mmcblk0p1 487.9M 3.8M 448.3M 1% /overlay
overlayfs:/overlay 487.9M 3.8M 448.3M 1% /
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mmcblk0p2 487.9M 780.0K 451.3M 0% /mnt/mmc2
/dev/mmcblk0p3 487.9M 780.0K 451.3M 0% /mnt/mmc3
/dev/mmcblk0p4 12.7G 40.0M 12.0G 0% /mnt/mmc4
root@OpenWrt:~# mount
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/mmcblk0p1 on /overlay type ext4 (rw,noatime,nodiratime,data=ordered)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600)
/dev/mmcblk0p2 on /mnt/mmc2 type ext4 (rw,noatime,nodiratime,data=ordered)
/dev/mmcblk0p3 on /mnt/mmc3 type ext4 (rw,noatime,nodiratime,data=ordered)
/dev/mmcblk0p4 on /mnt/mmc4 type ext4 (rw,noatime,nodiratime,data=ordered)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/mmcblk0p1 on /overlay type ext4 (rw,noatime,nodiratime,data=ordered)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600)
/dev/mmcblk0p2 on /mnt/mmc2 type ext4 (rw,noatime,nodiratime,data=ordered)
/dev/mmcblk0p3 on /mnt/mmc3 type ext4 (rw,noatime,nodiratime,data=ordered)
/dev/mmcblk0p4 on /mnt/mmc4 type ext4 (rw,noatime,nodiratime,data=ordered)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
Comments
Post a Comment