1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

Router reboot cause deletion of root folder

Discussion in 'Asuswrt-Merlin' started by mr_radar, Oct 9, 2019.

  1. mr_radar

    mr_radar New Around Here

    Joined:
    Jul 19, 2019
    Messages:
    7
    Hi,

    I noticed a strange behaviour of my router (ASUS RT-AC86U). When I reboot the router all the files I installed in /tmp/home/root are getting deleted...

    This is a very very strange behaviour...

    I dot not understand why the files in the root folder are not persistent. It is even worse it does not make sense to me ? Am I missing something specific to that type of device ?

    I will really appreciate your answers :)

    Cheers,

    PS : ASUS RT-AC86U, FW 384.11_2
    FYI, I created this ZSH version adapted for Asus router, you can read more about it here :
    https://www.snbforums.com/threads/install-oh-my-zsh-on-asus-routers.57662/
     
  2. dave14305

    dave14305 Very Senior Member

    Joined:
    May 19, 2018
    Messages:
    1,231
    /tmp/home/root is RAM-based. Expected behavior. Only /jffs or a USB will survive a reboot.
     
    mr_radar likes this.
  3. mr_radar

    mr_radar New Around Here

    Joined:
    Jul 19, 2019
    Messages:
    7
    Ok, now I understand the loss of my files. It makes sense. Thank you dave14305.

    Questions :
    - Is there a way to keep my files in the root folder permanently (I have my ZSH config there)
    - Why is the unix asus firmware built that way ? I don't see the point...

    Thanks :)
     
  4. ColinTaylor

    ColinTaylor Part of the Furniture

    Joined:
    Mar 31, 2014
    Messages:
    9,452
    Location:
    UK
    You could probably create a startup script that copied your files from a non-volatile location (like /jffs) to the appropriate directory.
    https://github.com/RMerl/asuswrt-merlin/wiki/User-scripts

    Because it's not Unix, it's a network appliance with an embedded operating system built around a Linux kernel. It's not designed to be a desktop or server system that people log into. The only reason you're able to create persistent scripts on it is because Merlin modified the code to do something it was never designed to do.
     
  5. Ronald Schwerer

    Ronald Schwerer Senior Member

    Joined:
    Jan 8, 2017
    Messages:
    362
    Keep the file(s) you want to persist in a subdirectory of /jffs. Then in your startup script, create symbolic links in /home/root that point back to the actual files.
    I do this to retain my /home/root/.ssh directory (public and private keys). This is better than copying the files each time since it will also persist any modifications.
     
    ColinTaylor likes this.
  6. Ronald Schwerer

    Ronald Schwerer Senior Member

    Joined:
    Jan 8, 2017
    Messages:
    362
    No, I am running stock ASUS firmware. Not as versatile as Merlin, but it still allows running basic sh scripts for housekeeping.
     
  7. cmkelley

    cmkelley Very Senior Member

    Joined:
    Aug 11, 2015
    Messages:
    910
    Location:
    Greater Los Angeles Area, California, USizicstania
    If you're posting here and using zsh I assume you are using Asuswrt-Merlin with a usb drive and have entware installed.

    My solution is to have the following in jffs/scripts/post-mount:
    Code:
    rm -rf /tmp/home/root
    ln -s /opt/root /tmp/home/root
    
    and so all of root is persistent, including my shell history. :)
     
    Ronald Schwerer and ColinTaylor like this.
  8. ColinTaylor

    ColinTaylor Part of the Furniture

    Joined:
    Mar 31, 2014
    Messages:
    9,452
    Location:
    UK
    My point was that Asus' firmware is not designed for users to log in and run their own scripts like they would on a desktop operating system. They are expected to use the GUI. That is why if you do SSH into it the environment is different from a typical Linux distro.
     
  9. dosborne

    dosborne Senior Member

    Joined:
    May 11, 2019
    Messages:
    216
    Location:
    /dev/null
    On any Linux based O/S, never count on /tmp files being persistent through a reboot. It is the whole premise behind having a temporary directory.

    Anything you want to persist should be configured to use another location, or worst case, some good ideas already posted.
     
  10. mr_radar

    mr_radar New Around Here

    Joined:
    Jul 19, 2019
    Messages:
    7
    Now I do understand what is going on and how to "fix" my problem.

    I was actually thinking of using the ln command (link).

    I am going to try and tell you what fits more considering my situation (ZSH+Oh-My-ZSH).

    Thank you all of you for quick and quality replies :)