Posts Tagged NSLU2

File server and automatic backup

随着计算机技术的广泛普及,计算机早已走入千家万户,越来越多的家庭拥有多台计算机和家庭局域网络,资源共享,特别是文件的共享的重要性就越来越突出。同时,文件的数量也越来越多,备份文件变得复杂困难。参考本文提供的参考文献学习如何设立文件服务器和文件同步备份的文章。本文主要从另一个角度提出一种完备的解决方案。

有效的解决办法是在家里设置文件服务器,直接连接到内部网络上。我在学习使用LinkSys生产的NSLU2时,通过将该设备的系统固件更换为Debian Linux(具体方法见Debian on NSLU2),使其功能极大地增强。鉴于本文讨论文件自动备份,下面就如何设置文件服务器和备份软件进行阐述。

硬件准备:你需要购置两台Linksys NSLU2和两个USB外置硬盘,硬盘最好是2.5英寸的,不需要额外的电源适配器,同时可以节约能源。硬件购回后,需要按照Debian on NSLU2一文的步骤对硬盘格式化和对NSLU2安装新的固件。完成这一步骤后,下面就只剩软件的安装了。

SAMBA文件服务器:绝大多数计算机用户使用Windows,所以必须使Windows计算机可以访问文件服务器。Debian Linux系统的SAMBA服务器提供了这样的功能。首先在linux系统中安装SAMBA服务器软件,然后参考Build a full-blown file/web server on Linksys NSLU2这篇文章的有关章节对SAMBA服务器进行配置,主要是设置共享目录。你只需要在一台NSLU2机器安装该软件。

[samba]
        path = /samba
        public = yes
        read only = no
        create mask = 0777
        directory mask = 0777
        writable = yes
        browsable = yes
        guest ok = yes

NFS文件服务器:Linux系统之间使用NFS文件系统来共享硬盘资源。所以你需要在两台NSLU2上都装上NFS文件服务器并对它进行必要的配置。在NFS服务器上,你需要编辑/etc/exports来制定共享的目录。

/home/samba        192.168.2.0/255.255.255.0(rw,sync,no_root_squash)

在使用NFS服务器的机器上,你需要修改/etc/fstab,使系统自动配置NFS服务器文件系统。

192.168.2.104:/personalstorage/samba    /mnt/pstorage    nfs     rw,rsize=65536,wsize=65536,hard,intr,async,nodev,nosuid   0       0

用sync实现自动备份:在Linux系统中,sync是一个功能强大的软件,文件的自动备份就需要用它来完成。你自需要在没有安装SAMBA的NSLU2机器上安装该软件,并在/etc/crontab中加上定时自动启动的任务就行了。可以设定,让sync每天的凌晨运行一次,对SAMBA机器上的所有文件备份到本机。

55 5     * * *   root    rsync -a --delete /var/vmail/  /mnt/pstorage/mails

Reference

Share

Tags: , , , , , , , , ,

Useful software for NSLU2 file/web server

To connect NSLU2 SSH server and FTP server, you have to use SSH client and FTP client software. There are a lot of freeware available. The software posted here is what we recommend strongly. PuTTY is a free telnet/SSH client. You can use to connect to telnet server or SSH server. It is flexible, easy-operated, small in size.

Downloand PuTTY

WS_FTP LE is a free FTP client. Since it is free its functionality is very simple but better than Windows console FTP client.

Download WS_FTP LE

WinSCP 3.8 is a free SFTP and SCP client for Windows. You can download them at the developers’s website or here.

Download WinSCP 3.8

If you previously flashed your NSLU2 to a customized firmware other than Linksys official firmware, you have to use a upgrade tool to flash new firmware. For Windows XP, you can use Upgrade 2.07. For Linux/MacOS, you can use UpSLug. Click the following link to download Upgrade 2.07 for Windiws XP.

Download Upgrade 2.07 for Windows XP

The essential files you need to setup a thttpd web server. Please refer the NSLU2 Web Server DIY guide to find how to use these files.

Download Windows Zip file

Reference

Share

Tags: , ,

User guide of NSLU2 file/web server


1. Introduction
2. Installation and configuration
3. FTP server
4. Web server
5. SSH server
6. Port forwarding

1. Introduction

Currently more and more families subscribe broadband Internet services, either Cable or DSL. In general, every family has more than one computer. To share hardware and software resources at home, such as hard drive, photos, music, software and so on, a dedicated computer as a file and/or web server has to run all the time, at least during the day time. More people are willing to have their own private web server running within their LANs. The problem is that a dedicated computer is not an energy- and cost-efficient solution. How can we obtain a more reasonable solution of a file and/or web server at home? A smart and practical solution of absolutely cost-efficient, energy saving and private file and/or web server is provided here for home networks. Linksys has a product called Network Storage Link for USB 2.0 Disk Drives (NSLU2). This device has two USB ports that you can plug external hard drives or flash drives. It provides a basic platform to create a cost-efficient and energy saving file and/or web server. The second component we need is a flash drive with 1 GB or more storage capacity. The third component is a customized firmware that allows us to install and configure software in a NSLU2 device. In the public domain, a user community called nslu2-linux-org makes enormous efforts to develop alternative firmware for NSLU2 devices. Unfortunately, a large group of people are not familiar with Linux and do not have experience to flash NSLU2 devices with the newly developed UNSLUG firmware.

Here is a customized NSLU2 with web server, file server, ftp server, and SSH server installed (see Figure 1). The customized system use FTP client to transfer and manage all files on the web server. In addition, usage of the web server is summarized and every 6 hours by Webalizer application. You can view the daily and monthly usage of your web server. By browsing these daily updated web pages you can easily monitor how your web server is used. If you like, you can make your web server available in the Internet by configuring your router properly. As a plus, you still can plug another external hard drive (formatted in NTFS Windows format) to the device and share it in your home network. This user manual describes how to use its web/ftp/ssh servers. You can evaluate the efficiency and speed of the web server by visiting http://www.sunfinedata.com/. It was constructed by the exactly same method. Plus, you can learn basic Linux commands by SSHing into the NSLU2 because a customized Linux operation system is running on it.


Figure 1. Components of the NSLU2 file/web server

Back to Content

2. Installation and configuration
A. Plug the Flash Drive

NSLU2 has two USB ports. You should plug the flash drive to the Disk 2 port at all the time. Do not try to plug it to Disk 1 port. The Disk 1 port is prepared for a NTFS format USB drive. So make sure that the flash drive is plugged into the Disk 2 port. The flash drive was formatted to Linux EXT3 format. It is totally different from the Windows partition formats (such as FAT16/32, NTFS). So do not try read and write files to your flash drive on any Windows PC.

B. Connect the device to your router and find its IP address

Use a RJ45 Ethernet cable to connect your device to your router. Since the default IP address of the device is set to dynamic, you can get its IP address in the clients table of your router. A sample client table could look like Figure 2. In this case, the IP address of the Linksys device (named LKG7E5076, your device will have different name) is 192.168.2.4.


Figure 2. Sample clients table in a router

C. Use web interface

The Linksys NSLU2 default username (admin) and password (admin) for the web interface are preserved. We recommend you to change the password to something meaningful to you. That will increase the security of the server if you expose it to the Internet.


Figure 3. The home page of the NSLU2 web interface
Use your web browser to visit the IP address (192.168.2.4) that is shown in the client table of your router. The home page of the NSLU2 will show up (see Figure 3). In the page, you can see the following important information:

Server nameLKG7E5076
Firmware version:V2.3R63-uNSLUng-6.8-beta
IP address192.168.2.4
USB port 1:Not installed (that means nothing is plugged in this port)
USB port 2:Ready, 729MB (94% Free) (This tells us that there is a disk attached to this port. The data partition has 729MB space of which 94% is free)

At the bottom of this page, you can find one line of message like ‘uNSLUng status: Unslung to disk 2, /dev/sda1’. That tells us the filesystem of the flash drive is running.

D. Change IP address setting

Through the web interface of the Linksys NSLU2, you can change the IP address configuration of the device. The following picture shows the web pages used to do the work. The customized NSLU2 server comes with dynamic IP address because you can easily find it in your LAN. Once you connect the device to your router, the first thing you need do is to change the IP address to a fixed one according your LAN setting. Please refer your router’s manual and NSLU2 original manual to do it. Figure 4 shows the current IP address setting and Figure 5 shows the changed setting.


Figure 4. The interface used to set the IP address of the NSLU2 device


Figure 5. Set a fixed IP address

Back to Content

3. FTP server

The customized device has FTP server enabled. Any normal account created through the NSLU2 web interface can connect to the FTP server remotely. To create a user account or change the password of existing accounts, please follow the NSLU2 original user guide. Figure 6 shows a sample view after connected to the NSLU2 device through the admin account. That is why I emphasize that you have to change the password of the admin account if you plan to expose your server to the Internet. An FTP account is set specifically for web server. Both the user name and password of the account are wwwroot.


Figure 6. A sample view of FTP server of the NSLU2 in a FTP client

Back to Content

4. Web server

There are two threads of thttpd web server running in the customized NSLU2. The web interface of the NSLU2 device is running on port 80. The user web server is running on port 8080. After you connect your device to your network and determine its IP address, you can look at the web server running at port 8080. Launch your web browser and enter http://192.168.2.4:8080/ to visit the user web server. Figure 7 shows the default web page for the user web server of the customized NSLU2. Please pay attention the above URL link. Since the default http port (80) is used for NSLU2’s web interface, we have to indicate the port that a web server is running for the user web server space. The port information is important for port forwarding, too. The default web page (index.html) on the user web server should be overwritten or deleted if you use a different file, such as index.htm. You can upload all files of your website through any FTP clients. The username and password for your web server are wwwroot. All web pages should be uploaded to wwwroot directory (see Figure 8). To share your web server through the Internet, you have to configure your router. Add the server IP address and the port 8080 to the forwarding IP list (see the port forwarding section for detail).


Figure 7. The default page for the user web server of the customized NSLU2


Figure 8. The initial FTP client window after connected the FTP server

Back to Content

5. SSH server

An SSH server is running in the customized NSLU2 device. That allows you log in the server and do configuration and install new packages. PuTTY is a free telnet/SSH client. You can use it to connect to any telnet server and SSH server. The following two links have PuTTY client program for downloading.

http://www.chiark.greenend.org.uk/~sgtatham/putty/

putty

Figure 9 shows a typical PuTTY configuration window. Every time the program is started, the window will pop up first. What you can do is type your server’s IP address in the Host name (or IP address) textbox and select the protocol type. If you use a telnet server, please select Telnet radio button, the port number will automatically change to 21. If you use an SSH server, please select SSH radio button, the port number will automatically change to 22. Click Open button to connect to the server. If this is your first time to log on this SSH server, an alert window will pop up first (see Figure 10). What you can do is to click Yes button to continue. Then a terminal window will pop up (See Figure 11). Within this window, you can enter the root username (root) and password (uNSLUng) to log in the device. You can always login as root. We suggest that you create a new user for normal maintenance of NSLU2.


Figure 9. A typical PuTTY configuration window


Figure 10. A security warning window when you connect to the SSH server first time


Figure 11. The normal terminal window after you log in the device

Back to Content

6. Port forwarding

If you are intending to expose your servers to the Internet, you have to study your router’s user manual and find a way to set port forwarding. Table 1 lists the port and protocol of different servers running in the NSLU2. They are useful when you set port forwarding in your router.

Table 1 Port information of different services for access from the Internet

Server Port LAN IP Protocol
FTP 21 Your device IP address TCP
HTTP 8080 Your device IP address TCP
SSH 22 Your device IP address TCP

The port forwarding function is different from router to router. Here we give two examples of port forwarding based on a USR 5461 router and an ActionTec DSL modem (see Figure 12 and Figure 13). For detail steps you should check the user guide of your router.


Figure 12 Port forwarding section in a USR 5461 router


Figure 13 Port forwarding section in ActionTec DSL modem

Back to Content

Reference

Share

Tags: , , , , , , , ,

Build a full-blown file/web server on Linksys NSLU2

Content
1. Introduction
2. Overview of NSLU2
3. Setup the new device
4. Upgrade firmware
5. Prepare the NSLU2 device for unsling
6. Unsling
7. Post-unslung setting
8. Install essential packages
9. A shell script to accelerate the setting
10. Legal notice

1. Introduction

Currently more and more families have broadband Internet services, either through Cable or DSL. In general, every family has more than one computer. To share hardware and software resources at home, such as hard drive, photos, music, software and so on, a dedicated computer as a file and/or web server has to run all the time, at least during the day time. More people are willing to have their own private web server running within their LANs. The problem is that a dedicated computer is not a cost-efficient and power-saving solution. How can we obtain a more reasonable solution of a file and/or web server at home? A smart and practical solution of absolutely cost-efficient, power-saving and private file and/or web server is provided here for home networks. Linksys has a product called Network Storage Link for USB 2.0 Disk Drives (NSLU2). This device has two USB ports that you can plug external hard drives or flash drives. It provides a basic platform to create a file and/or web server. The second component we need is a flash drive with 1 GB or more storage capacity. The third component is a customized firmware that allows us to install and configure software in a NSLU2 device. In the public domain, a user community called nslu2-linux-org makes enormous efforts to develop alternative firmware for NSLU2 devices. Unfortunately, majority of people are not familiar with Linux and do not have experience to flash NSLU2 devices with the newly developed UNSLUG firmware.

Here is a customized NSLU2 with web server, file server, ftp server, and SSH server installed (see Figure 1). The customized system uses FTP client to transfer and manage all files on the web server. In addition, usage of the web server is summarized and every 6 hours by Webalizer application. You can view the daily and monthly usage of your web server. By browsing these daily updated web pages you can easily monitor how your web server is used. If you like, you can make your web server available in the Internet by configuring your router properly. As a plus, you still can plug another external hard drive (formatted in NTFS Windows format) to the device and share it in your home network. This DIY manual describes how to build a web/ftp/ssh server on a NSLU2 device from scratch. You can evaluate the efficiency and speed of the web server by visiting http://www.sunfinedata.com/. It was constructed by the exactly same method. Plus, you can learn basic Linux commands by SSHing into the NSLU2 because a customized Linux operation system is running on it.

Figure 1. Components of the NSLU2 file/web server

Back to Content

2. Overview of NSLU2

NSLU2 has the following features advertised by Linksys. You can get more detail descriptions of this device from the materials provided in the NSLU2 package and the Linksys web site.

  • Connects USB 1.1 or 2.0 disk drives and flash disks directly to your network
  • Share music, video, or data files with managed access by user name or group
  • Integrated file server — access your files from the Internet
  • Built-in disk utilities — format, backup, and scandisk

From a customer’s point of view, it has the following advantages:

  • Small size – it can fit into your palm
  • Simple and stable – less worries about failure and the loss of your files
  • Power-efficient and cost-saving – save money for updating hard or flash drives
  • Customizable – this is a big advantage for advanced user. This manual will teach you step by step to create a customized file/web server on NSLU2 from scratch

I value these features more than what Linksys advertises. Believe or not, NSLU2 can be used as Linux machine after it is customized. The NSLU2 user community has found a way to install a full functional Linux system (Debian Linux) to the device. I own NSLU2 devices with Debian installed. Because of Debian Linux running in the machine, there is numerous GNU software available for it. You can do whatever you want in the machine once Debian is installed. We do not discuss how to install Debian to NSLU2. If you are interested in this topic, please visit http://www.cyrius.com/debian/nslu2/.

In this document, I will explain in detail how to convert your NLSU2 into a full-blown file/web server. Do not panic. It is pretty easy to do if you follow the steps described in this document. Anybody with a little bit computer experience can do it.

Back to Content

3. Setup the new device

After you get a band new NSLU2 device, you can convert it to a full-blown file/web server by following the steps described below. In this step, what you will do is to take advantage of the software and firmware provided by Linksys.

A. Use Linksys setup disk to change the device�s default settings

The setup program in the CD gives you capability to change default IP address and current date and time of the device. In this step, we want to change the fixed IP address to a dynamic IP address. The following three screen shots show how to do it step by step.

Figure 2. In this screen, you can change a fix IP address to a dynamic IP address. Just simply click “Automatically obtain an IP address (DHCP)” option and you are done. This effect will show in next screen shot.


Figure 3. A screen shot after selection of a dynamic IP adrress


Figure 4. This is a screen shot for changing time zone, date and time

B. Get the device IP address

Once the setup program is complete, the device will reboot. After the NSLU2 is fully rebooted, go to your router’s maintenance web page and check the client list of your router (see Table 1). You can find the IP address of your NSLU2 device. For my situation, the IP address of my NSLU2 is 192.168.2.3. From now on, I can use this IP address to access my NSLU2 in my LAN.

Table 1. Client IP addresses from the client list of a router

Type Name MAC Address IP Address Expiration
wired FertileLand 00:40:2B:6A:E7:08 192.168.2.2 54 minutes 27 seconds
wired LKG7E5076 00:0F:66:7E:50:76 192.168.2.3 59 minutes 11 seconds

Back to Content

4. Upgrade firmware

In most cases, people who read this manual are not a Linux guru even do not know anything about Linux. So the NSLU2 devices you operate usually have Linksys default firmware. If this is the case, you can follow the steps described in section A to upgrade the device to Unslung 6.8. Sometimes you have a device that already has non-Linksys firmware. If that is the case, please follow the steps described in section B to upgrade the device to Unslung 6.8. Before you do upgrade your NSLU2, please download the Unslung 6.8 at http://www.slug-firmware.net/u-dls.php to your computer and unzip the package. Later on you will need the unpacked the bin (Unslung-6.8-beta.bin) file during the upgrade process. If there is a USB drive connected to your NSLU2, please unplug it first before firmware upgrade.

A. Use NSLU2 web interface to upgrade firmware

You know the IP address of your NSLU2 device. You can access its web interface to do more advanced setting even upgrade its firmware. We will take advantage of the functions provided in the web interface to install the customized firmware. In our case, it is Unslung 6.8 beta version (http://www.nslu2-linux.org/wiki/Unslung/HomePage). The following describes the detail steps.

  1. In the address bar of your web browser enter 192.168.2.3, the default NSLU2 web interface will show up;
  2. Click “Administration” link and a login dialog window pops up. You should use the default username (admin) and password (admin) of the Linksys NSLU2 to log in;
  3. Click “Advanced” -> “Upgrade” to get into the upgrade firmware page;
  4. Click “Browse…” button to find the customized firmware (Unslung-6.8-beta.bin) on your hard drive;
  5. Click “Start upgrade” link to upgrade the customized firmware.

The upgrade process will take several minutes to complete. At the end of the upgrade process the NSLU2 device will reboot automatically.

B. More advanced way to upgrade your firmware

This is a method recommened from the “Unslung-6.8-beta-README.txt”. You must follow the steps described here in sequence. The text in this section is mainly from “Unslung-6.8-beta-README.txt”.
If you are installing Unslung 6.x onto an NSLU2 unit with an existing version of nslu2-linux.org firmware already installed, you must first put the NSLU2 into RedBoot Upgrade Mode.

  1. The NSLU2 should still be powered off at this point.  If not, shut it down again before proceeding.
  2. Using a paper clip, push and hold in the reset button which is located on the back of the NSLU2 near the power socket.
  3. While holding in the reset button, press and release the power button.
  4. Watch the Ready/Status LED, and as soon as it turns red quickly release the reset button.
  5. You should now be in upgrade mode which is indicated by the Ready/Status LED alternating between red and green.
  6. Use either the Linux UpSlug2 tool or the Windows SerComm Upgrade tool to upload the new firmware.  You can find download links at http://www.sunfinedata.com/nslu2/download.html or http://www.nslu2-linux.org/wiki/HowTo/InstallUns lungFirmware.

7) During firmware flashing, the top LED – Ready/Status – flashes red and green (approximately 5 minutes, but can be much longer).
8) The NSLU2 will reboot after the flashing is complete.

Back to Content

5. Prepare the NSLU2 device for unsling

A. Check version see if the upgrade was successful

After the NSLU2 is rebooted (no any disk attached), check if it is successfully upgraded. Enter the NSLU2’s IP address (192.168.2.3 in my case) into your web browser’s address bar, the NSLU2 web interface show in the browser. If you see the version information is “V2.3R63 uNSLUng-6.8-beta”, that means the firmware has been successfully upgraded. Otherwise, you have to repeat the steps described in the upgrade firmware sections.

B. Enable telnet

In the Unslung web interface, click “Manage telnet” link, then click “Enable Telnet” button in the new page. After the page is refreshed, you will see current telnet service status is “Enabled”. Click “Back” link at the bottom of the page to go back the NSLU2 main web page.
C. Telnet into the device

Once the telnet service is enabled, you can telnet into the NSLU2 device by following the simple steps here.

  1. Click “Start in Windows system bar and then click “Run” in the Start menu;
  2. Enter “telnet 192.168.2.3” into the textbox;
  3. Click “Open” button to run telnet program, a console window pop up to tell you connecting to the server;
  4. Then you have to login the NSLU2 device by using “root” as username and “uNSLUng” as password;
  5. The NSLU2 device will show the welcome information and tell the NSLU2 is running in the internal flash. Leave this window open while you carry on the following activities.

D. Format a flash or hard drive

Now you have to format your flash or hard drive. We recommend that you attach your flash or hard drive to USB Port 2 always. Here are the steps.

  1. Plug your flash drive or hard drive to USB port 2 (This is very important!!!!);
  2. Reflesh the NSLU2 web interface;
  3. Click “Administration” -> “Advanced” -> “Disk“. If needed, please use admin/admin as username/password to log in the device;
  4. Click “Format disk2” to format the flash or hard drive attached to USB port 2;
  5. Click “OK” for the popup confirmation window;
  6. After formatted, you may get error information. If so, detach your drive and reboot your NSLU2 device. After rebooted, repeat steps in sections B to D to format your drive;
  7. If no error information appears, please click “Home” link to switch to the main page of the NSLU2 web interface. Check the device status information and see if you can confirm that USB Port 2 is correctly formatted. If the drive attached to USB Port 2 correctly formatted, you will see a message very similar to “USB Port 2: Ready, 710MB (85% Free)”. Then you can go to next section.

Back to Content

6. Unsling

The official install guide of Unslung 6.8 is at http://download.berlios.de/unslung/Unslung-6.8-beta-README.txt. Please follow this guide closely. The simplifies steps are listed here.

  1. Follow steps in the previous section to enable telnet and telnet into the device;
  2. Plug your USB flash drive or hard disk to the device;
  3. Refresh the web interface and check the disk status. If you see “not installed” at the USB Port2, that means your drive is not formatted or incorrectly formatted. You have to repeat the steps in previous section to prepare your drive;
  4. If you see “USB Port 2: Ready, xxxGB (xx% Free)” or something like that, that means your drive is ready for being unslung. You can proceed to the next step;
  5. In the telnet console window, you can type “/sbin/unsling disk2” to unsling the file system to DISK2;
  6. In the telnet console windows, type “reboot” to reboot the NSLU2;
  7. After the device is rebooted, refresh the web interface. You can see the following information in the home page. This information confirms that your NSLU2 was correctly unslung.

Table 2. Correct information of an unslung NSLU2

Server Name: LKG7E5076
Version: V2.3R63-uNSLUng-6.8-beta
IP Address: 192.168.2.50
USB Port 1: Not Installed
USB Port 2: Ready, 729MB (96% Free)

Back to Content

7. Post-unslung setting

After successfully unslung you “slug”, you should complete the following two steps before install new packages.

A. Fixed IP address

If you want to use the file/web server to serve your LAN and the world, you can simplify your life by changing the dynamic IP address to a fixed IP address. Here are the steps to set a fixed IP address.

  1. Click “Administration” -> “LAN”. If needed, please use admin/admin to log in;
  2. Change IP address to “Fixed IP Address (recommended)”;
  3. Enter a fixed IP address in the IP address row, for example, 192.168.2.100 as shown in Figure 5. You have to choose one based on your real situation;
  4. Enter 255.255.255.0 in the network mask row;
  5. Enter the gateway IP address. It usually is the IP address of your router. For example, it is 192.168.2.1 in my situation; 
    Figure 5. IP address setting
  6. Enter your router’s IP address into the primary DNS server’s IP address. For example, it is 192.168.2.1 in my situation;
  7. Click “Save” link at the bottom of the page to save your change. You are done once the page is flashed back. From now on, we will use IP address 192.168.2.100 to refer the NSLU2.

B. Create a new user

We want that the web server is running in a separate user. The following steps tell us how to create a new user called “wwwroot” that will be used as the user of web server.

  1. Click “Administration” in the NSLU2 web interface;
  2. Use admin/admin as username/password pair to enter the administration page if necessary;
  3. Click “Users” to open user setup page;
  4. Enter “wwwroot” in the “name” box;
  5. Enter “wwwroot” in the “password” and “verify password” boxes;
  6. Check “Create Private Folder (Share)” option and make sure “Disk 2” is in the “Private Folder (Share) Location” option box;
  7. Click “Save as a new user” button to save create the new user (See Figure 6);
    Figure 6. Create a new user
  8. Select the newly created “wwwroot” user in the user list box (See Figure 7);
  9. Click “Groups” button below the list box;
  10. Check the group information in the left side list box of the popup window. If it does not have group called “everyone”, please remove any groups in the list box first and add “everyone” group into the left list box;
  11. Click “Close” button in the window. After the window is closed, you have completed the process to create a new user.
    Figure 7. Change group information

Back to Content

8. Install essential packages

In the last section, we describe what packages we should install for a full-blown file/web server. Since we will use Linux commands to complete all the steps, you have to telnet into the NSLU2 device first. Please use your web browser to open the NSLU2 web interface. The interface should look like Figure 8. Please check ther banner at the bottom of the page. If it shows “uNSLUng status: Unslung to disk 2, /dev/sda1”, you can proceed the following steps. Otherwise, if you see “uNSLUng status: Running from Internal Flash”, you have to go back to unsling section to successfully complete those steps.
Click “Mange Telnet” link in the top right side to open the manage telnet page. Click “Enable telnet” button and click “back” link in the refreshed page. Now you can telent into your device and log in by using root/uNSLUng combination or root/your customized password dung the unslung process. Once you telnet into the NSLU2 device, you can follow the following text to install and configure the essential packages.


Figure 8. The snapshot of the web interface of an Unslung NSLU2 device

A. Update ipkg

The ipkg is a tool that is used to install and remove software. There are tons of software available for Linux/unslung system. Before you use it, you have to execute the following commands. These commands will update the package list and essential things for ipkg.

# update ipkg
ipkg update
ipkg install unslung-feeds
ipkg update

B. Install openssh

Telnet is a unsecure way to log in your NSLU2 device. OpenSSH provides secure way to log in your device. In order to secure your device and skip the step to enable telnet, you have to install OpenSSH by executing the following command.

# install openssh
ipkg install openssh

After you successfully install OpenSSH on your device, you can use PuTTY to test your brand new ssh server. You can download PuTTY at http://www.sunfinedata.com.
C. Install webalizer and configure it

Webalizer is a useful software that can generate html pages that include visit statistics in tables and graphs. You can use these pages to monitor how your web server serves the world and detect any problems, such as dead links. Please execute the following commands and stemps.

# install webalizer
ipkg install webalizer
chmod +x /opt/bin/webalizer
cp /public/webalizer.conf /opt/etc/
chmod +r /opt/etc/webalizer.conf
cp /public/update-webalizer-stats /opt/etc/

Please note the config file should be copied to public folder. You can find the config file at http://www.sunfinedata.com.
In order to automatically run the webalizer to update visiting reports, you have to add one line to /etc/crontab. You can use vi or nano to edit /etc/crontab by adding the following line. After you complete this step, your web site visiting reports will be updated every 6 hours.

59 5,11,17,23 * * * root /usr/bin/webalizer &>/dev/null

D. Set myhttpd server

Now you can setup thttpd for our web server. Since the Unslung already includes a default web server running at port 80 (serving the web interface). We have to setup our own web server at a different port 8080. To do this, please follow the following commands.

#Setup thttpd web server
mkdir /opt/var
mkdir /opt/var/log
mkdir /opt/var/run
cp /usr/sbin/thttpd /opt/sbin/mythttpd
cp /public/mythttpd.conf /opt/etc/
cp /public/S8080mythttpd /opt/etc/init.d
chmod +x /opt/etc/init.d/S8080mythttpd
chmod +r /opt/etc/mythttpd.conf

After you complete this step, please type http://192.168.2.3:8080/ at your web browser’s address box to browse the first page of the server. You can visit http://192.168.2.3:8080/_stats/ to monitor how your web server serves the world.

The following is a sample of mythttpd web server config file. You can find the config file at http://www.sunfinedata.com.

mythttpd.conf

# This section overrides defaults
dir=/share/flash/data/wwwroot
nochroot
nosymlink
user=wwwroot# default = nobody
logfile=/opt/var/log/mythttpd.log
pidfile=/opt/var/run/mythttpd.pid
cgipat=**.cgi
# This section _documents_ defaults in effect
port=8080
# nosymlink# default = !chroot
# novhost
# nocgipat
# nothrottles
# host=0.0.0.0
# charset=iso-8859-1
charset=utf-8

Back to Content

9. A shell script to accelerate the setting

To manually complete the above steps, you have to type a lot Linux commands. To get thing simple and straight, a shell script (postunsling) was provided to accelerate the setting process. The zip file provided at http://www.sunfinedata.com includes this shell script plus all config files and other related files. Please extract these files to a folder on your desktop machine and copy all files under folder “Webserver” to public folder in your device. Then add execute privilege to the postunsling shell script at an ssh console. Run this script once you complete all manual work through the web interface.

postunsling

#!/bin/sh

#
# This shell command file is used to config openssh, mythttpd, and webalizer
# That can minimize the manual work and reduce any possible errors
#

#
# Before run this script, please create a new user through NSLU2 web interface
# the username and password should be wwwroot/wwwroot
# This is the default user of web server
# Users will use it to upload files to the server
#

# update ipkg
ipkg update
ipkg install unslung-feeds
ipkg update

# install openssh
ipkg install openssh

# install nano editor
ipkg install nano

# install webalizer
ipkg install webalizer
chmod +x /opt/bin/webalizer
cp /share/flash/data/public/webalizer.conf /opt/etc/
chmod +r /opt/etc/webalizer.conf
cp /share/flash/data/public/update-webalizer-stats /opt/etc/
chmod +x /opt/etc/update-webalizer-stats

# config mythttpd server
mkdir /opt/var
mkdir /opt/var/log
mkdir /opt/var/run

cp /usr/sbin/thttpd /opt/sbin/mythttpd
chmod +x /opt/sbin/mythttpd
cp /share/flash/data/public/mythttpd.conf /opt/etc/
chmod +r /opt/etc/mythttpd.conf
cp /share/flash/data/public/S8080mythttpd /opt/etc/init.d/
chmod +x /opt/etc/init.d/S8080mythttpd

mkdir /wwwroot/_stats
chmod +r /wwwroot/_stats
chown wwwroot:everyone /wwwroot/_stats

cp /share/flash/data/public/index.html /wwwroot/
chmod +r /wwwroot/index.html

Back to Content

10. Legal notice

This guide is provided as is without any warranty. The author and sunfinedata.com does not assume any responsibility if you damage your device. You are on your own by following the steps presented in the document.

Reference

Share

Tags: , , , , , ,