What's new

Router reboot cause deletion of root folder

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

mr_radar

New Around Here
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/
 
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 :)
 
- Is there a way to keep my files in the root folder permanently (I have my ZSH config there)
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

- Why is the unix asus firmware built that way ? I don't see the point...
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.
 
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.
 
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.
No, I am running stock ASUS firmware. Not as versatile as Merlin, but it still allows running basic sh scripts for housekeeping.
 
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/
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. :)
 
No, I am running stock ASUS firmware. Not as versatile as Merlin, but it still allows running basic sh scripts for housekeeping.
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.
 
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.
 
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 :)
 
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. :)


I would love to do this, but I have stock and no /jffs/scripts folder altogether.. Do you have any idea in which file this needs to go for stock? Many thanks.
 
Somebody told me to use this in /jffs/scripts/postmount:

Code:
[ -d "$1/home/root" ] && mount -o bind $1/home/root /home/root
ln -nsf /home/root /home/$(nvram get http_username)

Of course this requires Asuswrt-Merlin as well...
 
Somebody told me to use this in /jffs/scripts/postmount:
Code:
[ -d "$1/home/root" ] && mount -o bind $1/home/root /home/root
ln -nsf /home/root /home/$(nvram get http_username)
Of course this requires Asuswrt-Merlin as well...

Merlin install was a breeze - thank you for suggesting it.. And it does solve lots of the script problems.
 
Somebody told me to use this in /jffs/scripts/postmount:

Code:
[ -d "$1/home/root" ] && mount -o bind $1/home/root /home/root
ln -nsf /home/root /home/$(nvram get http_username)

Of course this requires Asuswrt-Merlin as well...

Can you share the step-by-step instructions to overcome SSH login issue after adding that piece of code to post-mount? Asking for a noob friend of mine? :D
 
Can you share the step-by-step instructions to overcome SSH login issue after adding that piece of code to post-mount? Asking for a noob friend of mine? :D
Sorry what's the SSH login issue? You mean passwordless logins?
 
Sorry what's the SSH login issue? You mean passwordless logins?
After adding that code to post-mount, I am not able to login to router via SSH, regardless of how I login (keys or username/password). It throws me out with the error "Permission denied (publickey)".
 
I did the other piece of code.
#! /bin/sh
/bin/rm -Rf /tmp/home/root
/bin/ln -s /tmp/mnt/2TBEXTERNAL/root /tmp/home/root

That works for me, of course ensure that your drive name is replaced from above..
I suggest you do a factory reset. Not being able to login is really crippling..
 
After adding that code to post-mount, I am not able to login to router via SSH, regardless of how I login (keys or username/password). It throws me out with the error "Permission denied (publickey)".
I also suffered from this when ownership/permissions were not right for files in /root.

I fixed it back then by doing this:
Code:
chown -R admin /root/
chmod -R go-rwx /root/
 
I also suffered from this when ownership/permissions were not right for files in /root.
I fixed it back then by doing this:
Code:
chown -R admin /root/
chmod -R go-rwx /root/

"admin" needs to be the name you gave to the router when you were first configuring it..
If you chose "turgut" as the admin user (and you should :D) then it needs to be like this..
# ls -ld /root
lrwxrwxrwx 1 turgut root 13 Apr 5 18:55 root -> tmp/home/root
# ls -l /tmp/home
drwxrwxrwx 1 turgut root 25 Apr 19 18:10 root

therefore it would need to be
chown -R turgut:root /root
chown -R turgut:root /tmp/home/root

...in that case.
 
Last edited:

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top