Inspired by this Thread, i (Uli) did a rewrite of the store-passwd.sh-script. You need to use BASH for this to execute. Better use the Script above if you are not sure!
#!/ffp/bin/sh# This script was written by Ulrich Wolf <ffp [a] wolf-u [dot] li># Inspired by the original Scripts of fonz and OneArmedMan# Defining the various locations for these files:
BACKUPLOCATION[0]="/sys/mtd1"
BACKUPLOCATION[1]="/sys/mtd2"
BACKUPLOCATION[2]="/mnt/HD_a4/.systemfile/AccountFile"
BACKUPLOCATION[3]="/mnt/HD_b4/.systemfile/AccountFile"# Defining the backup-locations of the files
BACKUPFILE[0]="/etc/shadow"
BACKUPFILE[1]="/etc/group"
BACKUPFILE[2]="/etc/passwd"
BACKUPFILE[3]="/etc/samba/smbpasswd"# Inactive Files#BACKUPFILE[4]="/etc/ftp_tbl"#BACKUPFILE[5]="/etc/ftpgroup"# Mounting the internal DRAMmount-t minix /dev/mtdblock0 /sys/mtd1
mount-t minix /dev/mtdblock1 /sys/mtd2
# Iterate through the files for backup of the filesfor BUFILESEQ in $(seq0 $((${#BACKUPFILE[@]} - 1)))do# Iterate through the backup-locations of the filesfor BULOCSEQ in $(seq0 $((${#BACKUPLOCATION[@]} - 1)))doif[-e${BACKUPLOCATION[$BULOCSEQ]}/${BACKUPFILE[$BUFILESEQ]##*/}]; then# File exists, copy the original oneecho-n"${BACKUPFILE[$BUFILESEQ]##*/} found in ${BACKUPLOCATION[$BULOCSEQ]}, copying"cp-f${BACKUPFILE[$BUFILESEQ]}${BACKUPLOCATION[$BULOCSEQ]}/. 2>/dev/null &&echo"done"||echo"failed"else# File does not exist, skipecho"${BACKUPFILE[$BUFILESEQ]##*/} not found in ${BACKUPLOCATION[$BULOCSEQ]}, skipping"fidonedoneecho-n"Flushing unwritten filesystem I/O buffers..."sync&&echo"done"||echo"failed"# Unmount the internal DRAMumount/sys/mtd1
umount/sys/mtd2
echo"Backup complete"exit0
Logo of MySQLAn RDBMS is a software tool to store, access and update (often large) amounts of data structured as interrelated tables. Originally, databases were typically used for adminstrative purposes such as storing employee- or inventory information. Nowadays, databases are also widely used to store the raw content from which dynamic web sites are generated. This allows the same information to be presented in different ways. Because SQL is a standardized language to update or access an RDBMS, it also avoids relying on proprietary storage formats with associated risks of obsolescence or lock-in to particular software.
Although there are various other open source and commercial RDBMS systems available, MySQL is commonly used in web development in conjunction withLinux, Apache (or lighttpd), and php. Wikipedia, for example, runs on MediaWiki software written in PHP and uses a MySQL database.
Uli kindly provided a packaged version of MySQL for the NAS in his repository.
MySQL 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 first make sure you still have the latest version (as Uli upgrades his repository regularly).
Note that the installation command below could take a while:
funpkg -i/ffp/pkg/additional/*/mysql-*.tgz
If you have a version of mysql installed that is outdated, you will need to run in upgrade mode instead (see here for help):
funpkg -u/ffp/pkg/additional/*/mysql-*.tgz
Configuration
MySQL can be configured with a file called my.cnf. After installation you can configure several MySQL settings by copying an example-file from /ffp/etc/examples/mysql/ to /ffp/etc/:
MySQL stores the data of its databases in files which are in turn stored in a directory named /srv/mysql/. Instead of creating the directory at that location, you may prefer to create a symbolic link from /srv/ to the target-directory of your choice.
First we create it:
This link will be lost after rebooting the device, so you have to add the following two lines to the end of the file /ffp/etc/fun_plug.init to recreate the link every time the NAS boots. You can edit this file using an editor like nano:
# create custom link to the server-folderln-s/ffp/opt/srv//srv
Initialization
MySQL needs some internal databases for the initial startup which can be installed by issuing the mysql_install_db command:
cd/srv/ls-al/ffp/bin/mysql_install_db
ls-al
This results in several warnings (which you can ignore) about adjusted sizes system- and help tables. Typical partial output:
081116 22:05:32[Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
081116 22:05:32[Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
081116 22:05:32[Warning] option 'myisam_max_extra_sort_file_size': unsigned value 2147483648 adjusted to 2147483647
081116 22:05:32[Warning] option 'thread_stack': unsigned value 65536 adjusted to 131072
Now we manually start the MySQL server for further configuration:
sh /ffp/start/mysqld.sh start
Note that you will have to press Enter to get your prompt back (unlike other daemons).
After the first start, we have to secure the installation:
/ffp/bin/mysql_secure_installation
You will be asked several questions (shown below in abridged form) and can answer Y(es) for each of them.
For "Enter current password for root (enter for none):" you press enter because the default root password is empty.
For the new root password, it is best to use a different password than the user root of the system: this is just for owning the administration rights to the database and is unrelated to overall control over the machine.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
All done!
After MySQL has started, you can test your installation using the following ways:
Command-line
Enter the following command on the command-line:
mysql -p
This will open a special mysql-command-line, where you can enter regular SQL-Commands. Now change to the database “mysql”:
USE mysql;
Then select the Host, User and Passwort from the Database:
SELECT Host, User, Password FROM user;
Finally exit the mysql-command-line:
exit;
A sample output will look like this:
root@CH3SNAS:/srv/mysql# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.67 Source distribution
Type 'help;' or '\h'for help. Type '\c' to clear the buffer.
mysql> USE mysql;
Database changed
mysql> SELECT Host, User, Password FROM user;
+-----------+------+-------------------------------------------+
| Host | User | Password |
+-----------+------+-------------------------------------------+
| localhost | root |*8D2414F01991E3B0B86E14D2469EACA0B6D78B99 || CH3SNAS | root |*8D2414F01991E3B0B86E14D2469EACA0B6D78B99 || 127.0.0.1 | root |*8D2414F01991E3B0B86E14D2469EACA0B6D78B99 |
+-----------+------+-------------------------------------------+
3 rows inset(0.01 sec)
mysql>exit;
Bye
By the way: As you can see, passwords are crypted (in this case it was “nas-tweaks.net“).
PHP
For the following, you need to install lighttpd and php in case you haven’t already done so.
You also need to enable the mysql module of lighttpd by editing the /ffp/etc/php.ini file:
; Linux extensions
extension=calendar.so
;extension=ctype.so
;extension=ftp.so
;extension=gd.so
;extension=mbstring.so
extension=mysql.so
;etc
Make sure you define the folder which contains all the above modules in line 536 of the php.ini file. Usually it should be:
You will need to restart the web server if you enabled the my-sql extension, or changed the extension_dir using:
sh/ffp/start/lighttpd.sh restart
Then place a file called testmysql.php in the document-root (as configured here e.g. /srv/www/pages) with the following content (replace YOURROOTPASS with the password of mysql user root):
<?php// Connect to the databasemysql_connect("localhost","root","YOURROOTPASS");// Select the database "mysql"mysql_select_db("mysql");// Query the database for the Users:$result=mysql_query("SELECT Host, User, Password FROM user;");// Print the resultswhile($row=mysql_fetch_object($result)){echo$row->User."@".$row->Host." has the encrypted password: ".$row->Password;}// Close the connection to the databasemysql_close();?>
If opening this page in your browser doesn’t give the expected results, check the password, and if needed close and open the browser again.
When you are done, you may want remove the root password (or delete this .php file) to avoid exposing the mysql password in the line mysql_connect("localhost", "root","YOURROOTPASS");.
Users and privileges
Adding additional Users
As you should never use the root-password of your database, you can add additional users in the mysql-command-line (enter “mysql -uroot -p” on the command-line).
Please consult the mysql-manual for more examples.
A User with all privileges, who can only connect from localhost:
After you send add or alter the rights, please make sure, that these get loaded by executing the following command in the mysql-command-line:
FLUSH PRIVILEGES;
Allowing external access
Per default external access is not allowed as this is a security risk. But many tools like HeidiSQL or other external administrator-programs rely on access from the outside of your NAS.
Caution: You should explicitly check the rights of your users! All MySQL-users should have passwords!
Edit /ffp/etc/my.cnf and add a comment to the line skip-networking, so that it looks like this:
#skip-networking
Edit /ffp/start/mysqld.sh and find the line beginning with mysqld_flags and remove “--skip-networking” between the two quotation marks. Save the file afterwards.
Running mysql under a user with limited rights
Per default the MySQL gets started with root-rights. This means, that if the MySQL-server is breached by a intruder, the system probably can be corrupted. Be advised to use the mysql-server only in secure areas (e.g. your local LAN without internet access) and to disable external access (default).
If you want to secure your installation please follow the following steps:
Stop the mysql-server:
sh/ffp/start/mysqld.sh stop
Add a new user with limited rights:
useradd -U-s/bin/false mysql
store-passwd.sh
This will create a user mysql who is in the group mysql (-U add a new group) and who cannot log in. It will probably show up in the Webinterface, but cannot be used!
This user needs access to the directories of MySQL:
cd/srv
chown-R mysql:mysql mysql
cd/ffp/var/run/chown mysql:mysql mysql
Edit /ffp/start/mysqld.sh and find the line beginning with mysqld_flags and remove “--user=root” between the two quotation marks. Save the file afterwards.
Then start MySQL again:
sh /ffp/start/mysqld.sh start
With these changes, MySQL is started under the user mysql.
Removing MySQL
If you want to remove MySQL and its databases, you proceed like described in the general tutorial on packages.
First, stop mysql:
sh/ffp/start/mysqld.sh stop
Then remove the package with funpkg:
funpkg -r/ffp/pkg/additional/*/mysql*.tgz
Afterwards you have to remove the databases (careful!). Change to the folder /srv/ and delete the folder mysql:
cd/srv/rm-R mysql
Furthermore, you should undo the change in /ffp/etc/fun_plug.init, possibly remove the (harmless) symbolic link /srv/, but especially disable execution of the startup script:
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!
The lighttpd daemon is a lightweight web server. Its main task is to respond to HTTP requests. In other words, it allows HTTP clients (such as Internet Explorer and Firefox) to retrieve hyperlinked HTML pages stored on a web site stored on the CH3SNAS.
The lighttpd server allows you to build a web site which is accessible via your local area network (LAN). If you configure your router’s firewall properly, you can also let others access the website via the Internet. Opening your firewall to give access to outside HTTP requests obviously requires paying some attention to security.
A basic web site consists of a collection of HTML pages which provide text, links, images, documents, etc. HTML pages can be written with an ASCII editor. There are numerous books and online tutorials on how to create basic and advanced web pages directly in HTML. This can be worth trying if you want to understand how the World Wide Web works: HTML is the main technology behind WWW.
In recent years, however, the average web page has gotten increasingly sophisticated in terms of its technical and visual design. Furthermore, the content of many web sites has become dynamic: what you see in your browser often changes daily (the weather, the news, a blog, photos). Such dynamic HTML pages are generated (by running programs or scripts) whenever the set of HTML pages needs to be updated, or are created on the fly whenever the server receives a page request.
Some examples of what you can do with a web site consisting of basic, static HTML served via lighttpd:
a basic home page telling who you are
a set of pages about your hobby, your recipes, or reporting on your holiday trip (all with embedded pictures)
Using this approach you “program” your page using the HTML language.
Examples of ways to generate ”’fancier static HTML”’ pages using software:
Microsoft Word can generate a HTML version of a document (including formatting, links and pictures)
professional photographers may use Photoshop Lightroom to generate an online gallery of sample pictures
Using this approach you use software to generate the HTML pages. This means you don’t need to learn (much) HTML, but instead need to learn how to use the (often fancy) software. All-in-all this can save you some typing and helps generate a uniform look for the web site.
Examples of applications involving generating dynamic HTML pages:
a Blog or Forum contains HTML forms that allow users to type in text that is appended to certain pages. Example: NAS-Tweaks uses a PHP server and software by WordPress for its Blog. Often this approach uses a database like MySQL to store and manage the raw data used to generate the HTML.
many well-known Web 2.0 sites that provide a service for you (WikiPedia, Google Maps, YouTube, Flickr)
Using using this approach, software generates HTML pages on demand, keeps the pages updated, and allows interaction with the user. If you go overboard on this, and manage to get the users of your website to provide content which keeps you web site interesting, you can call this Web 2.0 and tell your friends you may become rich – someday.
This kind of software is often known as Content Management Systems and includes engines like Drupal, Joomla, Mediawiki (as used by Wikipedia) and WordPress (as used for blogs).
Setting up Lighttpd
Installation
By default a lighttpd is already installed with the fun_plug packages. But there is an update available. Before you can install it, be sure to synchronize my repository. Then update using the following command:
funpkg -u/ffp/pkg/additional/*/lighttpd-*.tgz
If you didn’t install all packages from the “packages”-directory (why not?), you should execute at least the installation of the OpenSSL-package:
funpkg -i/ffp/pkg/packages/openssl-*.tgz
Directories
The default lighttpd configuration needs a small directory tree where it can store logfiles and retrieve the data to display to the users. Instead of creating the directory at that location, you may prefer to create a symbolic link from /srv/ to the target-directory of your choice.
mkdir-p/ffp/opt/srv/mysql
ln-s/ffp/opt/srv//srv
This link will be lost after rebooting the device, so you have to add the following two lines to the end of the file /ffp/etc/fun_plug.init to recreate the link every time the NAS boots. You can edit this file using an editor like nano. Use the following for all NAS other than the DNS-320 or DNS-325:
# create custom link to the server-folderln-s/ffp/opt/srv//srv
The folder /srv/www/pages is the default location for the web site itself. The location is set via a parameter called server.document-root in the /ffp/etc/lighttpd.conf file. This means that any directories below server.document-root are visible via the HTTP server (careful), while any other directories are not visible.
The folder /srv/www/logs is for log files in which lighttpd can record what happened.
HTML test pages
Within the www folder, you should create a home page named index.html containing the following ASCII text. Note that the indentation is only for readability and can be (and often is) omitted. You don’t need to worry about using Linux or Windows end-of-line conventions here (both work). You may have to adapt the line CH3SNAS:81 to reflect the network name of your NAS or use its IP address instead (e.g. 192.168.0.20:81).
<html>
<head>
<title>Hello world</title>
<style type="text/css">
<!--
h1 {text-align:center;
font-family:Arial, Helvetica, Sans-Serif;}
p {text-indent:20px;}
-->
</style>
</head>
<body bgcolor="#ffffcc" text="#0000ff">
<h1>Hello, CH3SNAS Tweak'n World!</h1><p>
<A HREF="page1.html">Link to local page1</A><p>
<A HREF="page2.html">Link to local page2</A><p>
<A HREF="http://CH3SNAS:81">Configure the CH3SNAS</A><p>
<A HREF="https://nas-tweaks.net/CH3SNAS:Tutorials/lighttpd">external link to the Lighttpd tutorial</A>
</body>
</html>
The HTML code consists of a head and a body section. The head contains the title (shown at the top of the browser window) and, in this case, defines formatting styles for Header1 and new paragraph (<p>).
The body starts with a header, followed by four links (“<A>nchors”) to other pages, to the original HTML configuration page for the CH3SNAS (on port 81 instead of the default 80) and a link to a remote web site.
Then create page1.html in the same directory containing:
This tutorial assumes that fun_plug is installed and that you have installed the additional packages (these include lighttpd). You can test whether lighttpd is installed using
which lighttpd
on the ssh command line. If it is installed, it will respond with the location of the lighttpd script file: /ffp/sbin/lighttpd.
Waking up daemons
Next we need to enable the lighttpd server from the command line (see the packages tutorial for a detailed explanation):
chmod a+x /ffp/start/lighttpd.sh
and enable a script which disables the standard HTML server called webs (if you are running a DNS-320 / DNS-325 please skip this step and go to the following section):
chmod a+x /ffp/start/kickwebs.sh
The standard “webs” server then restarts automatically within a few minutes, but moves to port 81 because the standard HTTP port (80) is already occupied by the lighttpd server.
If you are running a DNS-320 or a DNS-325, you need to enable “kickwebs_dns320.sh” for kicking the internal lighttpd (which is used for the Webinterface of the Device) from Port 80:
chmod a+x /ffp/start/kickwebs_dns320.sh
Note that the chmod commands only take effect on the next reboot. If you would reboot now, however, nothing changes. If you want to try, you can see test this manually using:
sh/ffp/start/kickwebs.sh start # When you run a Device other than DNS-320 / DNS-325sh/ffp/start/kickwebs_dns320.sh start # When you run a DNS-320 / DNS-325sh/ffp/start/lighttpd.sh start
Unless you have installed the server before, you will get the error message /ffp/etc/lighttpd.conf: Required file not found or not readable. Which, by Linux standards is an unusually clear error message: a file with configuration settings for lighttpd is missing in the /ffp/etc directory (see the packages tutorial for more explanation).
lighttpd.conf
We can resolve the missing /ffp/etc/lighttpd.conf file by copying the file from the directory /ffp/etc/examples/. If you are not on a DNS-320 or a DNS-325 and you don’t need PHP, then run the following command:
cp/ffp/etc/examples/lighttpd.conf /ffp/etc/
This copies one of the two supplied configuration files from the /ffp/etc/examples subdirectory to the /ffp/etc directory.
if you want to run PHP and you are not on a DNS-320 or a DNS-325, then run the following:
If you are on the DNS-320 or DNS-325, you have no choice but to run the Webserver with PHP (Please configure PHP before you try starting lighttpd again!):
Next we can try starting lighttpd manually again to see how we are doing:
sh/ffp/start/kickwebs.sh start # When you run a Device other than DNS-320/DNS-325sh/ffp/start/kickwebs_dns320.sh start # When you run a DNS-320 / DNS-325sh/ffp/start/lighttpd.sh start
sh/ffp/start/lighttpd.sh status
Example HTML page being hosted by LighttpdAs, this suggests that lighttpd is now happily running, we try typing http://CH3SNAS:81 in the address bar of your Web browser. Note that if your network name for the device differs from “CH3SNAS“, use that name or its IP address instead. You should now get the standard configuration screen. Please remember the :81 port number in case you need to access it in the future (it is one more than the standard port 80 used for HTTP servers – which you can look up on the internet). You can close that screen – it was only to demonstrate that kickwebs.sh did its job.
We now try entering http://CH3SNAS in the address bar of the Web browser. If all goes well, you will see the expected web page.
To boot or not to boot
Remember that you now have a lighttpd running on port 80 each time you boot the NAS. If you want to connect to the Webinterface of the NAS, connect to Port 81.
Testing Lighttpd
At this point, you can enter any of the following into your browser’s address bar (assuming CH3SNAS is the correct network name of your NAS):
http://CH3SNAS:80/index.html
http://CH3SNAS:80 – index.html is a default for browsers
http://CH3SNAS – port 80 is default for HTTP
CH3SNAS – http is the default protocol for web browsers
Notes
The log files
The directory /srv/www/logs contain log files which respectively record the access to the server and any errors (including starting and stopping) reported by the server.
-rw-r--r--1 root root 0 Oct 1917:06 access.log
-rw-r--r--1 root root 48 Oct 1917:06 error.log
If you want to clear the log files, one quick-and-dirty way to do so is to delete them and restart the CH3SNAS. The lighttpd server will regenerate the log files when it is started. A quicker approach is to restart the lighttpd server using:
rm/srv/logs/access.log
cd/ffp/start
sh lighttpd.sh restart
Now What?
You should now install PHP if not already installed and try using MySQL. Have fun 🙂
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!
The CH3SNAS, as well as other small nas devices, has a small fan at the back. This fan is necessary because the NAS can generate significant amounts of heat when one or two drives are used heavily.
CH3SNAS fanAlthough the fan is speed-controlled through software provided by Conceptronic, the fan never switches off completely. Some people find this too noisy for quiet environments like bedrooms or even some offices. An obvious solution is to turn the CH3SNAS off entirely when it is not in use (e.g. at night), but this is very inconvenient and it gives problems when the CH3SNAS may be accessed occasionally by remote (Internet) users.
Thanks to the fun_plug, the user can change the fan control algorithm to reduce noise, save a bit of power and reduce wear on the fan itself.
By default, the fan is controlled by a program embedded within the CH3SNAS called fancontrol. This program adjusts the fan speed depending on the temperature measured inside the CH3SNAS.
Conceptronic also provides two other utilities which are helpful to control the fan:
temperature – shows the actual temperature (on some devices in Fahrenheit and on others in Celsius) by entering the command "temperature g 0"
fanspeed – returns the current fan speed when you enter "fanspeed g". It can also set a new fan speed by entering the command "fanspeed w YourFanSpeed" (where YourFanSpeed is the desired speed in Rotations Per Minute).
Using shell scripts versus using binaries
There are different ways to control the fan. In any case the new software needs to stop (“kill”) the built-in fancontrol program provided by Conceptronic before it takes over control.
One approach is to use the programs temperature and fanspeed within a simple bash script that repeatedly measures the temperature and adjusts the fan speed accordingly. Such a script can even choose to turn off the fan entirely below a certain temperature. But a script-based approach, which, compared to a compiled C program, uses more (valuable) memory and CPU cycles.
Fortunately Fonz, the author of fun_plug, has written a small and efficient binary program named fanctl. It controls the fan without relying on the temperature and fanspeed) programs and without using the bash shell. This efficiency is nice as the program is intended to run as long as the CH3SNAS is powered up. By default, fanctl adjusts the fan speed every 30 seconds if needed.
Installation
Installing fanctl
Uli has created a package to simplify installation of fanctl.
In this tutorial we assume that the fun_plug is already installed on the NAS and that you synchronized Uli’s repository (see here for instructions on how to do this). Afterwards install the package (see detailed instructions here):
The final steps copies default configuration settings to the appropriate directory.
Activating fanctl
Please make sure, that no other scripts than the original fancontroller are active! You can check this by:
ps aux|grep fan
This should show the following output (the process identification numbers will vary):
1431 root fancontrol
12620 root grep fan
These are all the running processes (ps) which were filtered (grep) on whether they include the text fan somewhere in their name. Despite appearances, [http://en.wikipedia.org/wiki/Ps_(Unix)#Options aux] is not a command or name, but 3 separate options for ps with a missing “-” this time.
Now test the first run of the fanctl script by entering the following command on the command line:
sh/ffp/start/fanctl.sh start
After entering the above command, the fan will run with a audible noise for a few seconds. You can check the correct opertion of fanctl now:
ps aux|grep fan
This should show the following output (again the PID numbers will vary):
12628 root /ffp/sbin/fanctl /ffp/etc/fanctl.conf
12635 root grep fan
This shows that the fancontrol process disappeared and was replaced by the fanctl process (with its configuration file).
To understand or to adjust the behaviour of fanctl, you may want to inspect its configuration file /ffp/etc/fanctl.conf. If you use the nanoeditor:
nano/ffp/etc/fanctl.conf
Under normal circumstances the defaults should be fine.
Warning!
Do not change these values unless you completely understand the consequences.
Overheated hard drives can lead to data loss or early drive failure. So if you want to change the settings in the configuration file, please study the following documentation carefully and test any modifications you make carefully.
The graph
The graph (by Uli) explains how the program adjusts the fan speed. It assumes the default settings (which you won’t change unless you need to and know what you are doing – right?). Room temperature is typically about 20 degrees Celcius (68 degrees Fahrenheit). Fanctl adjusts the fan speed depending on the measured temperature
When you boot the CH3SNAS, but hardly use the drives the temperature should increase a few degrees, but stay well below 40 degrees. In that case, the fan follows the blue line: it stays off because there is no real need to cool the CN3SNAS yet. However, when you use the drives a lot, the temperature can rise above 40 degrees. Especially if the room temperature also happens to be hot. This causes the fan to switch on. The fan speed (in RPM) follows the curved slope (part of a parabolic curve). The maximum fan speed is limited by default to 6300 RPM (called pwm_hi). Like the original software, there is a actually a safety threshold as well: above 51 degrees, the CN3SNAS is turned off. The latter shouldn’t normally happen unless something goes very wrong (like a broken drive, or operating your CH3SNAS in the sauna).
Now assume that the CH3SNAS has become relatively hot (say 45 degrees Celcius), but the drives now enter a period of infrequent access. This causes the drive motors to automatically shut down, reducing heat production and causing the temperature to drop. Every 30 seconds, a drop in temperature will cause the fan to slow down. When the temperature drops below 40 degrees (called temp_hi) the fan speed stabilizes for a while. When the temperature then drops below 37 degrees (called temp_lo), the fan is turned off.
Note that turning the fan on and off occur at different temperatures. This is called (hysteresis). This reduces the chance that at some temperature the fan repeatedly runs for 30 seconds, then turns off for 30 seconds, and then turns on again.
Temperatures
If you want to change the temperatures (e.g. if the fan never switches off completely (NAS too warm) or you want to cool it down to a certain level), there are various values in the script for configuring these. All values have to be set in Celsius*1000! E.g. 40°C would be 40000
There are four different values:
temp_stop: If the temperature decreases below this value, the fan is set to the speed, which is configured as the variable pwm_stop (normally this will be zero and thus stops the fan). If the temperature rises about this temperature, nothing happens (hysteresis). Default is 37 degrees Celcius.
temp_lo: If the temperature rises above this temperature, pwm_start will be set for one second (Starts the fan). After this, the fan speed will be adjusted somewhere beween pwm_lo and pwm_hi – depending on the measured temperature. If the temperature drops below this temperature, the fan runs at pwm_lo (hysteresis). Default is 40 degrees Celcius.
temp_hi: If the temperature rises above this value, pwm_hi is set as fan speed. Default is 50 degrees Celcius.
temp_crit: If the temperature rises above this value, the CH3SNAS is shut down to prevent damage. Default is 51 degrees Celcius. Be extra careful with this value.
Fan speed
If you want to change the fan speed (e.g. if you think, the fan turns too slowly or if you want the fan to idle and not to stop), there are various values in the script for configuring these.
pwm_stop: This is the speed which is set below temp_stop. If set to zero, the fan will halt. It may not be a good idea to use really low non-zero values here (difficult to run the fan smoothly at these speeds).
pwm_start: This is the speed which is set for one second if pwm_stop was set and the temperature rises above temp_lo again. (Default: 3200 rpm)
pwm_lo: This is the speed which is set at temp_lo. (Default: 2700 rpm)
pwm_hi: This is the speed which is set at temp_hi. (Default: 6300 rpm)
Between pwm_lo and pwm_hi the fan speed will be interpolated according to the following formula:
Again, editing fanctl.conf should be done with care. Just editing the file will not cause the new values to be used immediately because the running program reads the file once when it starts. One safe way to reload a modified /ffp/etc/fanctl.conf file is to simply reboot the CH3SNAS. When the program is started, it will load the modified /ffp/etc/fanctl.conf file. Another way is to use
cd/ffp/start
sh fanctl.sh status
sh fanctl.sh restart
sh fanctl.sh status
The sh fanctl.sh retart stops and restarts the fan. Actually between the stop and the restart, fancontrol is briefly run.
Notes
A CH3SNAS in a hot room
According to the graph, if you put the CH3SNAS in a very hot environment (e.g. 38 degrees Celcius), the fan will turn on – even when the hard disks are not being used. Turning the fan on wouldn’t help lower the device temperature: it will only get the device temperature closer to room temperature. Currently the software cannot distinguigh this condition (but this obviously also applies to the default fancontrol software which never turns the fan off).
Shut down on overheating
In exceptional conditions, the CH3SNAS will shut down if it ever reaches temp_crit (typically 51′ Celcius). When it shuts down, it will create a file named OVERHEAT in the root directory. By checking for this file and its creation or modification time, you can get confirmation about the cause of the shutdown.
See the file /ffp/etc/fanctl.conf for more details how this works.
Logging the temperature
From an E-mail exchange with fonz (this hasn’t been tested):
PeterH> Other features might be more fun (e.g. log of temperature?).
That’s pretty easy. Just change /ffp/start/fanctl.sh and replace
You can plot nice graphs from the log file using gnuplot:
gnuplot>set timefmt "%Y-%m-%d %H:%M:%S"
gnuplot>set xdata time
gnuplot> plot '< grep fan /path/to/fan.log' u 1:4w st, '' u 1:8w st
Deinstallation
If you deinstall fanctl using
funpkg -r/ffp/pkg/additional/fanctl-2-1.tgz
and reboot your CH3SNAS, you will find using
ps aux|grep fan
that the original fancontrol appication automatically reappears. This is because fanctl is activated via a script (/ffp/start/fanctl.sh) that stops the default fancontrol process before starting the fanctl program.
This implies that deinstalling funplug and rebooting will also return fan behaviour back to the default behavior and default mechanisms provided by Conceptronic.
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!
After the installation of the fun_plug the only available editor is “vi”, which is not really considered a “newbie“-friendly editor. The nano editor is much easier to use and largely self-explanatory. If you nevertheless want more information on the GNU nano editor, see its home page.
Installation
In this tutorial we assume that the fun_plug is already installed on the NAS and that you synchronized Uli’s repository (see here for instructions on how to do this). Afterwards install the package (see detailed instructions here):
Apart from a power button and some status LEDs on the front, the CH3SNAS has the following external interfaces:
a DC power suppy input This plug is for the supplied external power supply which is rated at 5 Volt by 3 Amps plus 12 Volt by 3 Amps. This 50 Watt rating suggests that the CH3SNAS uses roughly half of the peak power of high-end laptop. Most of this power will be used by the drives (when these are active).
Gigabit Ethernet port This is for connecting the NAS to your local-area network. The port supports 10 Mbit/s, 100 Mbit/s and 1000 Mbit/s ethernet. In practice you are unlikely to see speeds above 200 Mbit/s – likely due to performance limitations of the CH3SNAS.
a single high-speed (480 Mbit/s) USB 2.0 port This port is only used to drive a printer. Other peripherals are not supported by the standard software. You cannot use the port to connect the CH3SNAS to a PC which acts as host without drastic software changes (a SAN is not a NAS; USB master/slave distinction; Windows does not support access to Ext2 formatted drives).
Hardware internals
The central processor in the CH3SNAS is a Marvell Feroceon 1850 processor core inside Marvell’s Feroceon 88F5182 chip “for Networking and Storage”. This core is compatible with the ARM v5TE instruction set architecture (often informally known as ARM9). Although some web sites state that this processor is an XScale processor, this is not inline with Marvell’s documentation and with the table provided by debug tooling specialist Lauterbach. See also Output of /proc/cpuinfo.
In Linux kernel circles, the chip is often referred to as Orion after internal code name. Marvell has been very active recently to get the mainstream Linux kernel to support this architecture.
System-on-Chip
This 88F5182 features a general-purpose CPU (the Feroceon), memory interfaces, as well as a dual port SATA controller, two USB ports (one is unused), and the digital circuitry (“MAC”) required for Gigabit Ethernet. Thus if we compare the 88F5182 to a hypothetical single-chip NAS, it lacks memory (which is normal), analog circuitry (“PHY”) needed for the Gigabit Ethernet port and it requires the usual handful of smaller support devices. The 88F5182 also provides PCI and PCI Express support, but neither is utilized in the CH3SNAS.
Gigabit Ethernet Tranceiver
The physical layer for Gigabit Ethernet (as well as 10 and 100 Mbit/s Ethernet) is provided by a separate Marvell 88E1111 chip. This converts (differential) serial signals into lower speed parallel data for further processing by the MAC layer in the 88F5182. The serial input/output pins are not directly connected to the RJ45 connector, but pass via a transformer (“magnetics”). This is probably to accomodate for differences in common mode level between two computers, and possibly to provide a degree of electrical safety.
DRAM
The CH3SNAS has 64 MBytes of volatile Double Data Rate (DDR) DRAM. The DRAM is not upgradeable as both 256 Mbit Nanya NT5DS16M16CS-6K chips are soldered to the main circuit board.
DRAM is needed to run the software (variables, state, stack). It is also used to buffer data for the various servers (e.g. files to hard disks gets buffered in memory and then sent via Serial ATA drives). It also contains a RAMdisk which behaves like a hard disk, but looses its data when the devices is turned off.
Non-volatile memory
The CH3SNAS has 8 MBytes of Flash memory (Spansion S29GL064A90TFIR4) to hold the firmware and its support files (using a compressed, read-only file system).
Real-time clock
Regardless of whether the CH3SNAS is on or off, a real-time clock chip (the ST M41T80) is powered up from a battery and keeps track of time. This is similar to how PCs work and is needed, for example to execute tasks at predetermined times/dates. Unfortunately, the real-time clock cannot wake up the CH3SNAS at some predetermined time. See Tutorial on NTP-Timesynchronization for information about accuracy of the time function available to software and how to improve that by synchronizing across the network.
Battery
The real-time clock is powered by a 3V battery. The battery should last a few years. If you ever find that the NAS ever looses track of time when you turn if off or disconnect the power, you should replace this battery.
Comparison to a PC
No display or sound
If we compare this to what people typically expect in a stand-alone computer, there is a no display or option to connect one (compensated by browser-based configurability), there is no sound output or option to add sound (compensated by a few LEDs) and no direct keyboard or mouse input possible (compensated by running a web browser on a “real” computer when you need to configure the CH3SNAS).
Soldered-in memory
There is also no way to add or extend the memory inside the system. This is normally not needed. But can be critical for advanced users because the embedded software inside the system does not (unlike personal computers)use space on the hard drive as extra “virtual” memory. All software is expected to be fully operational – even if no drives are inserted.
Virtual memory
During normal operation, the CH3SNAS has 0.5 or even 1 GBytes of virtual memory. This “swap” space on the hard disks (0.5 GBytes/drive) is used to temporarily store stuff that doesn’t fit into DRAM. This is pretty normal for Linux, but is a bit special because under some conditions (e.g. no drives are available yet) the same software needs to be able to run without virtual memory.
User-installable software
A more fundamental difference between a personal computer and an appliance like the CH3SNAS, is that users expect to be able to easily install new software (e.g. a game) on their personal computer. The CH3SNAS is an embedded computer in the sense that it comes with pre-loaded software, and you are unable to easily add more software: the system is closed and optimized for a particular set of tasks. Fortunately there are ways for advanced users to add more software (see fun_plug within the constraints of the memory limitations.
CH3SNAS Hardware OverviewMarvell Feroceon 88F5182 chipMarvell 88E1111 Gigabit Ethernet tranceiverTransformerOne of the two Nanya 32 Mbyte DDR DRAM chips8 Mbytes of Flash memory supplied by SpansionThe battery used to power the real-time clock (the 8-pin chip)CH3SNAS external interfaces
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!
The CH3SNAS has two internal clocks:
a real-time hardware clock, which is similar to the chip in a wristwatch. It is powered by a battery inside the CH3SNAS and thus never stops.
a software clock, which runs only when the NAS is turned on.
Unfortunately, the software clock drifts from the hardware clock and after a few hours the drift get noticeable (e.g., 16s/hour = 4444 parts per million) and the NAS will show incorrect times for e.g. file modifications. But thanks to NTP (the Network Time Protocol) the clock can be synchronized to one of the atomic clocks on the Internet. The resulting absolute error will be only a fraction of a second (e.g. 10 ms; because of packet delays across the Internet) and the drift will essentially become zero.
Note that this tutorial requires an installed Fonz fun_plug!
Background Information
The time in the Linux Kernel is a standardized value. One day equals 10000 “ticks”, so one tick = 8.64 s. Most of the CH3SNAS drift about 16s/hour, wich equals a drift of 384 seconds or 44.444 ticks/day. This value has to be subtracted from the 10000 Ticks of the Kernel and has to be set as the new number of ticks per day. In our case this 10000-44.444 = ~ 9956 Ticks. As you can see, this value is only an estimation because the drift is an estimation. As it will take a lot of time to get the exact value for the ticks, you can simply estimate them and synchronize periodically with a timeserver to reduce the clock drift.
As you can see below, there are two choices for the synchronization. Regular synchronization via Cron should be chosen over using the NTP-Daemon as the latter seems to cause the following two lines in dmesg reappearing over and over again until the device gets restarted:
kernel: TWSI: mvTwsiStartBitSet ERROR - Start Clear bit TimeOut .
kernel: TWSI: mvTwsiStopBitSet ERROR - Stop bit TimeOut .
The Procedure
Time-Synchronization via Cron
Simply add the following lines to /ffp/etc/fun_plug.local, e.g. with nano:
# This removes firmware cronjobs that interfere with ntpd.
crontab -l|grep-vw'/usr/sbin/daylight'|grep-vw'/usr/sbin/rtc'| crontab -
#Now start the ntp every hourecho"1 * * * * /usr/sbin/sntp -r -P no de.pool.ntp.org">>/var/spool/cron/crontabs/root
# force a cronjob updateecho"root">>/var/spool/cron/crontabs/cron.update
Reboot the device.
Sidemark: If the NTP-Service has been deactivated before the restart.
NTP-Daemon
As described above, this method seems to cause the TWSI-problems and is here only for historical reasons. Probably due to the concurrent access to this Two-Wire-Serial-Interface by the ntp-daemon and the fancontrol.
Edit the /ffp/etc/ntp.conf to change the time servers to servers which are geographically close. You can search for them here.
Quick possibility: Change them to general ones:
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst
With this configuration both clocks get adjusted to the German timezone. If you want to change the timezone, you have to edit the /ffp/etc/fun_plug.local.
The string for Germany is (also change the timeserver, as this one is for Germany):
Change it according to your Timezone. You can find possible ones in the appendix
Start the Service
You can now start the service manually or you can perform a reboot (it will be started during the bootup):
/ffp/start/ntpd.sh start
Finetuning
After a few hours you can find a file called /ffp/etc/npd.drift on you CH3SNAS. If the Value is +500 or -500, you have to adjust the number of ticks in the file /ffp/etc/fun_plug.local. fonz has set this to ”tick=9965”, which may be right for your device. If not, try reducing or incrementing this value to reduce the drift.
If you only want to temporarily deactivate fun_plug, simply rename the file fun_plug in the topmost directory of your CH3SNAS, reboot, and you are done.
But there could be cases where you want to completely remove fun_plug. Because the folder containing the fun_plug packages is owned by user root, this folder can only be deleted by root. This can be done by a single rm (remove) command in a PuTTY (ssh) terminal session if you are log in as root. You may want to see this article on root user for information about the special role of the root user.
But let’s assume pessimistically that that doesn’t work because the ssh server is not running or because you have problems logging in as root. Fortunately, the fun_plug script is no owned by root can still be modified by non-root users. This enables a trick to remove the folders without using root privileges: simply add commands for the removal of the fun_plug folder and the fun_plug script to the script itself. These commands will be executed under root privileges during the next reboot.
Note that the folder may be named either ffp or fun_plug.d – depending on the version of fun_plug that you have installed.
Script
You have to download the Script for the Removal here
Installation and execution
Rename the downloaded script to fun_plug and copy it to the NAS in the topmost directory of Volume_1. This will probably overwrite a existing script file fun_plug.
Reboot the CH3SNAS by holding down the power button 5 seconds or via the web interface (Tools -> System -> Reboot). During the reboot, fun_plug will be completely removed.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.