Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Install r29570 on TP-Link MR3220 v1
- # Login with telnet, change root password, login with SSH
- # Install packages to support extroot
- opkg update
- opkg install kmod-usb-storage kmod-fs-ext4 block-mount fdisk e2fsprogs swap-utils
- # Wipe existing partition table from USB memory stick
- dd if=/dev/zero of=/dev/sda bs=64k count=1
- # Partition USB memory stick with 64M swap, 256M root and rest as third partition
- cat | fdisk /dev/sda <<__EOF__
- n
- p
- 1
- 1
- +64M
- t
- 82
- n
- p
- 2
- +256M
- n
- p
- 3
- w
- q
- __EOF__
- # Should look like this
- root@OpenWrt:~# fdisk -l /dev/sda
- Disk /dev/sda: 4206 MB, 4206886912 bytes
- 130 heads, 62 sectors/track, 1019 cylinders
- Units = cylinders of 8060 * 512 = 4126720 bytes
- Disk identifier: 0xcb85d70e
- Device Boot Start End Blocks Id System
- /dev/sda1 1 17 68479 82 Linux swap / Solaris
- /dev/sda2 18 80 253890 83 Linux
- /dev/sda3 81 1019 3784170 83 Linux
- # Create swap and filesystems, also set unique label in addition to automatically generated uuid
- mkswap /dev/sda1 -L ow_swap_`dd if=/dev/urandom bs=1k count=1|tr -dc "a-f0-9"|cut -c1-6`
- mkfs.ext3 /dev/sda2 -L ow_root_`dd if=/dev/urandom bs=1k count=1|tr -dc "a-f0-9"|cut -c1-6`
- mkfs.ext3 /dev/sda3 -L ow_data_`dd if=/dev/urandom bs=1k count=1|tr -dc "a-f0-9"|cut -c1-6`
- # Check label and uuid with blkid command
- root@OpenWrt:~# blkid
- /dev/mtdblock2: TYPE="squashfs"
- /dev/sda1: TYPE="swap" LABEL="ow_swap_53bdb3" UUID="3ebd4c59-fffd-47b5-b598-136ff740a20f"
- /dev/sda2: LABEL="ow_root_f479b3" UUID="0b4dfe19-3f7d-4579-983c-452ed9e4bc83" SEC_TYPE="ext2" TYPE="ext3"
- /dev/sda3: LABEL="ow_data_8505fb" UUID="a6ca6666-7639-4825-9eee-727718affd19" SEC_TYPE="ext2" TYPE="ext3"
- # Configure swap to be enabled on next boot
- /etc/init.d/fstab stop
- uci delete fstab.@swap[0]
- uci commit fstab
- uci add fstab swap
- # Works with /dev/sda1 as device
- #uci set fstab.@swap[-1].device=/dev/sda1
- # Fails with label
- #uci set fstab.@swap[-1].label=`blkid -s LABEL /dev/sda1 | cut -d\" -f2`
- # Fails with uuid
- uci set fstab.@swap[-1].uuid=`blkid -s UUID /dev/sda1 | cut -d\" -f2`
- uci set fstab.@swap[-1].enabled=1
- uci commit fstab
- # Configure extroot to be mounted on next boot
- uci delete fstab.@mount[0]
- uci commit fstab
- uci add fstab mount
- # Works with /dev/sda2 as device
- #uci set fstab.@mount[-1].device=/dev/sda2
- # Fails with label
- #uci set fstab.@mount[-1].label=`blkid -s LABEL /dev/sda2 | cut -d\" -f2`
- # Fails with uuid
- uci set fstab.@mount[-1].uuid=`blkid -s UUID /dev/sda2 | cut -d\" -f2`
- uci set fstab.@mount[-1].options=rw,sync,noatime
- uci set fstab.@mount[-1].fstype=ext3
- uci set fstab.@mount[-1].enabled_fsck=1
- uci set fstab.@mount[-1].enabled=1
- uci set fstab.@mount[-1].target=/
- # or with target=/overlay if using overlay mode
- uci commit fstab
- # Configure data partition to be mounted on next boot
- mkdir -p /mnt/data
- uci add fstab mount
- # Works with /dev/sda3 as device
- #uci set fstab.@mount[-1].device=/dev/sda3
- # Fails with label
- #uci set fstab.@mount[-1].label=`blkid -s LABEL /dev/sda3 | cut -d\" -f2`
- # Fails with uuid
- uci set fstab.@mount[-1].uuid=`blkid -s UUID /dev/sda3 | cut -d\" -f2`
- uci set fstab.@mount[-1].options=rw,sync,noatime
- uci set fstab.@mount[-1].fstype=ext3
- uci set fstab.@mount[-1].enabled_fsck=1
- uci set fstab.@mount[-1].enabled=1
- uci set fstab.@mount[-1].target=/mnt/data
- uci commit fstab
- # Disable anon mount feature
- uci set fstab.automount.anon_mount=0
- uci commit fstab
- # Resulting /etc/config/fstab
- root@OpenWrt:~# cat /etc/config/fstab
- config 'global' 'automount'
- option 'from_fstab' '1'
- option 'anon_mount' '0'
- config 'global' 'autoswap'
- option 'from_fstab' '1'
- option 'anon_swap' '0'
- config 'swap'
- option 'uuid' '3ebd4c59-fffd-47b5-b598-136ff740a20f'
- option 'enabled' '1'
- config 'mount'
- option 'uuid' '0b4dfe19-3f7d-4579-983c-452ed9e4bc83'
- option 'options' 'rw,sync,noatime'
- option 'fstype' 'ext3'
- option 'enabled_fsck' '1'
- option 'enabled' '1'
- option 'target' '/'
- config 'mount'
- option 'uuid' 'a6ca6666-7639-4825-9eee-727718affd19'
- option 'options' 'rw,sync,noatime'
- option 'fstype' 'ext3'
- option 'enabled_fsck' '1'
- option 'enabled' '1'
- option 'target' '/mnt/data'
- # Populate new rootfs with content of existing rootfs
- mkdir -p /mnt/sda2 /tmp/cproot
- mount --bind / /tmp/cproot
- mount /dev/sda2 /mnt/sda2
- tar -C /tmp/cproot -cvf - . | tar -C /mnt/sda2 -xf -
- sync; umount /mnt/sda2 ; umount /tmp/cproot
- # Activate extroot on next boot
- /etc/init.d/fstab enable
- /etc/init.d/fstab start
- /etc/init.d/fstab whole_root_enable
- # or if using overlay mode
- #/etc/init.d/fstab overlay_enable
- # Reboot router
- reboot
- # Login and check mounts after restart
- # Looks like extroot is not working but data partition was properly mounted with uuid
- root@OpenWrt:~# df -h
- Filesystem Size Used Available Use% Mounted on
- rootfs 1.5M 848.0K 688.0K 55% /
- /dev/root 1.5M 1.5M 0 100% /rom
- tmpfs 14.4M 64.0K 14.3M 0% /tmp
- tmpfs 512.0K 0 512.0K 0% /dev
- /dev/mtdblock3 1.5M 848.0K 688.0K 55% /overlay
- overlayfs:/overlay 1.5M 848.0K 688.0K 55% /
- /dev/sda2 240.1M 12.0M 215.7M 5% /tmp/whole_root-disabled
- /dev/sda3 3.6G 71.3M 3.3G 2% /mnt/data
- # Check that uuid's are still in place with blkid
- root@OpenWrt:~# blkid
- /dev/mtdblock2: TYPE="squashfs"
- /dev/sda1: TYPE="swap" LABEL="ow_swap_53bdb3" UUID="3ebd4c59-fffd-47b5-b598-136ff740a20f"
- /dev/sda2: LABEL="ow_root_f479b3" UUID="0b4dfe19-3f7d-4579-983c-452ed9e4bc83" SEC_TYPE="ext2" TYPE="ext3"
- /dev/sda3: LABEL="ow_data_8505fb" UUID="a6ca6666-7639-4825-9eee-727718affd19" SEC_TYPE="ext2" TYPE="ext3"
- # Swap seems to be enabled
- root@OpenWrt:~# free
- total used free shared buffers
- Mem: 29436 17936 11500 0 2244
- -/+ buffers: 15692 13744
- Swap: 68472 0 68472
- # Switch from uuid's to device names
- uci delete fstab.@swap[-1].uuid
- uci set fstab.@swap[-1].device=/dev/sda1
- uci delete fstab.@mount[0].uuid
- uci set fstab.@mount[0].device=/dev/sda2
- uci delete fstab.@mount[1].uuid
- uci set fstab.@mount[1].device=/dev/sda3
- uci commit
- # Resulting /etc/config/fstab
- root@OpenWrt:~# cat /etc/config/fstab
- config 'global' 'automount'
- option 'from_fstab' '1'
- option 'anon_mount' '0'
- config 'global' 'autoswap'
- option 'from_fstab' '1'
- option 'anon_swap' '0'
- config 'swap'
- option 'enabled' '1'
- option 'device' '/dev/sda1'
- config 'mount'
- option 'options' 'rw,sync,noatime'
- option 'fstype' 'ext3'
- option 'enabled_fsck' '1'
- option 'enabled' '1'
- option 'target' '/'
- option 'device' '/dev/sda2'
- config 'mount'
- option 'options' 'rw,sync,noatime'
- option 'fstype' 'ext3'
- option 'enabled_fsck' '1'
- option 'enabled' '1'
- option 'target' '/mnt/data'
- option 'device' '/dev/sda3'
- # Re-enable extroot
- /etc/init.d/fstab enable
- /etc/init.d/fstab start
- /etc/init.d/fstab whole_root_enable
- # Reboot
- reboot
- # Login and check if extroot is working
- # Yes, seems to work now.
- root@OpenWrt:~# df -h
- Filesystem Size Used Available Use% Mounted on
- rootfs 240.1M 12.0M 215.7M 5% /
- /dev/root 1.5M 1.5M 0 100% /rom
- tmpfs 14.4M 60.0K 14.3M 0% /tmp
- tmpfs 512.0K 0 512.0K 0% /dev
- /dev/sda2 240.1M 12.0M 215.7M 5% /
- /dev/sda3 3.6G 71.3M 3.3G 2% /mnt/data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement