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

Shibby FW- How can I mount my usb drive to /opt

Discussion in 'Tomato Firmware' started by Bird333, Nov 24, 2012.

  1. Bird333

    Bird333 Network Guru Member

    My drive automatically mounts to /tmp/mnt/opt. I want to mount it just to /opt. When I try to do it, something screws up with the system. For example, the colors of the files/directories all change to white. Also, trying to look at my iptables entries seg faults. I guess some kind of link would work also instead of mounting it. Basically, I want my scripts to be able to reference /opt/filename instead of /tmp/mnt/opt/filename.
  2. M0g13r

    M0g13r LI Guru Member

    mount -o bind /mnt/opt /opt ?

    in run after mounting
  3. Bird333

    Bird333 Network Guru Member

    I have tried that but it causes the problems I mentioned above. I am looking for a way that doesn't cause those problems.
  4. bmupton

    bmupton Serious Server Member

    ln /tmp/mnt/opt /opt
  5. Bird333

    Bird333 Network Guru Member

    I tried that before and this is what I get (btw the system says you can't do a hard link on a directory)
    Don't let the 'DD-WRT' fool you. :)

    Tomato v1.28.0000 MIPSR2-102 K26 USB Big-VPN
    root@DD-WRT:/tmp/home/root# cd /
    root@DD-WRT:/# ls
    bin       dev       lib       proc      sys       var
    bkp       etc       mnt       rom       tftpboot  www
    cifs1     home      nas       root      tmp
    cifs2     jffs      opt       sbin      usr
    root@DD-WRT:/# cd opt
    root@DD-WRT:/opt# ls
    root@DD-WRT:/opt# ln -s /tmp/mnt/opt /opt
    ln: /opt/opt: Read-only file system
    root@DD-WRT:/opt# ls -l
    I am also confused as to why there is an empty /opt directory on the file system.
  6. bmupton

    bmupton Serious Server Member

    Someone more familiar with the Tomato filesystem may have to chime in here. I've only been running it for a couple weeks, before this I was a DD-WRT man until I got fed up dealing with it.
  7. GrayWolf

    GrayWolf Serious Server Member

    Have you tried putting an entry something like?
    In /etc/fstab:
    /dev/sdb1 /opt ext3 defaults 1 1
    One way to do this is to put something like the following?
    In the Administration... Scripts... Init... section of the web interface:
    echo "/dev/sdb1 /opt ext3 defaults 1 1" >> /etc/fstab
    Of course, some may argue for using an ext2 file system over an ext3 on an external flash drive.

    I also have an entry my Tomato (Shibby v102) router's /etc/fstab file, which mounts a swap partition:
    Still in /etc/fstab:
    /dev/sdb2 swap swap defaults 0 0
    At the moment, both entries appear to work correctly.
  8. Bird333

    Bird333 Network Guru Member

    This command echo "/dev/sdb1 /opt ext3 defaults 1 1" >> /etc/fstab does add the line to the /etc/fstab file but it doesn't mount to /opt. I think the problem is that /opt is read-only. Shibby, if you are seeing this can you just add an option to let us choose where we want to mount our usb harddrive? Of course if no option is specified you can just have it use the default behavior.
  9. koitsu

    koitsu Network Guru Member

    1. Can you explain, calmly and coherently, why mount -o bind /mnt/opt /opt doesn't work for you? Yes I have read your first post and it isn't clear/concise as to what your issues are. This method is normal and is used on other firmwares (not just Shibby) as well. In fact, this is used for CIFS/SMB mounts as well. "Something screws with the system" and "things appear in white" tells me absolutely nothing useful.

    2. The reason /opt (meaning out-of-the-box, to you) appears read-only (when attempting to make a symlink of /tmp/mnt/opt to /opt) is because it's part of the root filesystem, and that is read-only. There is absolutely no way possible that's going to change with this firmware. If you want that kind of overlay feature, you want OpenWRT. They have solved this in a very different manner and it would work how you expect it -- however, I can assure you'd eventually be confused, because their model effectively has one main filesystem, and a 2nd which "overlays" itself on top of the main. Main = read-only, 2nd = writeable (to flash).

    I also find it amusing that you're in the /opt directory (which is pre-created for you per the firmware) yet you're trying to do ln -s /tmp/mnt/opt /opt. You should never (try to) modify CWD. What did you think ln -s was going to do? unlink /opt (i.e. "rm -r /opt") and then re-create it for you? Sigh.

    So instead of folks banging on keys (to-so-speak) like monkeys, can we please get some coherent details as to what the problem is here? Again: mount -o bind /mnt/opt /opt is the solution. If there are "quirks" as a result of that, let's talk about those. STAY FOCUSED.
  10. leandroong

    leandroong Addicted to LI Member

    There is a seldom bug appearing to me and remain unsolved. Only reset is the solution.
    I would normally got the problem, sometimes and not often, when i unmount my data USB from powered USB hub, then later on mount it back and have both USB drives disappeared. There is conflict, maybe due to hub hardware issue. So, I would remove USB hub connection from router inorder to re-detect both external USB hard disks. Problem that appeared to me, the optware is not mounting correctly, it display as "/tmp/mnt/opt" instead of "/opt". Only router reboot fix that issue.

    Note: doing mount -o .... would not resolved optware location.

    @bird33, if you want permanent and not using echo, I suggest you edit your fstab. mine is like this:

    root@BTRouter2:/tmp/etc# cat fstab
    #device Mountpoint FStype Options Dump Pass#
    LABEL=swap none swap sw 0 0
    LABEL=optware /opt ext3 rw,noatime 1 1
    LABEL=rdata /tmp/mnt/rdata ext3 rw,noatime 1 1

    Note: To make it permanent do the ff after editing it:
    1. nvram setfile2nvram /etc/fstab
    2. nvram commit
    3. reboot
    Note: do it without the prefix number.
  11. Bird333

    Bird333 Network Guru Member

    1. mount -o bind /tmp/mnt/opt /opt works but it causes weird problems. The main problem is that I can't list my iptables rules after I use that command. I get a 'segmentation fault' and none of the rules are displayed. I also noticed some other weirdness such as my prompt has brackets around it and all the colors for the different files and directories disappear and they are all just white. Normally, directories show as blue, links are aqua, etc. After the mount command, all of them appear white/light gray. So far these are the only differences I have noticed. And yes I have traced it to that command causing the problem.

    2. The only reason I ran that command in cli is to see error message I get for that command. What does CWD mean?

    I would like to mount to /opt without it causing these other problems. I hope I have cleared everything up.
  12. leandroong

    leandroong Addicted to LI Member

    @bird333, I think when I dont edit my fstab, my optware mounted like you said, "/tmp/mnt/opt". That is why you needed to edit your fstab for correct mounting like I mentioned above.
    If you are getting segmentation fault, which I encounter long time ago.... I remedy that by re-installing the firmware w/out doing any nvram erase, if I recall it correctly. Since then, I don't have that issue. Problem seems to be base on FW not loaded correctly.
    koitsu likes this.
  13. koitsu

    koitsu Network Guru Member

    Thank you.

    Do you have some kind of custom environment set up? A unique shell with dotfiles? Libraries installed on your USB drive -- more specifically, Linux binaries? Filesystem mounts (and bind mounts) have nothing to do with iptables, and the only thing I can think of is that you have other iptables binaries installed on your USB drive.

    TomatoUSB uses a PATH default of:

    So you can see how Linux binaries (for other platforms/architectures), if in any of those /opt directories listed above, could cause the problem. If you have Optware installed on that USB drive, this could be the source of the issue as well. Can you try running /usr/sbin/iptables (the full command, not just "iptables") and see if the behaviour continues?

    As for libraries, this could happen if you are doing something with LD_LIBRARY_PATH in your dotfiles.

    To me this indicates something is on your USB drive which is causing this problem. I'm starting to think the above situation (see a few paragraphs up) is what's happening here. This isn't the "fault" of the mount command, this would be the fault of what you have stored on your USB drive. Let's focus on that for now.

    You can also try leandroong's recommendation -- I HIGHLY recommend their advice. The "thorough" NVRAM clear is necessary, especially if you have used other firmwares in the past.

    CWD = current working directory.

    On UNIX and *IX systems you should not get in the habit of changing/messing with a directory while you are in that directory, i.e. do not be inside of /opt if you plan on mounting /opt or unmounting /opt or changing something about /opt. The same can be said about /var/tmp, /usr, /i/like/snakes, or any other path. This has to do with inodes and what happens when you yank or change one out "from underneath" the shell.
  14. Bird333

    Bird333 Network Guru Member

    It's entirely possible there is some custom environment setup causing this. A little background. I was running DD-WRT with 'optware the right way' (aka 'otrw') installed on my USB drive. You can read about it here http://www.dd-wrt.com/wiki/index.php/Optware,_the_Right_Way. There are several services that this installs and it does change some environment variables I do believe, but I didn't think any of this mattered because these services don't start under Tomato. BTW, /usr/sbin/iptables still gives the segmentation fault also. I'm not really sure what 'dotfiles' are. Do you mean files names that start with '.' that are hidden?

    I am also starting to suspect this might be why my transmission is not working either.
  15. koitsu

    koitsu Network Guru Member

    Why not format the USB drive and find out? Or move all files/directories from the root of the USB drive into a sub-folder called "OLD" or something like that, and then see if the issue persists? Be sure to move any dotfiles out of the way as well.

    I would also suggest doing the thorough NVRAM erase as leandroong suggested -- if you do this, please manually restore your router settings in the GUI -- do not use the "config backup and restore" feature, as that will just reintroduce DD-WRT NVRAM variables into the picture, and those may be causing a lot of problems here.

    Dotfiles are files that start with period. However, some have special purpose -- such as .login, .profile, .bashrc, .bash_profile, and numerous others. If these are somehow used ("sourced") and brought into the shell when you log in to it, then yes, these would almost certainly be causing problems. I get the impression there is a lot about your setup that you aren't disclosing here because you aren't sure why it would matter (I say that politely not judgementally; I know it sounds judgemental but I don't mean it like that).

    You need to understand that DD-WRT and every single thing about it (and related to it) generally is "unique". TomatoUSB != DD-WRT. The two things are not compatible (I am intentionally keeping the technical details out of this -- I am quite familiar with the technical details). The same goes for any firmware vs. another firmware.

    If you want to run something that's like Optware, but on TomatoUSB, I recommend strongly you go with Entware. I can assure you it works fine on TomatoUSB -- I use it myself. The packages are kept up to date and the maintainers are very, very active (vs. Optware where it's just a clusterf*** of a mess and nobody seems to maintain anything, i.e. total chaos with no centralised support). Before considering Entware, however, please make sure your USB drive is formatted fresh (as in no files on it ANYWHERE). If you ABSOLUTELY need a swap partition, you need to read and follow this guide that Monk E. Boy made. Please zero your disk and start fresh -- I'm serious here. And for auto-swapon bits, be sure to see this post in the same thread.

    If you want a highly CLI-oriented router firmware, i.e. "I am familiar with Linux and prefer to treat my router as a little Linux box", but still want some GUI features, I strongly recommend you run OpenWRT instead. I cannot stress this point enough. You will find the environment a lot easier to work in, set up, and so on. Their kernel is also newer (if I remember right). Tomato/TomatoUSB are mainly intended for simple end-users -- there are some of us that are highly technical and use it, but we're also familiar with the innards (some moreso than others).

    The most worrisome problem I see reported here is iptables segfaulting. This is in an embedded environment -- debugging this is very difficult. I could do it if I had the right tools installed and the user was familiar with things like strace and gdb. I don't know why iptables would segfault unless ld.so was trying to load a library from Optware or something off your USB disk, or (god forbid) somehow something injected rules which iptables can't list (for some reason -- and debugging that might require kernel debugging capabilities, which TomatoUSB does not have for many reasons).
  16. Bird333

    Bird333 Network Guru Member

    Can you give me a command to move these files? I need to be able to put them back also. Is there a list of Entware packages somewhere? I don't see any on the project site.
  17. koitsu

    koitsu Network Guru Member

    If dotfiles are involved, there is no "easy one-liner" to move them because using something like the .* wildcard would include the . and .. directories (which you don't want), and Busybox sh does not support shopt/setopt to disable dotglob. So let's make the (bad?) assumption that the only thing on your USB drive in the root directory are non-dotfiles:

    mkdir /tmp/mnt/opt/old_files
    mv /tmp/mnt/opt/* /tmp/mnt/opt/old_files
    If ls -al /tmp/mnt/opt shows some dotfiles, you will need to move them to /tmp/mnt/opt/old_files yourself. I'm not going to sit here and do UNIX commands 101 though, sorry. The reason I can't is because most of the utilities that come with Busybox don't have the necessary flags/features needed to make this easy on you (like find's -maxdepth flag).

    Anyway, now log out of the router (telnet/ssh) and unmount the drive (through the GUI), then remount it and log back in to the router. If the problem is gone, then the issue becomes obvious (something stored on the USB drive that's probably DD-WRT or Optware related causing problems).

    If you have questions about Entware, you should either file a ticket/PR to have them provide an answer, or you can ask on their forum. The closest thing to a package list you'll be able to get is this. It's a lot easier to just install Entware and use opkg list. I assume you know enough UNIX to know things like opkg list | grep -i something.
  18. Bird333

    Bird333 Network Guru Member

    I had a spare harddrive so I just swapped it out and the problem went away. So I guess there is something stored on the other drive. Thanks for the help everyone.
  19. viumden

    viumden Serious Server Member

    The BASH installation in /opt will cause this strange behaviours, dig further for this issue, it is actually the /opt/etc/profile:
    # Bash initialization script
    PS1="[\u@\h \W]$ "
    Change the name or content of this /opt/etc/profile will fix the weird issue after the mount.

    In /rom/etc/profile:
    export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/home/$USER:/mmc/sbin:/mmc/bin:/mmc/usr/sbin:/mmc/usr/bin:/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/bin:`nvram get env_path`"
    export PS1='\u@\h:\w\$ '
    alias l='ls -lFA'
    alias ll='ls -lF'
    ldd() {
    [ -f /jffs/etc/profile ] && . /jffs/etc/profile
    [ -f /opt/etc/profile ] && . /opt/etc/profile
    That is the root control file.
  20. Liotcheg

    Liotcheg Serious Server Member

    viumden, you are genius! I've been suffering from this wierd issue for several weeks! First I had this with optware on microSD card, than I changed to WD harddrive and got the same.

    Just for hystory to see how wierd it was:
    [root@b737 root]$ ls -lah /opt/
    ?-------w-    0 16877    22          2.7T Jan  1  1970 /opt/
    Have you ever seen a 2.7TB microSD? No? Than what about PENTABYTE config files?))))

    [root@b737 root]$ ls -lah /opt/etc/
    d--------x    0 16877    8          19.1P Jan  1  1970 .
    ?-------w-    0 16877    22        19.1P Jan  1  1970 ..
    d-----x---    0 16877    2          19.1P Jan  1  1970 default
    d-----x-w-    0 16877    2          19.1P Jan  1  1970 init.d
    d-------wx    0 33188    1          19.1P Jan  1  1970 ipkg.conf
    Thank you!
  21. Bird333

    Bird333 Network Guru Member

    Can you explain your history with your router? Did you upgrade from DD-WRT like I did?
  22. koitsu

    koitsu Network Guru Member

    @Liotcheg, your issue looks like a corrupted filesystem or quite possibly a filesystem that is some other format than ext3. What filesystem are you using?
  23. Liotcheg

    Liotcheg Serious Server Member

    No. After several unsuccessful attempts to flash dd-wrt I decided to flash tomato. And then I inserted a MicroSD card and installed optware. The router is Asus RT-N66U.
    I believe, the only important part of my history is that where I installed bash))
  24. Liotcheg

    Liotcheg Serious Server Member

    Yes, looks like but I'm sure it has nothing to do with a filesystem.
    First my optware was installed on a MicroSD card with ext2, so I decided "hm, looks like a filesystem problem")) and installed optware on 2TB Western Digital hard drive with ext3.
    And I had the same issue on HD.

    *viumden* gave a correct explanation. The root of the issue is in /opt/etc/profile and it appears after installation of bash from optware.
    I tested it by removing and restoring /opt/etc/profile.
  25. Franciszek

    Franciszek Serious Server Member

    I notice the same behaviour. In my opinion there is a library problem.
    Check if this help you:
    export LD_LIBRARY_PATH=/lib:/opt/lib

    and next check direcotry content: ls -lah /opt/etc/
  26. koitsu

    koitsu Network Guru Member

    Please see the last paragraph of his post for the root cause. Bottom line: people need to stop using Optware (as in completely nuke any drive/system that has had it installed on it) and use Entware instead.
  27. joew1

    joew1 Serious Server Member

    koitsu, this is SteveF under a different ID. A short while ago I found that my ID, SteveF disappeared from the forum along with the post I started: QoS versus BW Limiting. Do you have an idea what may have happened? Has there been some problem with the forum?

  28. Toastman

    Toastman Super Moderator Staff Member Member

    There is a problem, clearly. Looking into it ... :eek:

Share This Page