Softwaredetails of the Conceptronic CH3SNAS

Supported protocols

Configuration interface showing servers
Configuration interface showing servers
A computer or user can communicate with the CH3SNAS using a range of protocols.

Servers

  • SMB/CIFS server
    This provides the basic file server functionality on the local-area network.
  • FTP server
    This is mainly for allowing the files to be accessed via the Internet. Such access will normally require some configuration of the home router/gateway as general access from the outside to devices on the LAN is normally filtered by the gateway’s firewall function. A typical router (e.g. Linksys WRT54G) can be configured to direct incoming ftp requests (port 21) to the IP address of the NAS. The NAS, in turn, can be configured via the browser interface to only allow access to some directories, to request a user/password or to give only read access.
  • Print server
    Technically this is part of the SMB/CIFS protocol suite. It allows the CH3SNAS to act as a print server on the local network.
  • uPnP (Universal Plug-and-Play)
    This is a set of protocols which allows the CH3SNAS to be discovered as a source of multimedia (music, video, pictures) and to allow a uPnP-enabled rendering device such as a network-enabled video renderer to see and access the available media. Probably the most common current uPnP-enabled rendering devices are Windows PCs running Microsoft Media Player.
  • iTunes server
    Essentially iTunes is, as a networking protocol, Apple’s proprietary counterpart to uPnP. Common iTunes rendering devices are computers running
  • HTTP server (limited)
    There is a small HTTP server to generate and process the HTML forms used to configure the CH3SNAS. That configuration interface can be accessed via a web browser using a computer on the local-area network (or if desired – mind the security – from the Internet). This HTTP server process is known as “Webs” and is from GoAhead. Users interested in using an HTTP server for other uses should consider installing the Lighttpd package under fun_plug.
  • DHCP server
    In case the CH3SNAS is used in a network without a DHCP server, the CH3SNAS can be configured to provided all devices with a unique IP-address. This will presumably be seldom used, but can help if you want to connect the CH3SNAS to, for example, a stand-alone laptop. The laptop sees a more or less fully functioning network without having to temporarily reconfigure the laptop to use static IP address.

Clients

  • NTP client
    The CH3SNAS can use the Network Time Protocol to get the current time from NTP servers on the internet.
  • DHCP client
    Although the CH3SNAS can be bound to a fixed IP address, it can also get its IP address from a local DHCP server.
  • E-mail client
    The CH3SNAS can be configured to automatically send e-mail to its administrator to notify about certain events.
  • FTP client
    The CH3SNAS can be configured to automatically download files at scheduled times from an FTP server.
  • HTTP client
    The CH3SNAS can be configured to automatically download files at scheduled times from an HTTP server.

Client/server

  • Telnet (requires fun_plug)
    The CH3SNAS contains support for establishing telnet sessions, whereby a remote user can login to the machine via an unsecure connection.
  • SSH (requires fun_plug)
    SSH is a modern successor to telnet. SSH fixes security problems in telnet by encrypting traffic between both machines.

Available firmware and upgrades

Conceptronic regularly provides updates of the firmware (embedded software, or if you like: operating system and servers) inside the CH3SNAS. These are available for download at Conceptronic.net. Test versions (betas and “release candidates”) are also made available for a more technical audience.

You may want to see our overview on all versions to see the new features and if any major issues have been reported. There is also a guide on upgrading the firmware available here

[ return to CH3SNAS page ]

Installation and Configuration of PHP on Fonz fun_plug 0.5

German version of this tutorial

This tutorial is deprecated and should only be used with fonz fun_plug 0.5!
Please check the tutorial page for updated tutorials on this topic!

PHP is a server-side scripting language that is widely used for developing dynamic web sites. PHP allows custom software to run on the server (in our case the NAS) hosting the web site.

Logo of PHPPHP scripts are typically embedded in HTML pages. When a browser requests such a HTML page, the scripts are executed by the PHP add-in module of the HTTP server (here: lighttpd). Usually the PHP code inserts some additional HTML content into the version of the HTML page that gets sent to the browser. The browser (“client”) itself thus doesn’t see the scripts which were executed on the server.

In this tutorial we assume that the lighttpd HTTP server is already installed on the NAS (see tutorial on installing lighttpd On bigger systems, PHP is sometimes used in combination with an Apache server (instead of the leaner lighttpd) and an SQL database. This widely-used bundle of software tools is sometimes known as LAMP: Linux, Apache, MySQL, PHP. The installation of MySQL on the NAS is covered in another tutorial.

Contents

PHP uses

With regular HTML pages, your web server can only provide static content: all users see the same set of pages and the pages don’t change until someone (e.g. manually) updates the stored HTML pages. A server-side scripting language like PHP helps if you need to add dynamic content, such as a visitor counter (see example code below) or maybe news-of-the-day.
Public domain as well as proprietary PHP software is available for various applications including:

Setting up PHP

Installation

Uli kindly provided a packaged version of php for the NAS in his repository.

PHP is not installed as part of fun_plug by default, but you should already have downloaded a copy as part of the general tutorial on how to download, install and upgrade packages. Let’s make sure you still have the latest version (as Uli upgrades his repository regularly). Note that the rsync command could take a while because it can download multiple packages depending on what is already in your /ffp/pkg/packages directory. Also note that you have to install curl additionally! As of PHP 5.2.17 you also have to install libiconv which is in fonz repository.

cd /ffp/pkg
funpkg -i /ffp/pkg/additional/dev-lang/php-*.tgz
funpkg -i /ffp/pkg/additional/net-misc/curl-*.tgz
funpkg -i /ffp/pkg/packages/libiconv-*.tgz

If you have a version of php installed that is outdated, you will need to run in upgrade mode instead (see here for help). Still, make sure you have curl and libiconv installed!

funpkg -u /ffp/pkg/additional/dev-lang/php-*.tgz
funpkg -u /ffp/pkg/additional/net-misc/curl-*.tgz
funpkg -u /ffp/pkg/packages/libiconv-*.tgz

Configuring PHP

PHP is configured with a file called php.ini. You thus need to copy one of the example-files from /ffp/etc/examples/ to /ffp/etc/ while renaming it to php.ini:

cp /ffp/etc/examples/php.ini-wolfuli /ffp/etc/php.ini

Configuring Lighttpd

To use PHP with the lighttpd-webserver, you have to use another configuration file as explained in the section on config files in the tutorial.

If you have a NAS other than the DNS-320, you execute the following:

cp /ffp/etc/examples/lighttpd.conf-with-php /ffp/etc/lighttpd.conf

If you have a DNS-320, you execute:

cp /ffp/etc/examples/lighttpd.conf-dns320 /ffp/etc/lighttpd.conf

Activation

Restart lighttpd to load the new configuration – including the PHP module. This can be done by rebooting the entire NAS or using

cd /ffp/start
sh lighttpd.sh restart

Testing PHP

You can test your installation of PHP by placing a file called index.php in the server.document-root directory (e.g. /mnt/HD_a2/www/pages) with the following content:

<H1>This is normal HTML</H1>
But the <U>following table</U> is generated by PHP:
<?php
phpinfo();
?>

PHP configuration information
PHP configuration information
Now go to the website on your NAS using the configured address and e.g. http://CH3SNAS:80. You should see a long page with configuration information for the PHP server as shown in the picture). This output is generated by the function call “phpinfo()“.

Using PHP

Let us now go back to a somewhat less intimidating and possibly even boring example: the standard “Hello World” in PHP. Copy and paste the following text to a file named helloworld.php and store it in the server.document-root:

<?php
echo "Hello World";
?>

Then go to the website on your NAS using the configured address and port and add /helloworld.php (the address may look like this: http://CH3SNAS/helloworld.php).

The following example shows a more complete web page (adapted from the lighttpd tutorial). It adds 3 features:

  • visitors are greeted using their IP address (using the $_SERVER['REMOTE_ADDR'])
  • any viewing of the web page triggers updates to a file (counter.txt) stored on the NAS
  • the web site uses counter.txt to show how often the page has been viewed

This requires three fragments of PHP code, each enclosed between and ?> tokens:

 
<?php
$fname = "counter.txt";             // The file where the number of hits gets stored
if(!file_exists($fname)) {          // If file doesn't exist..
    $countfile=fopen($fname,"a");   // .. create it
    $counter=0;                     // .. and initialize hit counter to zero
}
else {
    $countfile=fopen($fname,"r+");  // Open for read and write
    $counter=fgets($countfile,100); // Load number of hits by reading first 100 bytes
    rewind($countfile);             // Reset the file pointer to overwrite old counter value
}
$counter++;                         // Increment counter by one
fputs($countfile,$counter);         // Write the new value to the file
fclose($countfile);                 // Close the File
?>
 
<html>
    <head>
        <title>Hello PHP World!</title>
        <style type="text/css">
        <!--
                        h1 {text-align:center; font-family:Arial, Helvetica, Sans-Serif;}
                        h2 {text-align:center;}
                        p  {text-indent:20px;}
        -->
        </style>
    </head>
 
    <body bgcolor = "#ffffcc" text = "#0000ff">
        <h1>Welcome, <?php echo $_SERVER['REMOTE_ADDR']; ?>, <BR>to the PHP world</h1>
        <h2>This page was viewed <?php echo $counter; ?> times</h2>
        <p><A HREF="page1.html">Link to page1</A></p>
        <p><A HREF="page2.html">Link to page2</A></p>
        <p><A HREF="https://nas-tweaks.net/">external link</A></p>
    </body>
</html>

Output of final example
Output of final example
HTML output as visible using the browser's View Source feature
HTML output as visible using the browser's View Source feature

The first and by far the longest PHP section looks to see if a file name counter.txt exists in the server.document-root If it doesn't exist, it creates it and decides there have been zero hits so far ($counter=0). Note that variables in PHP do not need to be declared and start with a $ and that no clear distinctions are made between numeric and string variables: conversions are done on demand.

If the file already exists, the first 100 bytes (should be enough for a decent number) are copied into $counter. Then $counter is incremented, written to the counter.txt file and the file is closed.

The remaining HTML code is similar to the code in the lighttpd tutorial. In the level one header (H1), a string is generated by a PHP echo command which prints the IP address of the remote client. In the level two header the value of $counter that was previously computed is used.

Optional: Using shared extensions

PHP allows the use of additional modules, so called "shared extensions". E.g. there is calendar for calendar-related functions. The modules are stored in /ffp/lib/php/extensions/no-debug-non-zts-20060613/.

Available modules

You can list the available modules using:

ls -al /ffp/lib/php/extensions/no-debug-non-zts-20060613/*.so

As of version php-5.2.6-3 the following modules are available:

Module Description Requires installation of ffp package
calendar functions related to days/months/years and Unix timestamps -
ctype character type checking -
ftp File Transfer Protocol -
gd image processing libjpeg, libpng
mbstring manipulation of non-ASCII strings (e.g. unicode) -
mysql MySQL database access mysql
pdo PHP data objects -
pdo_mysql PDO interface to the MySQL database mysql
pdo_sqlite PDO interface to the SQLlite database -
sqlite SQLlite database access -
tokenizer access to PHP tokens found by the lexical analyzer -
zlib .gz file compression -

Editing php.ini

If you want to add one or more modules, you need to edit the file /ffp/etc/php.ini.
Open php.ini and find:

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

And add below the extension you want. E.g. to enable the calendar extension, you add:

; Linux extensions
extension=calendar.so
;extension=ctype.so
;extension=ftp.so

Afterwards you have to restart lighttpd to load the changes.

Demo of calendar extension

To see whether or not calendar was indeed loaded, you could run the PHPinfo.php script shown above.
Or run a script calendar.php containing:

<?php
for ($year=2000;$year<2011;$year++) {
    $days = cal_days_in_month(CAL_GREGORIAN,2,$year);
    echo "February in $year has $days days <BR>";
}
?>

Notes

PHP and HTML

A page with PHP code is generally stored on disk as HTML code with one or more fragments of embedded PHP. When the HTTP sends delivers the actual page to the browser ("client") the PHP sections have been interpreted and removed. In general they have been replaced by additional HTML code (see the counter example above). The receiving client thus does not see the PHP code and cannot even directly know whether PHP has been used to generate the served page.

Short open tag

If you want to use "<?" instead of "<?php" to mark the start of PHP code fragments, you need to change change the value of "short_open_tag" (line 131) in /ffp/etc/php.ini file to On:

short_open_tag = On

This is a matter of taste and convenience. When you distribute PHP code for use in other servers, you need to keep in mind that they may be set to short_open_tag = Off.

File extensions and default file names

HTML pages containing PHP code should have a .php extension. This tells the lighttpd server to pass the code via the PHP preprocessor before sending it across the network.

When you access the lighttpd server without providing a specific file name, it successively checks for files in the server.document-root directory(typically /srv/www/pages/) named

  • index.php
  • index.html
  • index.htm
  • default.htm

This is defined in a parameter called index-file.names in the lighttpd.conf file. As the list suggests, if you have both an index.php file and an index.html file in the same directory, the index.php file has precedence. If you explicitly ask for index.html, however, you will get that file instead of index.php.

Stateless

Note that after a page has been processed, when a new request for the same page is made by the same or another client, all computation starts from scratch: PHP is "stateless" in the sense that variables such as $counter are all lost after the page request has been completed. So the only way to track state in a PHP server is to store information in a file (as in counter.txt above), to store information in a database (another tutorial), or to assume the client maintains any relevant information between one page request and the next one.

Learning the PHP language

There are numerous books (printed and online) on PHP. See for example php.net.

Dealing with PHP errors

PHP syntax errors messages are appended to the Lighttpd error.log file. So if you are experimenting with- or developing PHP code, it can help to keep an eye on that file.

Busybox

This article assumes fun_plug is installed. It only explains what busybox is and how it works, so don’t expect to learn new useful Linux tricks.

Busybox calls itself “The Swiss Army Knife of Embedded Linux”. It is a single program that provides over 60 commonly used commands that are normally available on the Linux command line. Examples of such commands:

ls lists what’s in a directory
mkdir creates directories
tar creates/opens tarball files containing multiple files
cp copies files

In a standard Linux distribution these commands are separate programs. Busybox implements these programs (occasionally with somewhat reduced options) as a single executable program. Hence the “Swiss army knife” slogan. This saves space and maybe loading time, which is important for embedded Linux implementations.

To see what programs are handled by Busybox on the CH3SNAS you can use the following command within an ssh (PuTTY) session:

cd /bin
ls -l | more

The piping via more allows you to view the folder listing produced ls at your own pace. Use the spacebar to see more of the listing, and q to quit the more utility. The output will contain dozens of lines like:

lrwxrwxrwx    1 root     root            7 Apr  1 12:53 ln -> busybox
lrwxrwxrwx    1 root     root            7 Apr  1 12:53 ls -> busybox
lrwxrwxrwx    1 root     root            7 Apr  1 12:53 md5sum -> busybox
lrwxrwxrwx    1 root     root            7 Apr  1 12:53 mesg -> busybox
lrwxrwxrwx    1 root     root            7 Apr  1 12:53 mkdir -> busybox

Essentially this says that, for example, the file /bin/ls is a symbolic link (“->”) to the program /bin/busybox. You can get a feel for for this by trying

busybox ls -l /bin/busybox

yourself and seeing that it performs the same as typing ls -l /bin/busybox directly. Typing busybox without any parameters gives information like the program version and a list of all supported commands.

Conceptronic CH3SNAS

Conceptronic CH3SNAS Black Edition
Conceptronic CH3SNAS
The CH3SNAS is a Network-Attached Storage device manufactured and marketed under the Conceptronic brand. This brand is owned by the 2L Alliance based in The Netherlands.

The CH3SNAS is essentially a small file server which you connect to a local TCP/IP network via an ethernet cable. In a home network, the CH3SNAS will typically be connected via a UTP cable to a router. The CH3SNAS can contain up to two 3.5 inch SATA drives (which can be sold bundled with the actual CH3SNAS). The drives can have any capacity (typically 0.2-1 TBytes/drive). If two drives are used (for extra capacity or to enable RAID 0 and 1 modes), they do not need to have equal storage capacity or be of the same brand.

The CH3SNAS is internally a small, networked Linux computer with one or more shared (logical or physical) network drives. The CH3SNAS is primarily intended to store files that can be accessed by a computer on the local network.

One specific application highlighted by the vendor is to stream audio or video from the CH3SNAS to other networked devices such as laptops or a Playstation 3. Alternatively it can centrally store media, which can then be copied to smaller portable devices (Conceptronics markets their storage product line with the slogan Grab’n’Go).

Files can optionally be accessed across the internet (via an FTP server, which is disabled by default for security reasons). As a bonus, the CH3SNAS can also act as a print server, thus converting a printer with a USB port into a printer than can be shared across the local-area network.

CH3SNAS Usage

The CH3SNAS caters to a wide range of users:

  • average home PCs users with a wired or wireless network
  • users interested in computing technology (and thus interested in trying out more advanced featues)
  • tweakers who are willing to spend significant amounts of time to tune/adapt the (and may thus actually extend the system – which is internally Linux-based).

More information on target users, target usage, and interoperability with various operating systems can be found in the article on Usage-Scenarios.

Hard disk configurations

The CH3SNAS can be operated with a single or dual 3.5 inch hard disk of any capacity or brand. When the system is initialized, the user has the option of creating partitions (volumes) which can be on a single disk or span both disks. A list and discussion of the possible storage configurations can be found in Configuration Options.

Hardware

Marvell 88F5182 in the Conceptronic CH3SNAS
Marvell 88F5182
Externally, the CH3SNAS has a Gigabit Ethernet connector, a USB port for connecting a printer, a connector for the supplied power supply, a single on/off button, four status LEDs and a somewhat hidden reset button.

The internals obviously consist of the hard disks themselves (which may come with the CH3SNAS, but can also be purchased seperately) and a circuit board that houses the processor and memory chips which form the small computer which contols the hardware and provides the numerous software features. Unlike destop PCs or laptops, the computer is not hardware upgradeable. The central chip is a complex System-on-Chip manufactured by Marvell (Marvell Feroceon 88F5182). More hardware details and photos of all key components can be found in Hardware.

Software

Webbased Configuration
Webbased Configuration
The software running on the embedded processor core is mainly needed to support the following features:

  • SMB/CIFS (file server for a LAN)
  • FTP (file server for usage across the Internet)
  • Print server (connect a USB printer to the network)
  • uPnP (multimedia server)
  • iTunes server (Apple’s multimedia server)

More software details on these protocols and a more extensive list of modules can be found in [[CH3SNAS:Software]] [[XXX]]. The software also includes a configuration interface which be access via a web browser (similar to the way routers are typically configured).

This Linux-based software is stored in an on-board non-volatile Flash memory which allows the CH3SNAS to boot even when the hard disks are not yet operational. The softwarecan be updated to newer firmware versions via the web-based configuration interface. In addition, the CH3SNAS (as well as various similar devices) have options to allow the more technically inclined to add scripts or even additional servers without having to recompile code or even without having to modify the content of the Flash (via the so-called fun_plug technique).

References

More detailed versions of the above abridged sections can be found on separate pages in this blog:

CH3SNAS:References provides links to important external sites about the CH3SNAS.

Configuration options of the Conceptronic CH3SNAS

The CH3SNAS uses the Linux ext2 file system, and thus cannot preserve data which was written to the hard disks (e.g. using Microsoft Windows) before these are inserted into the CH3SNAS: reformatting will normally be necessary for both a new and a used hard disk. Lets assume the drives have storage capacities of respectively C1 and, if a 2nd drive is present, C2 Gigabytes. The CH3SNAS supports a number of different ways in which to format individual hard disk partitions using the built-in web interface:

  • Standard – each drive can be accessed as a different volume (results in a volume of size C1 and, if present, C2)
  • JBOD – Just-a-Bunch of Disks, allowing both drives to be accessed as a single large volume (of size C1+C2)
  • RAID 0 – files are “striped” over both drives, thus potentially giving higher performance (resulting in a single volume of size 2*min(C1,C2))
  • RAID 1 – files are automatically mirrored at the sector level on both drives, thus allowing data recovery if either drive fails. RAID 1 results in a single volume of size min(C1,C2). Note that this occupies 2*min(C1,C2) of total disk space.

Configurations 2, 3, and 4 require a dual-drive system. A RAID 0 or 1 volume can be no larger than the smallest of the two drives, but can optionally be configured to be smaller than min(C1,C2). Any remaining space on both drives becomes accessible as a single JBOD volume.

Consequently, a dual-drive system can support up to 6 alternative configuration options:

  • Two Standard volumes
  • A single large JBOD volume
  • A single RAID 0 volume (if both drives have the same size, and no JBOD volume is needed)
  • A single smaller RAID 1 volume (if both drives have the same size, and no JBOD volume is needed)
  • A RAID 0 volume and a JBOD volume
  • A RAID 1 volume and a JBOD volume (see screen shot)

  • It may be possible to create other working configurations (such as RAID 0 + RAID 1 + JBOD), but these cannot be created using the built-in configuration interface and will probably not have been tested.

    Under Windows, volumes can be assigned user-selectable drive letters (such as R: for a RAID).

Usage scenarios and target users of the Conceptronic CH3SNAS

Target users

The CH3SNAS seems to be targetted at home users with enough experience to set up a basic wired- or wirless network. Some effort was clearly invested in making the configuration of the system painless. The device and its manual thus do quite some handholding for the novice user to get the device to work as intended. The device and its manual unfortunately do not provide guidelines for novice users about suitable backup strategies or ways to safeguard their data. This may be current practice for this type of product, but is a problem when you give novice users the storage capacity to e.g. save all their home videos on a single drive or device. [IMO vendor should do something about this in printed manual, but volunteer to create a page on [[Data backup do’s and don’ts]]?]

The device does contain some optional features and settings (such as an FTP server or options for setting IP addresses) which are suited for more technically oriented users.

For the real enthusiasts (hobbyists, students, IT professionals) the CH3SNAS and some of its competitors provide

Compatibility with Microsoft Windows

The CH3SNAS is simplest to access for PCs running a version of Windows. This is because the access protocols are based on a set of proprietary Microsoft standards (MSB/CIFS) which are supported by Windows itself. Thus, to a PC running Microsoft Windows, the NAS looks exactly like another PC with one or more shared drives (see screenshot) and possibly a shared printer. No special software is therefore needed under Microsoft Windows to access or configure the CH3SNAS.

Although an EasySearch utility is provided to simplify initial network setup for non-technical users, it is relatively easy to set up the NAS without this using the written documentation. The actual configuration of the NAS (e.g. drive formatting, access control, enabling FTP) is done using a web browser (default IP address 192.168.0.20).

Compatibility with Linux PCs

Internally, the device runs a small Linux distribution and an open-source file sever (called a Samba server). This is presumably to keep the materials costs (smaller processor, less emory), development cost (open source) and power consumption of the device down.

The CH3SNAS can also be accessed by Linux PCs: although LINUX natively tends to use a UNIX equivalent (NFS) to the Microsoft protocols provided by the CH3SNAS, Samba client support is relatively standard in Linux distributions. Although setting up access to from a Linux PC will, however, be a bit trickier than from a PC running Microsoft Windows, this is not necessarily an issue for typical Linux users.

Alternatively, Linux PCs users can access an implementation of NFS which is hidden in the 1.03 firmware, but is not accessible via the web-based configuration interface (yet). A tutorial on to access this hidden feature will be provided in the future. For urgent needs, see the personal Blog of Dennis, a former employee of Conceptronic.

Compatibility with Apple computers

The CH3SNAS does not natively support Apple’s AppleTalk protocol suite (roughly Apple’s equivalent of Microsoft’s SMB/CIFS). Modifications are possible to support this. This involves installing the open source Nettatalk server via the use of FunPlug.

Compatibility with the Playstation 3

The CH3SNAS is sometimes used with Sony’s Playstation 3 for wireless streaming of multimedia. In this scenario, the PS3 discovers the CH3SNAS using uPnP and uses uPnP to display available tracks/videos.

Compatibility with the XboX 360

As of Firmware 1.05, the CH3SNAS can be discovered by the XboX 360 for streaming multimedia content to the XboX.