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

[Announce] Busybox v1.13.3 for NAS200 running jac2b

Discussion in 'Cisco/Linksys Network Storage Devices' started by jackito, Mar 15, 2009.

  1. jackito

    jackito LI Guru Member

    Hi,

    I compiled a new version of Busybox (v1.13.3) for NAS200 running jac2b.
    It adds bugfixes, and this functionalities:

    1) bunzip2
    2) bzcat
    3) bzip2
    4) diff
    5) dos2unix
    6) fuser
    7) gunzip
    8) nice
    9) nohup
    10) pgrep
    11) pscan
    12) renice
    13) split
    14) stat
    15) sysctl
    16) top
    17) traceroute
    18) unix2dos
    19) unzip
    20) watch
    21) zcat

    And of course:

    * ls with color!
    * tar with bzip2 support

    You can get it here.
    Hope you enjoy it!
     
  2. jackito

    jackito LI Guru Member

    I tried to use this busybox binary as my shell instead of the original one.
    But it is not working. I get a message about "wrong password" but Im sure is because of the "invalid" shell.
    The only way to use this binary as my default shell is to create a new firmware version (.bin) replacing the original busybox binary with this newone one? Any other ideas?
     
  3. jackito

    jackito LI Guru Member

    Solved. I just create /etc/shells with my own shell in the list and now is working. :biggrin:
     
  4. mdsilva

    mdsilva Addicted to LI Member

    Hi, great!!

    I'm glad to have top and ls with colour. (is vim comming soon?)

    Problem is how do i install it? So far i have extracted it to my hard drive (not sure where the best place to put it). How do i use it or make root able to use it by default?

    Any clues?
     
  5. jackito

    jackito LI Guru Member

    The installation is really simple.
    Just untar the binary in some directory of the harddrive, for example, /harddisk/volume_X/data/ (where X is a number that depends on the configuration of your harddrives ie: 3 for RAID-1).
    Next just create links for all the applets you want to run. For example top and ls (you can get the list of applets that are compile in busybox simply by executing it without any parameters):

    Code:
    cd /harddisk/volume_3/data
    ln -s busybox ls
    ln -s busybox top
    
    After doing this you can just execute:

    Code:
    ./top
    -or-
    /harddisk/volume_3/data/top
    
    If you want to be able to call ls or top or whatever applet you want to run from any directory of the system without calling it with the full path you just need to change and export your PATH enviroment var so the system will be able to find your new binary and links for execution:

    Code:
    export PATH='/harddisk/volume_3/data:$PATH'
    
    That´s all. Now you can just run top or ls.
    Keep in mind that the order of the path counts, because the system will execute the first program that he find with that name. In this example the "new" ls will prevale over the "original" ls because the system will find it first since it is in the first path for seek. So using the opporsite example if you do:

    Code:
    export PATH='$PATH:/harddisk/volume_3/data:'
    
    Then when you call ls you are going to execute the original version of busybox ls, without color, but on the other hand if you execute top, since top is not part of the default busybox, the system will execute the new busybox top.

    Last but not least if you want to make your new PATH env var permanent, create or edit the .profile file in root´s home directory and add the first export example to it. From now on everytime you log in to the system your new path will be set up.

    Fer

    PS: if you want to use the new busybox as your default shell just take a look to my previous posts, hope they are clear enough.
     
  6. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    If you want to do something drastic like replace your busybox, you can't do it in the Flash of course. But there's a workaround: you can use pivot_root to remount your root directory and make it writeable. There are two ways to do this:

    Method 1: Put the new root directory in RAM:
    1. Create a new directory so you have a mount point, then mount it: mkdir /tmp/newroot; mount -t ramfs none /tmp/newroot
    2. Change to the new root directory's location: cd /tmp/newroot
    3. Create a directory where the old root directory will be mounted: mkdir rom
    4. Create symlinks for all entries that should be in the root directory: for x in $(ls /);do ln -sf /rom/$x $x;done
    5. Pivot the root directory: pivot_root . rom; cd /
    6. As you can see, you are now in the new root directory which is a RAM disk.
    7. If you want to go back to your old root, do: cd /rom;pivot_root . /tmp/newroot
    8. You will have to repeat all steps after a reboot: the RAMdisk root directory will be gone.

    Method 2: Use one of the partitions on the hard disk as root directory (e.g. the config partition of the second hard disk):
    1. Change to the new root directory, e.g. cd /harddisk/volume_2/conf
    2. Create a subdirectory where the old root directory will be mounted: mkdir rom
    3. Create symlinks for all entries that should be in the root directory: for x in $(ls /);do ln -sf /rom/$x $x;done
    4. Pivot the root directory: pivot_root . rom; cd /
    5. As you can see, you are now in the new root directory which is the root of the config partition. Be careful not to remove any files that you see in the root directory such as "passwd" - they may be needed when the system reboots.
    6. If you want to go back to your old root, do: cd /rom;pivot_root . /harddisk/volume_2/conf
    7. Because the hard disk is persistent, nothing will be lost the next time you want to pivot your root directory; all you need to do is go to the directory and do the pivot_root command again. No need to recreate the symlinks first.

    Because of all the symlinks in the new root directory, everything should still work as before. But the pivoted root directory is read-write so you have more freedom to replace stuff. You can also do the replacing before the pivot_root (that might make things a little easier e.g. when you want to replace busybox) by copying certain directories instead of symlinking them.

    Remember, the directory that you want to pivot your root to must be the root directory of a block device, otherwise the pivot will fail with a vague error message. You can't just pivot_root to any directory. So the root directory of a RAM disk can be used, or the root directory of a hard disk or the root directory of a USB stick.

    When you pivot your root directory, the original mount point of the new root directory is dismounted (I think). So for example after you pivot_root to /harddisk/volume_2/conf, the directory /harddisk/volume_2/conf in the new root directory will appear empty because nothing is mounted there. You will have to mount the partition at that point again. If you do that and you want to pivot_root back to the original root directory, you will have to remember to unmount the partition from that mount point first: after all you can't mount two filesystems in the same location.

    You can create an early.sh that contains the commands to pivot the root directory, to make it happen automatically.

    Please note: I tested method 1 while I wrote this, but not method 2. As usual, try this at your own risk! If you mount your config partition as root directory and then wipe some important files that keep you from rebooting properly, it's not my fault. I recommend making backups of your data and of your configuration before you do this. You can make configuration backups through the Linksys web interface.

    ===Jac
     
  7. mdsilva

    mdsilva Addicted to LI Member

    Hi, thanks guys got it working using the ln -s busybox <<tool>> for:

    [, [[, ash, awk, basename, bunzip2, bzcat, bzip2, cat, chgrp, chmod, chown, chroot, chvt, clear, cmp, cp, cut, dd, deallocvt, df, diff, dirname, dmesg, dnsd, dos2unix, du, echo, egrep, env, expr, false, fgrep, find, free, fuser, grep, gunzip, gzip, halt, head, hexdump, hostname, id, ifconfig, init, insmod, install, kill, killall, klogd, linuxrc, ln, logger, logread, losetup, ls, lsmod, md5sum, mkdir, mknod, mkswap, mktemp, modprobe, more, mount, mv, netstat, nice, nohup, nslookup, openvt, pgrep, pidof, ping, pivot_root, poweroff, ps, pscan, pwd, readlink, reboot, renice, reset, rm, rmdir, rmmod, route, sed, seq, sh, sleep, sort, split, stat, swapoff, swapon, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, top, touch, tr, traceroute, true, tty, umount, uname, uniq, unix2dos, unzip, uptime, usleep, vi, watch, wc, wget, which, who, whoami, xargs, yes, zcat

    then i set my path by adding this line to the end of ~/.profile (roots home is on hard drive 1):

    export PATH='/harddisk/volume_1/data/tools:$PATH'

    Will this break something if i have to reboot?
     
  8. jackito

    jackito LI Guru Member

    AFAIK nothing.
    But if you want to keep it completelly safe just don´t link the same applets that the original firmware has. For example: cp, kill, etc. Then you will not have two different versions of the same and that is 100% safe IMHO.
    In my installation I just link the missing tools to the new busybox and also some that I´m 100% sure that will not break anything, for example: tar and ls.
    Also I use the new busybox as my default shell. :biggrin:
     
  9. mdsilva

    mdsilva Addicted to LI Member

    Thankyou
     
  10. Pa0l0ne

    Pa0l0ne Addicted to LI Member

    What does it mean? I have upped busybox on my /harddisk/volume_1/data and created the symbolic links of "ls" and "top" commands but when i try to execute it all, the shell give me this error:

    -sh: ./top: Permission denied <---OK the problem is that my new busybox wasn't have 777 permission :redface:

    So i have tried to create a "shells" directory on my "etc" and upped the new busybox on it but in this case i can't logon anymore in ssh because of the ssh password incorrect?! Fortunatelly i have cancelled shells directory and the new busybox on it in normal telnet session (fortunatelly i don't have disabilitated it)...so what does "create /etc/shells with own shell in the list mean?
     
  11. jackito

    jackito LI Guru Member

    "shells" is not a directory, is a file. A file that should be under /etc.
    Inside the file one by line there should be the different shell binaries that are available for the users.
    For example:

    Code:
    /bin/sh
    /bin/ash
    /harddisk/volume_X/conf/myshell_binary_1
    /harddisk/volume_X/conf/myshell_binary_2
    
    Then you can use any of them as your default shell after editing the passwd file.
     
  12. Pa0l0ne

    Pa0l0ne Addicted to LI Member

    in my /etc does not exist shells file so if i create one is sufficient to insert only this code in it?:

    /bin/sh
    /bin/ash
    /harddisk/volume_1/conf/root/busybox

    Take in mind that my passwd file is just edited for "/harddisk/volume_1/conf/root" home directory
     
  13. jackito

    jackito LI Guru Member

    Perfectly sufficient. Exactly what you need to do.
     
  14. DJ Soulfly

    DJ Soulfly Addicted to LI Member

    I'll did that to but I'll still have the original shell instead of the new one and have to run ./busybox ash manualy to start busybox 1.13.3
     
  15. jackito

    jackito LI Guru Member

    Can you please post the content of your /etc/shells and /etc/passwd files?
    Don´t worry about the password section you can obfuscate it. Im only interested in the last section of each line.
    Also please post the path to your "new" busybox file.
    Thanks.
     
  16. DJ Soulfly

    DJ Soulfly Addicted to LI Member

    content of /etc/passwd :

    root:md5:/harddisk/volume_3/conf/root:/bin/sh
    bin:x:1:1:bin:/bin:
    lp:x:4:7:lp:/share/spool:
    mail:x:8:12:mail:/var/spool/mail:
    ftp:x:14:50:FTP User:/:
    nobody:x:99:99:Nobody:/:
    ourtelnetrescueuser:sPuRQwXaya5YE:100:100::/home/user:/bin/sh
    guest:xqnMpE/plEnFs:501:501::/home/user/guest:/dev/null0
    alwin14:md5:/dev/null1
    private:md5:/dev/null0

    content of /etc/shells :

    /bin/sh
    /bin/ash
    /harddisk/volume_3/data/rc.d/busybox

    the strange thing also the shells file is gone after a reboot of the nas
     
  17. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    The /etc directory is mounted in RAM so everything that's in there won't survive a reboot. The Linksys software copies everything back during startup. You'll have to generate the shells file yourself by creating a startup script.

    ===Jac
     
  18. DJ Soulfly

    DJ Soulfly Addicted to LI Member

    That explains it why this file is always gone on reboot.

    If i am correct. I must create a startup script which copies shells to /etc on boot and put it on /harddisk/volume_3/data/rc.d/ and then should busybox 1.13.3 be loaded on boot?
     
  19. jackito

    jackito LI Guru Member

    Yes, you are correct.
    Another thing is that you must correct the shell for your root user.
    Based on your post, right now, the shell for your root user is "/bin/sh" that´s why you are not getting the new busybox as your default shell (that and the lack of /etc/shells file).
    So apart of making the startup script to create /etc/shells file on every reboot, you need to change root´s default shell from "/bin/sh" to something like "/harddisk/volume_3/data/rc.d/busybox" or whatever the path to your new busybox is.

    Fer
     
  20. DJ Soulfly

    DJ Soulfly Addicted to LI Member

    ok next challenge. The startup script works and copies the shells file to /etc/shells

    content of /etc/passwd :

    root:md5:/harddisk/volume_3/conf/root:/harddisk/volume_3/data/rc.d/busybox/busybox
    bin:x:1:1:bin:/bin:
    lp:x:4:7:lp:/share/spool:
    mail:x:8:12:mail:/var/spool/mail:
    ftp:x:14:50:FTP User:/:
    nobody:x:99:99:Nobody:/:
    ourtelnetrescueuser:sPuRQwXaya5YE:100:100::/home/user:/bin/sh
    guest:xqnMpE/plEnFs:501:501::/home/user/guest:/dev/null0
    alwin14:md5:/dev/null1
    private:md5:/dev/null0

    content of /etc/shells :

    /bin/sh
    /bin/ash
    /harddisk/volume_3/data/rc.d/busybox/busybox

    When i am connecting through ssh it accepts my password and load busybox 1.13.3 only the thing is its generating the following output and then disconnects :

    BusyBox v1.13.3 (2009-03-27 11:38:01 CET) multi-call binary
    Copyright (C) 1998-2008 Erik Andersen, Rob Landley, Denys Vlasenko
    and others. Licensed under GPLv2.
    See source distribution for full notice.

    Usage: busybox [function] [arguments]...
    or: function [arguments]...

    BusyBox is a multi-call binary that combines many common Unix
    utilities into a single executable. Most people will create a
    link to busybox for each function they wish to use and BusyBox
    will act like whatever it was invoked as!

    Currently defined functions:
    [, [[, ash, awk, basename, bunzip2, bzcat, bzip2, cat, chgrp, chmod, chown, chroot, chvt, clear, cmp, cp, cut, dd, deallocvt, df, diff, dirname, dmesg, dnsd, dos2unix,
    du, echo, egrep, env, expr, false, fgrep, find, free, fuser, grep, gunzip, gzip, halt, head, hexdump, hostname, id, ifconfig, init, insmod, install, kill, killall,
    klogd, linuxrc, ln, logger, logread, losetup, ls, lsmod, md5sum, mkdir, mknod, mkswap, mktemp, modprobe, more, mount, mv, netstat, nice, nohup, nslookup, openvt,
    pgrep, pidof, ping, pivot_root, poweroff, ps, pscan, pwd, readlink, reboot, renice, reset, rm, rmdir, rmmod, route, sed, seq, sh, sleep, sort, split, stat, swapoff,
    swapon, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, top, touch, tr, traceroute, true, tty, umount, uname, uniq, unix2dos, unzip, uptime, usleep,
    vi, watch, wc, wget, which, who, whoami, xargs, yes, zcat
     
  21. jackito

    jackito LI Guru Member

    Sorry, my mistake.
    You MUST create a softlink to call busybox, named sh.

    Code:
    # ln -s busybox sh
    Then in the /etc/shells and /etc/passwd instead of calling busybox, call the new link "sh" that points to the new busybox binary.

    You will probably need to remove the startup script, reboot, make the change and enable the startup script again.
    That should be enough.
    Sorry again for my mistake in the previous post. :redface:
     
  22. DJ Soulfly

    DJ Soulfly Addicted to LI Member

    Thanks man it works like a charm :thumbup:. Now i can get some testing with amule on my nas
     
  23. DJ Soulfly

    DJ Soulfly Addicted to LI Member

    I've i do this it works perfectly the only thing it breaks transfer files through SCP. Has anyone found a solution for it?
     
  24. DJ Soulfly

    DJ Soulfly Addicted to LI Member

    Solved I have edited .profile like this and it works like a charm :

    Code:
    PATH=/harddisk/volume_3/data/rc.d/busybox:/bin:/sbin:/usr/bin:/usr/sbin
    export PATH
    
    Also it's possible to link all the new commands without breaking things :cool:
     

Share This Page