What's new

How would you go about syncing/symlinking root home folder to entware drive during system operation?

  • 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!

domic

Regular Contributor
basically I have personal settings that get written to
Code:
/root/*
, which is a symlink to
Code:
/tmp/home/root/
We know that on system shutdown, everything on /tmp gets wiped, and lost, including personal config files.

I wish to have all
Code:
/root/*
files stored to
Code:
/opt/root/
instead (/opt itself is a symlink to
Code:
/tmp/mnt/<entware-usb-device-name>/entware/
), so that my personal settings are persistent between reboots/shutdowns etc.

Of course, ideally such an option should be included for AMTM/Entware users upon installation, but that's its own topic for upstream.
 
If you're asking specifically about interactive terminal sessions you can put the new HOME variable in /opt/etc/profile which is sourced from /etc/profile. Alternatively you could put it in /jffs/configs/profile.add but that can be problematic if you log in before the Entware drive is mounted.
 
If you're asking specifically about interactive terminal sessions you can put the new HOME variable in /opt/etc/profile which is sourced from /etc/profile. Alternatively you could put it in /jffs/configs/profile.add but that can be problematic if you log in before the Entware drive is mounted.
No, I wish to always have it set up.
 
Can you describe an example scenario that's causing you the problem.
Sure. I can't store command history between reboots, my fish_config theme/prompt settings too. And most settings one wishes for in a convenient setup that's found in /root/* (hidden dot files/folders included).
 
Sure. I can't store command history between reboots, my fish_config theme/prompt settings too. And most settings one wishes for in a convenient setup that's found in /root/* (hidden dot files/folders included).
So this is interactive sessions. Just set the HOME environment variable as I described. I've just tested this and it works. I don't know anything about fish_config but a quick scan of this page suggests it's no different.
 
I did a quick test running
Code:
ln -s /opt/root/ -T /tmp/home/root

Do you think it would run into any problems if I added this script to "/jffs/scripts/post-mount"?
Code:
# The two commands below removes empty startup /tmp/home/root (/root) directory
# and replaces it with a symbolic link that is stored in /opt/root (entware USB storage root directory's respective root user home folder)

rm -rf /tmp/home/root
ln -s /opt/root/ -T /tmp/home/root

The idea is that it changes after entware software stack is mounted and launched, and runs before any SSH users are connected.
The rm command should delete old symlinks at the same time.

But if I choose to use the $HOME variable instead, can I do it in the post-mount file instead?
 
Hm, I tested adding
Code:
export HOME=/opt/root
to either profile files you suggested and rebooted, but I still connect to /tmp/home/root/ in SSH

(I still haven't tried adding my script)
 
The idea is that it changes after entware software stack is mounted and launched, and runs before any SSH users are connected.
I'd guess it would probably work. It would depend on exactly how your Entware installation is setup and what (if any) services you're running. I have my own custom Entware installation so I can't comment much more on that.

If you want home directory changes to apply globally to Entware services (e.g. vnstatd) your change should be done before they are started not after.

But if I choose to use the $HOME variable instead, can I do it in the post-mount file instead?
No. SSH sessions don't have any connection to the post-mount script, that's what /etc/profile and /opt/etc/profile are for. The profile is run for each user when it logs in. If Entware is already mounted is will get the new HOME variable. If it's not mounted it won't.
 
My bad, I meant to say $HOME is redirected to "/opt/root" now, but my SSH sessions still default to /tmp/home/root.
I was thinking about if I maybe should change /etc/passwd so the "admin" user home directory is set to "/opt/root", but I don't know if that will survive reboots or is not recommended.
 
My bad, I meant to say $HOME is redirected to "/opt/root" now, but my SSH sessions still default to /tmp/home/root.
That's because /etc /passwd hasn't changed. After you log in type cd ~ and you'll see it'll change to the new home directory. Your command history should automatically be going to this directory.
 
Does this help?


(it's how I learned to make my /home/root folder persistent on the USB stick used for Entware)
 
On a good note, fish_config settings seem to persist reboots, and I have a command history now too. <3
 
Similar threads
Thread starter Title Forum Replies Date
U Faster syncing ntp on router Asuswrt-Merlin 2

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

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