faruktezcan / openwrt-ram-root

Extroot using ramfs with backup&restore option
6 stars 2 forks source link

openwrt-ram-root

Extroot using tmpfs with backup&restore option

Introduction:

+++++++++++++

-If you have a router without a USB port, it is very likely that, with more intense usage of your router, you will need more disk space and/or you may want to test new software or config options or upgrade package(s) without changing your original setup to see everyting works properly.

-These can be achieved by creating a ram drive (tmpfs/zram) in your router's memory and using it as your new storage space. With this option, you can install and test new packages beyond your flash drive’s capacity to see how they work. As soon as you reboot the router, it will go back to your former state.

-The ability of saving your ram drive in a local/remote directory and restoring it back to your router is also given to you as an option.

-If you want to install packages that should NOT be included in your backup, you can define them in the config file. These packages will be installed automatically each time you start ram-root operation. Otherwise, all the packages that you install and/or other changes that you make will be saved by making a backup.

-Example 1: If you have another router or computer which is always reachable by your router and you want to use that remote device for backups, then start the 'ram-root' process and install the packages and set them up accordingly. Make a backup when you are satisfied with the changes. When you reboot the router next time and start the 'ram-root' process again, everything will be restored back to your router. If your device has enough flash capacity to save the backup file, in this case, you can use it for backups.

-Example 2: Lets assume your router's flash capacity is very limited and you do not have another device for backups. By defining 'PRE_PACKAGES' in the config file you can install them on-the-fly during ram-root process. If you change the configuration later, making a backup includes only those changes not the packages you defined. With that, you are saving your flash drive's capacity. The penalty, in this case, is that those packages have to be installed next time if you reboot the router.

-Installing optional 'zram-swap' is highly adviced as this provides you approx. 50% more memory capacity.

-For further explanation/investigation please check the self-explanatory config file.

Installation:

+++++++++++++

-Download the provided ‘zip’ file and extract 'ram-root' directory to root directory ( '/' ) of your device.

-After the extraction you should have a new directory named ‘/ram-root’.

-You should make some changes additionally in the ‘config’ file according to your needs before running the script for the 1st time.

-Install optional 'e2fsprogs kmod-fs-ext4 kmod-zram zram-swap' packages considering you have enough flash drive space.

-The script will check your router's ( and, maybe backup unit's) setup and will make the required changes automatically.

How to use: +++++++++++

Notes:

++++++

If the packages < e2fsprogs kmod-fs-ext4 kmod-zram > are installed before running ram-root, the ram device will be stored on a zram disk which uses approximately half the memory compared to < tmpfs >. This means that, you can have twice the disk capacity while consuming the same amount of memory.

You can enable the autorun option by entering '/etc/init.d/ram-root enable' command to boot your router through the 'ram-root', if you can make sure that everything works quite nicely.

The previous state of the router is mounted under '/old-root'. You can simply switch to that directory, make changes to your base system and reboot.

Included scripts in 'tools' directory:

++++++++++++++++++++++++++++++++++++++

'opkgclean.sh' : Cleans unsuccesful installation attempt debris due to flash storage shortage

'opkgdeps.sh' : Lists all dependant packages for the given package

'opkgupgrade.sh' : Upgrades whole system packages interactively

'overlaypkgs.sh' : Saves user-installed packages before upgrade and restore them later.

'ssh-copy-id' : Copies your ssh credentials to the remote device for easier ssh connections.

'zram-status' : Shows the zram drive statistics.