User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:public:extroot [2017/04/25 15:55] (current)
grief created
Line 1: Line 1:
 +====== Rootfs on External Storage (extroot) ======
 +As TurrisOS is a fork of OpenWrt, most of the principles of OpenWrt are applicable to TurrisOS. Extroot is one of them.
 +===== What is extroot? =====
 +Almost every router has a small amount of persistent memory. Turris Omnia has 8 GB of storage but [[https://​forum.turris.cz/​t/​why-is-var-on-tmpfs/​1327/​4|developers say]] that this storage was not designed to be heavily used for read/write. Sometimes it can be an issue, for example if it is needed to:
 +  - Have permanent ''/​var''​ directory instead of symbolic link to ''/​tmp''​
 +  - Install more than 8 GB of software but don't want to alter ''​opkg''​ target installation pathes
 +  - Use software that requires a lot of read/write operations to the root filesystem but don't want to damage the internal memory.
  
 +There are several workarounds which involve creating symbolic links from the router'​s internal filesystem to the one which is mounted from USB device. But there is a choice which might be more convenient and reliable in some cases: **extroot**.
 + 
 +In OpenWrt there is a possibility to replace the root filesystem which is located in the internal memory with the one from external device during the boot. Original instructions for OpenWrt to achieve that can be found [[https://​wiki.openwrt.org/​doc/​howto/​extroot|here]].
 +
 +===== How to do extroot on Turris Omnia =====
 +
 +**If you fail, there is a possibility to soft-brick your device, so please do the backups! If you failed and router doesn'​t boot, please follow [[en:​howto:​omnia_factory_reset|these]] instructions.**
 +
 +  - USB device is needed, make sure it is working. If it is a hard drive, check that is has enough power from USB port to work and check its cable.
 +  - At least one partition on the USB device must be empty. One of the partitions will be used for extroot and will be mounted as ''/''​ (root). Others can be used for any custom mounts including swapping.
 +  - **Extroot only supports Ext4**, so if you have a partition of other type, use ''​mkfs.ext4''​ to re-format the partition.
 +  - Please stop all non-core activities like torrent client, DLNA server, Samba server etc.
 +  - Clone the internal filesystem to the external device. For example, if the device appeared as ''​sda1'':​ <​code>​
 +mkdir -p /​tmp/​introot
 +mkdir -p /​tmp/​extroot
 +mount --bind / /​tmp/​introot
 +mount /dev/sda1 /​tmp/​extroot
 +tar -C /​tmp/​introot -cvf - . | tar -C /​tmp/​extroot -xf -
 +umount /​tmp/​introot
 +umount /​tmp/​extroot
 +</​code>​
 +  - In LuCI, navigate to System → Mount Points → Add.
 +    - Check ''​Enable this mount''​.
 +    - Choose your external USB device from ''​UUID''​ combo box.
 +    - Choose ''​Use as root filesystem (/​)''​ from ''​Mount point''​ combo box.
 +    - Hit ''​SAVE & APPLY''​
 +  - Now configuration should look similar to this: <​code>​
 +# 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 uuid '​1f0e8e00-b854-49d2-97ee-4b57bdaccb1d'​
 +        option target '/'​
 +        option enabled '​1'​
 +</​code>​
 +  - Copy ''/​etc/​config/​fstab''​ to the external filesystem: <​code>​
 +mount /dev/sda1 /​tmp/​extroot
 +cp /​etc/​config/​fstab /​tmp/​extroot/​etc/​config/​fstab
 +umount /​tmp/​extroot
 +</​code>​
 +  - Cross the fingers and reboot.
 +  - After reboot, mounts should look like that:<​code>​
 +# mount
 +/​dev/​mmcblk0p1 on /rom type btrfs (ro,​noatime,​ssd,​space_cache,​commit=X,​subvolid=ABC,​subvol=/​@)
 +...
 +/dev/sda1 on / type ext4 (rw,​relatime,​data=ordered)
 +...
 +</​code>​
 +  - From now all your data would be stored on the external drive. You can find the internal root filesystem mounted to ''/​rom''​. ​
 +
 +===== Notes =====
 +  - I'd recommend to keep essential files like the contents of ''/​etc/​config''​ in sync between extroot and internal memory. I cannot say for sure at which exact moment the internal memory is replaced with the external one. It has to be ''​ /​etc/​rc.d/​S40fstab'',​ so scripts with level less then 40 have to be loaded from internal memory while the others - from the external storage. Since ''/​rom''​ is obviously is read-only, to copy changed files from the extroot to internal memory, you'd have to remount it for read/write: <​code>​mount /rom -o remount,​rw</​code>​
 +  - Please be aware that ''​schnapps''​ most probably will stop to work with extroot or will work with errors. It uses Btrfs snapshot feature to work but Brtfs is not supported by extroot. If you can shed some light on that, please update this article.
 +  - You can now make ''/​var''​ permanent (reboot required): <​code>​
 +cp -r /tmp /var-tmp
 +rm /var
 +mv /var-tmp /var
 +</​code>​