What's new

How to change /opt path

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

demokedes

Occasional Visitor
Dear all,
I am changing external usb storage. Consequently I have to change /opt path. What is the easiest way to achieve that?
I moved content of the old location to the new location.
The old location is not accessible anymore. If I cd /opt, I get:
Bash:
admin@RT-AX88U-CD00:/jffs/scripts# cd /opt
-sh: cd: can't cd to /opt
 
Last edited:
/opt is a link to /tmp/opt. This in turn is a link to the real entware directory on the USB drive. This link is created automatically by the Entware startup process.
 
Colin,
Thank you understand that. But is it possible to manually change the path? I moved the directory to another location. If I run the command from the new location it is working. Can this be done manually or do I need to reinstall entware?
 
If I run the command from the new location it is working.
Sorry, I don't understand what your problem is if it's working now. Everything in Entware is compiled to work from /opt therefore your new location must be soft linked to /opt. The Entware startup process usually does this, so if you've moved Entware to a different USB drive it will automatically be picked up.

If you installed Entware via amtm or Diversion the startup process will scan the USB drive when it's mounted looking for /entware*/bin/opkg. It will use this as the Entware location if it finds it.
 
Not sure if this will help, but here's a script I wrote that gets activated by the nvram variable script_usbmount=path-to-script which is present in both the stock asuswrt and asuswrt-merlin. The script runs when a usb stick gets successfully mounted. To make sure that the path is available shortly after boot, I put the script, executables and libraries in /jffs. The section on handling /tmp/opt might give some hints.

Code:
#!/bin/sh
{
  echo "=== $0 == $( /bin/date ) ==="

  export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/jffs/bin
  export LD_LIBRARY_PATH=/jffs/lib:$LD_LIBRARY_PATH

  # Do an fsck just in case.
  /bin/umount /dev/sda1
  /jffs/bin/fsck.ext4 -fpv /dev/sda1

  # Since there's a fixed read-only symlink of /opt->/tmp/opt, cut
  # out the additional redirect symlink of /tmp/opt->/tmp/mnt/sda1.
  /bin/mkdir -p /tmp/opt
  /bin/mount /dev/sda1 /tmp/opt
  /sbin/swapon /dev/sda2

  # Get my basics into the root home directory.
  cd /tmp/opt/usr/
  /bin/cp -pr .config .profile .ssh .vimrc bin /root/
  cd /root/
  /bin/chmod -R og=,u+rwX .ssh

  # Start a script that creates a SOCKS5 proxy and a lighttpd
  # instance with a common home page for all my devices.
  ( /usr/bin/nohup /jffs/bin/fix_srvcs </dev/null >/dev/null 2>&1 & ) </dev/null >/dev/null 2>&1 &

  echo "=== $( /bin/date ) ==="

} >/tmp/usb_mount.log 2>&1
 
Dear all,
I am changing external usb storage. Consequently I have to change /opt path. What is the easiest way to achieve that?
I moved content of the old location to the new location.
The old location is not accessible anymore. If I cd /opt, I get:
Bash:
admin@RT-AX88U-CD00:/jffs/scripts# cd /opt
-sh: cd: can't cd to /opt
If you use amtm or Diversion to setup Entware then the scenario is simple and works 100% of the time - unless someone tinkers with things or changes the file content that my scripts use.

amtm and Diversion start Entware services with /jffs/scripts/addons/diversion/mount-entware.div
If Diversion is installed, the file has additional content but the logic is the same:
While the routers is mounting an attached storage device, mount-entware.div will first look for /entware/bin/opkg.
amtm and Diversion create and install Entware into a folder named entware on the selected device, this is the default.
However, older scripts created a variation of that folder name like entware-ng - including my scripts a long time ago.
So, if there is no entware folder, mount-entware.div then looks for /entware*/bin/opkg and would rename it to entware if its a variation of entware*.

All actions when mount-entware.div is triggered are logged to the routers Syslog:
When Diversion is installed:
Code:
Diversion: Starting Entware and Diversion services on <device>
Without Diversion:
Code:
Entware: Starting Entware services on <device>
It also states if there are two instances of Entware found on separate devices.

So in essence, check your Syslog after a reboot to find out why your new device is not starting Entware on your router.
 
I am not using Diversion, so I am not familiar with it.
During the weekend, I was testing a bit and I solved it.
I added following to lines into init-start script and it is working now.
Thank you!
Bash:
/bin/mkdir -p /tmp/opt
/bin/mount /tmp/mnt/Verbatim/sdb1/entware /tmp/opt
 

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