HowTo's

From NAS-4220

Jump to: navigation, search

Contents

HowTo create an Application for the NAS4220


HowTo compile Programs

As the platform of the IB-NAS4220 is binary compatibel to IB-NAS1000/2000, packages can be compiled the same way. Links and pathes of both platforms are different therefore packages of both plattforms are not running on the other NAS.

Links to nas-2000.org:

How to update the IB-NAS4220 with a RAID1 (ext2/ext3) to harddrives with higher capacity

You don't need any extra harddrives for updating your drives without lose of your data.

These are the following steps which have to be done:

  1. remove your small harddrives from the IB-NAS4220
  2. install your new harddrives with the higher capacity in your NAS
  3. create a new RAID1 on the NAS
  4. attach your old harddrives to a PC with network connection
  5. boot your PC with a Linux Life-CD like Knoppix or install a driver for the ext2/ext3 filesystem on your Windows.
  6. copy your data over the net on your NAS

How to disconnect the samba-share in order to reconnect with another user-name

To log on to more than one smb-share simultanously using different user names does not work. You very likely will get an error message like this:

Image:netuseerror.jpg


If you need to access a different share, which asks for a different user, you need to disconnect the actual connection.

How to connect to the NFS-Share on MacOS

Manual way

To connect to the NFS-Shares from MacOS follow these steps:

  • Enable NFS (Control Panel-> File Server -> enable NFS Server)
  • Enable NFS-Access
  1. Control Panel -> Share Management -> mark the wished share [remember the selected sharename and path, you will need it later - eg. path: /mnt/md1 sharename: public] -> press "NFS Access" ->
  2. either "Allow for all" [insecure! only use it if your NAS is accessable only localy or you know how to secure your network!] or
  3. enter IP-Address or
  4. subnet (for example 192.168.100.0/255.255.255.0 for all networkdevices in 192.168.100.1 to .254)

-> "Add" -> "Save" -> "Save")

  • in MacOS open the terminal (Applications->Utilities) [personaly i recommend iTerm - but both will to]
  • make wished mountpoint on your local Mac eg. ~/Desktop/NAS-PUBLIC (your desktop)
  • then mount the NFS-Share there (replace NASIP, /mnt/md1, public and the local path to your needs)
   mkdir ~/Desktop/NAS-SHARE
   sudo mount_nfs -P NASIP:/mnt/md1/public ~/Desktop/NAS-PUBLIC
   # sudo-Password is your local Mac-Password!!!!

Faulty stuff for me was an "Operation not permitted"-error. The "-P"-switch helps on MacOS. Information for mounting the share at startuptime (and the missing hint for the problem) is taken from here - but right now i don't have time to verify this.

Mounting via GUI

  • Start Application->Utilities->Directory Utility. "Show Advanced Settings"->"Mounts", add new mount with "+"
  • "Remote NFS URL:" -> nfs://NASIP/mnt/md1/public <- replace NASIP, md1 and public for your own needs
  • "Mount location:" -> /Users/USER/MOUNTPOINT <- replace for your own needs
  • open "Advanced Mount Parameters" with the little grey arrow and enter "-P" (without quotation marks!)
  • "Verify" -> "Apply"
  • Done. The NFS-Mount will from now on be mounted at boottime.

Troubleshooting

After working with this for a while the connection doesn't establish any more. mount-command returns something like "mount_nfs: bad MNT RPC:"

Workaround: The hostname of the mac needs to be inserted into /etc/hosts of the NAS.

  • open System Preferences -> Sharing and remember Computer Name
  • open Terminal (look above), following should echo the same, else remember this one too
   hostname
  • connect to NAS and edit hosts. Use your own IP and MACNAME. If Computer Name and hostname aren't identical use both eg. MACNAME and MACNAME.local. Don't forget to make the backup of hosts! Next command will to a backup and write the necessary information to /etc/hosts
   cp /etc/hosts /etc/hosts.bak
   echo 192.168.100.2 MACNAME >> /etc/hosts
   #       ALTERNATIVE !!!!
   echo 192.168.100.2 MACNAME MACNAME.local >> /etc/hosts

It's strange but it works finally. Maybe we can get around this later on. Stay tuned ;)

ToDo

I've done some NFS-speedtests. It seems to me that ever higher the transferchunks ever better the whole performance. Not only the speed but also the cpu-usage. Therefor the options rsize,wsize or rwsize can be used. (mount_nfs -P -o rsize=10240,wsize=10240) If you don't know what you're doing don't do it ;)

HowTo use compiled programms of other distributions

When I was trying to x-compile perl for my 4220 I went into some trouble (some missing things and so on), so I decided try to use a precompiled perl package: For this purpose Debian fits quite well, just goto the Debian ftp-servers, download the package(s) you need (look for the dependencies!).

 Next unpack the .deb-file -> ar x package.deb
 the data.tgz contains the program including other files
 upload the extracted files from data.tgz to the NAS storage
 if required link the libaries to the matching dirs (e.g. /usr/lib ,...)

Have fun using the programs.

Installation of a Debian-System (chroot)

Following i did successfully. Even if i didn't like the chrootidea cause of the performance i'll give a short descrition.

 cd /mnt/md1/public/debian/
 tar xzvf SargeBook_v5.tgz
 mount -t proc none ./proc
  • chroot into it -
 usr/sbin/chroot ./ /bin/bash
  • modify /etc/resolv.conf so it's a nameserver in it eg. 192.168.1.1
 echo "nameserver 192.168.1.1" > /etc/resolv.conf
  • modify dist-mirrors and install some needed stuff (you may want some other location than ftp.de.debian.org ;) )
 echo "deb http://security.debian.org/ sarge/updates main contrib non-free" > /etc/apt/sources.list
 echo "deb http://ftp.de.debian.org/debian sarge main" >> /etc/apt/sources.list
 apt-get update
 apt-get install apt-utils
 apt-get install nano iptraf findutils
 apt-get upgrade
  • if wished, upgrade debian to etch:
 echo "deb http://security.debian.org/ etch/updates main contrib non-free" > /etc/apt/sources.list
 echo "deb http://ftp.de.debian.org/debian etch main" >> /etc/apt/sources.list
 apt-get update
 apt-get dist-upgrade
  • for startup i did following script (don't forget chmod 700 script afterwards):
 #!/bin/sh
 CWD=`pwd`
 cd /mnt/md1/public/debian/
 mount -t proc none ./proc
 mount -t sysfs none ./sys
 mount -t usbfs none ./proc/bus/usb
 usr/sbin/chroot ./ /bin/bash
 cd $CWD
 exit

Sources: nas-2000-wiki - Some inspiration from here

Move /system to USB stick - Solution for the spindown problem

The NAS4220 has problems with spindown. Some of the core processes access the hard disks frequently. On a basic system without any packages, these are accesses to the /system-filesystem in 99%, which prevents spindown. One possible solution is to move /system to an USB-stick, which is described here. A small stick (>=64MB) is enough. Everything has to be done connected as "root" (same password as "admin") via telnet or ssh (telnet can be enabled via http://ip-of-the-box/cgi/telnet/telnet.cgi ).

Prepare USB-Stick

Insert USB-Stick, the stick should automatically be detected as /dev/sda1 and mounted as /mnt/usb1. Check this with "mount".

Format USB-Stick with ext3:

  • umount /dev/sda1
  • mke2fs -j /dev/sda1
  • mount /dev/sda1 /mnt/usb1

Now copy /system to the stick with all folders and user privileges. This can be done with tar:

  • (cd /system; tar cf - .) | (cd /mnt/usb1; tar xf -)

Mount-Patch

To mount /dev/sda1 as /system instead of /dev/md0 at the next reboot, you can use the userscript extension (thanks to skara and streuspeicher). This is also the right place for the spindown commands for the hard disks (printed bold):

  • cd /mnt/md1/public/applications (or cd /mnt/ide1/public/applications at non-Raid systems)
  • mkdir usb-system
  • chmod 777 usb-system
  • cd usb-system
  • vi init
 HD_MNT_POINT=$(cat /usr/sausalito/codb/objects/1/Disk.rootdir 2> /dev/null) 
 CWD=$HD_MNT_POINT/public/applications/usb-system 
 exec $CWD/do-init >> $CWD/init.log 2>&1
  • vi do-init
echo "------ START $(date) -----" 
USB_MNT_POINT=/mnt/usb1 
USB_DEV=/dev/sda1 
echo "checking $USB_MNT_POINT ..." 
if [ -e $USB_MNT_POINT/ImageInfo ]; then 
  echo "remounting /system ..." 
  cd / 
  umount /system 
  if [ $? != 0 ]; then 
     echo "ABORTED: Failed to unmount old /system." 
     exit 
  fi 
  mount $USB_DEV /system 
  echo "DONE: Your NAS system is now running from USB stick:"
  echo "set spindown of /dev/hda and /dev/hdb to 10 minutes ..." 
  hdparm -S120 /dev/hda /dev/hdb
else 
  echo "ABORT: Found no USB device with valid system."
fi 
  • chown root:root *
  • chmod 777 *

Remarks:

  • This is a description for a 2 disk raid system, where the disk are normally mounted as /dev/md0 (/system) and /dev/md1 (/mnt/md1). For other systems some modifications are necessary (eg. /dev/ide1 instead of /dev/md0).
  • Some disks don't support spindown. Others don't support spindown time less than 10 minutes, you have to play arround a bit with the parameters of "hdparm -Sxx ...".
  • You can check the current spindown state with "hdparm -C /dev/hda" and "hdparm -C /dev/hdb".
  • After a reboot without the stick attached, the system is unmodified.
  • Other installed packages (ssh, webserver, ...) can prevent spindown further. In this case some further steps are necessary or remove unneeded packages.
  • All changes at the configuration (users, shares) have to be done twice, with and without the stick (or you have to copy /system to USB again).
  • If you want to know, which access causes the spinup, take a look here.

Guide to secure ftp

Here is how you can edit the configuration of the ftp-server, that users can only browse folders they are supposed to browse:

HowTo remotely reboot or turn off your IB-NAS4220

You might want sometimes to be able to restart or turn off your IB-NAS4220 with a script ran from another computer on the network. For example if you have an UPS, and your servers (including IB-NAS4220) connected to it, you might want your IB-NAS4220 to stop like the other servers in case of a long power failure, when UPS batteries are low and will be off soon.

The idea is to use a scriptable http client (here wget, but you can use curl, or perl, etc...) to simulate a use of the WEB administration interface of the IB-NAS4220. Here is the appropriate command :

wget -q -O /dev/null --http-user=admin --http-password=<myAdminPass> --post-data="powerAction=<ACTION_ID>" http://IB-NAS4220/cgi/power/powerHandler.cgi

Where myAdminPass is of course your admin account's password, and ACTION_ID is either 1 for a reboot, or 2 for a system turn off.

Remark: on my version of the firwmare (2.6.0.IB.1.RS.1), http-user and http-password are not mandatory because there is no security check on this URL...

How to use second hdd for sharing

Using JBOD or Span (that's no good idea at all ;)) you can't create a share at the second device. If your system is located at ide1, ide2 will be read/writeable to anybody. The solve this problem we create the share manually, all you need are the ssh- and userscript-packages. SSH is required to access and make changes to the system files. Userscript enables us to load our custom configuration at boot time. Install according the documentation. Don't forget to reboot after installation!

Please note: Beside following will work it may be not secure ! You may need to modify other active accesspossibilities (eg. ftp, nfs) too!

Samba Shares

  • make a backup of /usr/hddapp/etc/samba/smb.conf (if you don't know how you maybe would like to add a shortcut for it - once again ... don't forget to reboot!)
  • you will have something like this:
[ide2]
use receivefile=yes
create mask=0777
comment=IDE Disk
path=/mnt/ide2
directory mask=0777
writeable=yes
available=1
guest ok=true
use sendfile=yes
  • change this part to following (after making a copy of it!):
[ide2]
use receivefile=yes
create mask=0775
write list=mainuser,@writegroup
path=/mnt/ide2
directory mask=0775
writeable=no
available=1
valid users=otheruser,mainuser,@writegroup,@readgroup
use sendfile=yes
  • notice following changes:
    • create mask=0775
    • write list=mainuser,@writegroup
      • 'mainuser' is a username on your nas
      • '@writegroup' is the group 'writegroup' on your nas - that's what the symbol '@' stands for
    • directory mask=0775
    • writeable=no
    • valid users=mainuser,otheruser,@writegroup,@readgroup
      • 'otheruser' and '@readgroup' only are allowed to read here
      • it would be ok to only have groups and/or user as writable and/or readable. any combination is valid - at least anybody should have any rights at all, else it would be senseless ;)
  • according the examples at userscript-page place the changed smb.conf at userscript/config/smb.conf
  • place following as userscript/scripts/smbd.sh :
#!/bin/sh
#
killall smbd
killall nmbd
cat > /usr/hddapp/etc/samba/smb.conf < /usr/userscript/config/smb.conf
/usr/hddapp/etc/rc.d/S80samba.sh start
exit 0
  • restart the nas

With this little guide and a look at the official samba-documentation you should be able to create even other shares at this device. Only thing to do would be to create the directories manually (ssh).

NFS Shares

  • Make a backup of /usr/hddapp/etc/exports
  • Create a copy of the above file to /usr/userscript/config/exports, this will be used to store our custom NFS settings which will be loaded by userscript at boot time.
cp /usr/hddapp/etc/exports /usr/userscript/config/exports
  • Amend the /usr/userscript/config/exports file to share the ide2 drive. See the full NFS settings for complete options. In the example below, we have two NFS shares /mnt/ide1/public and /mnt/ide2/shared accessible by two IP addresses:
# /mnt/IDE1
/mnt/ide1/public 192.168.0.2(rw,root_squash) 192.168.0.3(rw,root_squash) 
# /mnt/IDE2
/mnt/ide2/shared 192.168.0.2(rw,root_squash) 192.168.0.3(rw,root_squash)
  • Create a script to be run by userscript which will stop the existing NFS server, load our custom config file and restart the NFS server. This file should be placed at /usr/userscript/scripts/nfsd.sh with the following contents:
#!/bin/sh
#
killall nfsd
cat > /usr/hddapp/etc/exports /usr/userscript/config/exports
/usr/hddapp/etc/rc.d/S85nfs.sh start
exit 0

Adding a serial port

See Adding a serial port

Personal tools
In other languages