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

jac2b - two challenges tar and fan control

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

  1. jackito

    jackito LI Guru Member

    Hi,

    First of all, I want to thank Jac for his amazing firmware. I love it.
    I managed to add a USB HDD formated in ext2 for backups, share it, etc.
    But now I have two challenges:

    1- I want to do automatic backups to the external drive using tar. I would like to do incremental or differential backups using a simple script. The problem is that tar is very limited on this platform. :(
    I can´t use -N or --newer for instance also I can´t give tar a file that contains a list of paths to backup (-T filename). Is there anyway to run a more complete tar binary or at least with -N or -T options?

    2- I want to find the way to control the fan, is not a big issue but I would like to turn it off and on manually or at least without waiting 10 minutes after the discs go to "stand by". Does anybody knows how to do this? Does the process "CheckHDDPower" has anything to do with this? Do you know if it is possible to get the CGIs source code for the webinterface (utility.cgi is setting the fan control I think)?

    Thanks in advance and again, great firmware Jac!

    Regards,

    Fernando
     
  2. alejandro_liu

    alejandro_liu Addicted to LI Member

    You could probably download the current NASi200 snapshot and use it as a platform to compile a more uptodate tar command.

    BTW, fan control is done through GPIO, if you are able to succesfully compile tar you should be able to compile this small C program:

    Code:
    #include <string.h>
    #include <sys/syscall.h>
    #include <stdlib.h>
    
    
    #define __NR_gpio_low           320
    #define __NR_gpio_high          321
    #define gpio_low(n)	syscall(__NR_gpio_low,n)
    #define gpio_high(n)	syscall(__NR_gpio_high,n)
    
    void main(int argc, char **argv) {
      if (argc != 2) exit(1);
      if (!strcmp(argv[1],"on"))
        gpio_high(57);
      else if (!strcmp(argv[1],"off"))
        gpio_low(57);
    }
    
    Run from the command line, if you pass "on" as argument it will turn on the fan, "off" it will turn it off.

    BTW, if you are making backups to disc, it is usually better to simply make copies (using cp) or if you want to be fancy, use rsync to make a snapshot style copies.

    See this article for an explanation:

    http://www.mikerubel.org/computers/rsync_snapshots/

    Doing this way you can simply get a pre-compiled rsync and be done with it.
     
  3. jackito

    jackito LI Guru Member

    Thank you very much Alejandro for your suggestions and code, I will try to follow both leads!:thumbup:
     
  4. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    As for the backup problem, you could probably use some form of the "find" command to generate a list of files that are newer than the last tar[.gz] file and use that list to generate a differential backup. No compiling necessary, only a bit of creative script-writing. :cool:

    As for fan control, the Linksys program Set_Led (note capitalization) allows you to control the fan too: Set_Led fan_on turns it on and Set_Led fan_off turns it off.

    Of course no matter how often you turn the fan off, it will still be turned on whenever the hard disk is accessed a few times (I forgot what triggers it but I believe it's an algorithm in the modified kernel that turns the fan on if any hard disk is accessed more than X times over a certain period of time). The turn-off time is in the Flash configuration (/dev/mtd2) and it may be possible to trick the firmware into using a shorter turn-off time by changing the value in flash, but I haven't found a reliable way to do that.

    Either way, there is a cron running so you can add a line to /etc/crontab to turn the fan off every minute or whatever, and restart the cron daemon.

    Note that many people have reported overheating problems with the standard fan. If the noise is bothering you, it may be a better idea to use a Dremel and put a bigger quieter fan in there like I did.

    I don't know if CheckHDDPower controls the fans, it's possible I guess (the fans aren't currently turned off by cron, that's for sure).

    The CGI sources and all webpages are in /home/httpd/html.

    ===Jac
     
  5. alejandro_liu

    alejandro_liu Addicted to LI Member

    I remember that CheckHDDPower would use hdparm to check the status of the drives and would turn off the fan.

    The part that turns on the fan is inside the kernel.

    My firmware (nascc) if it works for you :) should give you more transparent control of the fan.
     
  6. alejandro_liu

    alejandro_liu Addicted to LI Member

    BTW the problem with using find to generate a list of files is that the "tar" version that comes with busybox does not support the feature that accepts such a list of files.

    You can alwas pass that list of files in the command line allthough that is limited to the command line limits (i think 32,000 arguments)
     
  7. jackito

    jackito LI Guru Member

    Thanks for your reply Jac.

    About the backup Im already working on a solution with rsync. I downloaded a precompiled rsync binary from another post in this forum (thanks a lot to the author that share it!) and Im working on the script.
    I was also thinking about using find -N to output the list of files to a file a then use that file with tar but BusyBox version of tar doesn t support this. I tried with piping and also
    Code:
    tar -cf test.tar $(cat file_list)
    but in the last case the problem was that some directories and filenames on the list contain spaces (I also try to escape the spaces with backslashes) but no matter what tar keeps thinking that spaces separate files. :tongue:
    Anyway now that I can run rsync I will use it. rsync is a lot better for backups. :wink:

    Regarding the fan control, right now Im using a cron job that runs Set_Led fan_off to shutdown the fan for a while. It a lot more less anoying know. I kept an eye on the temperature of the device and its ok. :thumbup:
    Anyway I will keep in mind the overheating problems that other users are reporting.

    Thanks to your firmware the only limitation to satisfy my needs right now is the hardware processing power, but I dont care too much. I bought a new (not used) NAS200, for 50 euros on ebay I cant ask more. :wink::biggrin:

    Fernando
     
  8. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    Apart from that, you will also run out of command line pretty quickly that way. I was thinking it might make more sense to do something that vaguely resembles
    Code:
    ls -R | xargs find ... -newer ... | cp -a ...   ...
    Or some such...

    ===Jac
     
  9. jackito

    jackito LI Guru Member

    Hi Alejandro,

    I can confirm you that is using hdparm for something so probably is for turning the fan off. :)

    BTW I already implement rsync (thanks to dsc68!! you can find the thread in this forum "[Announce] Rsync for NAS200") as a solution for backup. I wrote a nice (at least for me) script to run "differential" backups every night on a USB drive and send me a complete report also when it finish (rsync log, free space on the NAS, backup size, etc). Im using ext2 (no 4GB filesize limit jeje) on the USB drive and sharing it (read-only) with SAMBA.

    Thanks for the tips!
     
  10. jackito

    jackito LI Guru Member

    I have an idea but I think is a little bit crazy.
    What do you think about running iSCSI target on the NAS200? Will it make the CPU go crazy, more than stressed? :tongue:

    Im trying to access a few VHD in the NAS (I don´t have enough space on my local HDD) for Hyper-V but it only supports VHD on iSCSI (no NFS, no SMB -at least not supported by MS-). There is a trick to make it work with SMB/CIFS (tested on Win2K8 file server) but I wasn´t able to make it work with SAMBA. The problem is that the machine account need full control on the share and also at fs level. I was able to give this permissions for a user account but not to the machine account (yes, I already try to give full permissions to machine_name$ at fs and share level and also made machine_name$ owner of files and folders at the share).

    So if I want to use Hyper-V I need to run iSCSI on the NAS (it will work like a SAN instead). :tongue:
    I know that the performance is not going to be like :eek:
    Maybe I can use iET. What do you think? Will it work?
     
  11. alejandro_liu

    alejandro_liu Addicted to LI Member

    Using IET may work but not easily. The reason is that iET makes use of a kernel module that you need to compile. But once you go over that hurdle, it should be straight forward.

    As far as performance goes, you should be getting between 4-6MBps
     
  12. jackito

    jackito LI Guru Member

    Hi Alex,

    I already install Ubuntu 8.04 on a VM to do this.
    Next step is to figure out how to compile iET kernel modules and binaries.
    I taked a look at the README of iET and for compiling the modules and the binaries there is an option to point where the kernel source is to use that source.
    So maybe pointing to the NAS200 kernel source will do the trick.
    As for the compiling it self I dont have a clear idea of how to do it.

    My plan:

    Start from jac2b source tar.gz
    Add iET to the tree
    Do a lot of google to find how to compile against this tree (CHROOT? to use libraries, kernel source, etc)
    Compile iET binaries and kernel module
    Upload them to the NAS200

    Test:
    insmod iET kernel module
    execute iET binary

    As you can see I have a long way before it will work.
    Wish me luck! :biggrin:
     
  13. jackito

    jackito LI Guru Member

    Hi guys,

    I have good news. I managed to compile the iSCSI iET kernel module. I tested it and it is loading ok. :biggrin:
    On the other hand I spend almost all the afternoon trying to compile the binaries for iET without luck. I´m using iscsitarget-0.4.17.tar.gz. :(
    I can´t find the way to do it on Ubuntu 8.04 and as far as I can see Ubuntu is using a newer libc library than NAS200, etc. During the weekend I will keep trying (maybe with Gentoo instead of Ubuntu?) and updating any news here.

    Fernando
     
  14. jackito

    jackito LI Guru Member

    Finally I managed to get iSCSI support up and running on the NAS200.
    Check my other post with the announcement. :biggrin:

    Fer
     

Share This Page