/root/.bash_profile changes aren't saved after reboot

Discussion on setting up QNAP NAS products.
Post Reply
e-r-a-n
Getting the hang of things
Posts: 77
Joined: Sat May 11, 2013 3:02 am

/root/.bash_profile changes aren't saved after reboot

Post by e-r-a-n » Mon Mar 23, 2015 3:07 am

Hi,
I have made some tweaks and setups on my Qnap T269L:
1. created symbolic links to my /root (~) folder
2. saved those commants to .bash_profile
3. installed nodejs & mongodb from the app repository
4. added some libraries with npm...
5. created a folder for mongodb database, under /root/database/

after a while I had a reboot on my device, and now all those recent changes are missing:

Code: Select all

[~] # node
-sh: node: command not found
[~] # npm
-sh: npm: command not found
[~] # mongod
-sh: mongod: command not found


and ofcourse, /root/database/ isnt there anymore.

Its like, any change I do is removed after a reboot. I tried creating some changes and then do a reboot again, and everything was removed.
I looked at the /share/cached_data1/.qpkg/
nodejs, mongodb are there, and also in /opt/bin/:

Code: Select all

[~] # ls /opt/bin/
2to3*                diffutils-sdiff*     mongoexport@         rcsclean*            unzip-unzip*
bash*                funzip*              mongofiles@          rcsdiff*             unzipsfx*
bzcat@               gunzip@              mongoimport@         rcsmerge*            update-alternatives*
bzip2@               gzexe*               mongorestore@        reset@               zcat@
bzip2-bzip2*         gzip@                mongos@              rlog*                zcmp*
bzip2recover*        gzip-gunzip*         mongostat@           sdiff@               zdiff*
captoinfo@           gzip-gzip*           ncurses-clear*       smtpd-2.7.py*        zegrep*
ci*                  gzip-zcat*           ncurses5-config*     sqlite3*             zfgrep*
clear@               ident*               ncursesw5-config*    sudo*                zforce*
cmp@                 idle-2.7*            node@                sudoedit*            zgrep*
co*                  infocmp*             npm@                 sudoreplay*          zipgrep*
curl*                infotocap@           openssl*             tic*                 zipinfo*
curl-config*         ipkg*                pydoc-2.7*           toe*                 zless*
diff@                ipkg-opt@            python2@             tput*                zmore*
diff3@               merge*               python2-config@      tset*                znew*
diffutils-cmp*       mongo@               python2.7*           uncompress*
diffutils-diff*      mongod@              python2.7-config*    unrar*
diffutils-diff3*     mongodump@           rcs*                 unzip@


But its not even in my PATH..

Code: Select all

[~] # echo $PATH 
/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/sbin:/usr/local/bin


I'd make the change in .bash_profile, to add this folder to my path, but again, the change wont apply after reboot.
I hope someone can help me out.
Thanks!!

User avatar
pwilson
Guru
Posts: 22581
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada (UTC-08:00)

Re: SSH Changes aren't saved after reboot

Post by pwilson » Mon Mar 23, 2015 3:20 am

e-r-a-n wrote:Hi,
I have made some tweaks and setups on my Qnap T269L:
1. created symbolic links to my /root (~) folder
2. saved those commants to .bash_profile
3. installed nodejs & mongodb from the app repository
4. added some libraries with npm...
5. created a folder for mongodb database, under /root/database/

after a while I had a reboot on my device, and now all those recent changes are missing:

Code: Select all

[~] # node
-sh: node: command not found
[~] # npm
-sh: npm: command not found
[~] # mongod
-sh: mongod: command not found


and ofcourse, /root/database/ isnt there anymore.

Its like, any change I do is removed after a reboot. I tried creating some changes and then do a reboot again, and everything was removed.
I looked at the /share/cached_data1/.qpkg/
nodejs, mongodb are there, and also in /opt/bin/:

Code: Select all

[~] # ls /opt/bin/
2to3*                diffutils-sdiff*     mongoexport@         rcsclean*            unzip-unzip*
bash*                funzip*              mongofiles@          rcsdiff*             unzipsfx*
bzcat@               gunzip@              mongoimport@         rcsmerge*            update-alternatives*
bzip2@               gzexe*               mongorestore@        reset@               zcat@
bzip2-bzip2*         gzip@                mongos@              rlog*                zcmp*
bzip2recover*        gzip-gunzip*         mongostat@           sdiff@               zdiff*
captoinfo@           gzip-gzip*           ncurses-clear*       smtpd-2.7.py*        zegrep*
ci*                  gzip-zcat*           ncurses5-config*     sqlite3*             zfgrep*
clear@               ident*               ncursesw5-config*    sudo*                zforce*
cmp@                 idle-2.7*            node@                sudoedit*            zgrep*
co*                  infocmp*             npm@                 sudoreplay*          zipgrep*
curl*                infotocap@           openssl*             tic*                 zipinfo*
curl-config*         ipkg*                pydoc-2.7*           toe*                 zless*
diff@                ipkg-opt@            python2@             tput*                zmore*
diff3@               merge*               python2-config@      tset*                znew*
diffutils-cmp*       mongo@               python2.7*           uncompress*
diffutils-diff*      mongod@              python2.7-config*    unrar*
diffutils-diff3*     mongodump@           rcs*                 unzip@


But its not even in my PATH..

Code: Select all

[~] # echo $PATH 
/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/sbin:/usr/local/bin


I'd make the change in .bash_profile, to add this folder to my path, but again, the change wont apply after reboot.
I hope someone can help me out.
Thanks!!


As part of QNAP's nonstop innovation, the directory /root lives in a RAMDisk, :roll: so all changes made to this directory are lost every time your NAS is restarted/started. :roll:

Check out the Fix the $PATH in /etc/profile section of QNAPedia article: Install Optware IPKG. Changes made via the Optware invocation script can put files back into place across reboots, so simply make your changes there instead.

You can also put these changes in your "autorun.sh" file. Check out QNAPedia article: Running Your Own Application at Startup, especially the MTD-based method section.
Last edited by pwilson on Mon Mar 23, 2015 3:39 am, edited 1 time in total.

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs

Please review: When you're asking a question, please include the following.

e-r-a-n
Getting the hang of things
Posts: 77
Joined: Sat May 11, 2013 3:02 am

Re: /root/.bash_profile changes aren't saved after reboot

Post by e-r-a-n » Mon Mar 23, 2015 3:38 am

I see. Ok, good to know.
Im used to the fact that my home folder of my linux usernames are usually /home/<user>, and its persistent and resilient to reboots.
also, I usually define symlinks and such settings with my /home/<user>/.bash_profile.
How do I Do it in qnap? What is the best approach to define symlinks
Where is it better approach to store data, on my shares, or on qnap local storage?
Where should I define start-up applications, that load on boot?

User avatar
pwilson
Guru
Posts: 22581
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada (UTC-08:00)

Re: /root/.bash_profile changes aren't saved after reboot

Post by pwilson » Mon Mar 23, 2015 3:49 am

e-r-a-n wrote:I see. Ok, good to know.
Im used to the fact that my home folder of my linux usernames are usually /home/<user>, and its persistent and resilient to reboots.
also, I usually define symlinks and such settings with my /home/<user>/.bash_profile.
How do I Do it in qnap? What is the best approach to define symlinks
Where is it better approach to store data, on my shares, or on qnap local storage?
Where should I define start-up applications, that load on boot?


For all users, except "admin", the $HOME directory is actually stored at: /share/homes/<username>.

If you switch to OpenSSH then "admin's" $HOME directory will be at /share/homes/admin. See my previous message thread: Installing OpenSSH as default SSHd Server (but keeping QNAP's SSHD version active as well)

The passwd file directs....:

Code: Select all

grep admin /etc/passwd
admin:x:0:0:administrator:/share/homes/admin:/bin/sh


QNAP's SSHd server does not respect the $HOME field in the passwd file, and makes "/root" the $HOME directory for "admin", irregardless of the settings in the passwd file. :roll: :roll: :roll: :shock:

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs

Please review: When you're asking a question, please include the following.

e-r-a-n
Getting the hang of things
Posts: 77
Joined: Sat May 11, 2013 3:02 am

Re: /root/.bash_profile changes aren't saved after reboot

Post by e-r-a-n » Mon Mar 23, 2015 4:26 am

Is there any benefit in installing OpenSSH, just for having my /share/homes/admin by default when I log in?
or does it allow modification of my .bash_profile for symlinks definitions as well?

User avatar
pwilson
Guru
Posts: 22581
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada (UTC-08:00)

Re: /root/.bash_profile changes aren't saved after reboot

Post by pwilson » Mon Mar 23, 2015 4:36 am

e-r-a-n wrote:Is there any benefit in installing OpenSSH, just for having my /share/homes/admin by default when I log in?
or does it allow modification of my .bash_profile for symlinks definitions as well?


The only advantage, is that it does respect your $HOME directory (at /share/homes/admin), so you can modify files like:

  1. /share/homes/admin/.profile
  2. /share/homes/admin/.bash_profile
  3. /share/homes/admin/.bashrc
  4. /share/homes/admin/.bash_aliases

These files do not live in the RAMDisk, so they will survive all reboots. :DD

This alone should be all the incentive you need to dump QNAP's broken SSHd daemon. (I keep my QNAP SSHd active (on a different port) as a "backdoor" for admin access in case OpenSSH doesn't load properly), please review that entire message thread I referred you to).

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs

Please review: When you're asking a question, please include the following.

e-r-a-n
Getting the hang of things
Posts: 77
Joined: Sat May 11, 2013 3:02 am

Re: /root/.bash_profile changes aren't saved after reboot

Post by e-r-a-n » Mon Mar 23, 2015 4:24 pm

Thank you Patrick, I followed your quick guide and did the same (saving qnap's sshd on different port for safety)
I also applied the [autorun] section, for auto-loading the service (and other will come soon)
Im intrigued about RAMDisk, How can I tell which partitions are what?
If I download binary files and want them to be in my PATH, so that I wont need to specify their absolute location, Which bin folder is more appropriate and changes do survive reboot?
I now remember that once I asked about transmission extended plugin, that comes with TorrentWatch-X, and it have some specific settings that I know of, that doesnt survive reboots. Is it somehow related to the fact that these files are probably in the RAMDisk?
If so, Where is the "real" files, which are loaded into memory on boot?

User avatar
pwilson
Guru
Posts: 22581
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada (UTC-08:00)

Re: /root/.bash_profile changes aren't saved after reboot

Post by pwilson » Mon Mar 23, 2015 4:55 pm

e-r-a-n wrote:Thank you Patrick, I followed your quick guide and did the same (saving qnap's sshd on different port for safety)
I also applied the [autorun] section, for auto-loading the service (and other will come soon)
Im intrigued about RAMDisk, How can I tell which partitions are what?
If I download binary files and want them to be in my PATH, so that I wont need to specify their absolute location, Which bin folder is more appropriate and changes do survive reboot?
I now remember that once I asked about transmission extended plugin, that comes with TorrentWatch-X, and it have some specific settings that I know of, that doesnt survive reboots. Is it somehow related to the fact that these files are probably in the RAMDisk?
If so, Where is the "real" files, which are loaded into memory on boot?


You can change your path to anything you want. I do this in my .profile. (/share/homes/admin/.profile).

Code: Select all

echo $PATH
/Apps/opt/bin:/Apps/opt/sbin:/share/homes/admin/bin:/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/sbin:/usr/local/bin:/usr/local/jre/bin:/usr/local/apache/bin:/usr/local/samba/bin


I put my scripts in /share/homes/admin/bin.

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs

Please review: When you're asking a question, please include the following.

Post Reply

Return to “Turbo Station Installation & Setup”