Difference between revisions of "How to forge a local file system server with IGEPv2 Board"

From IGEP - ISEE Wiki

Jump to: navigation, search
Line 369: Line 369:
  
 
[[Image:Previewowncloudinstallation1.png|thumb|center]]
 
[[Image:Previewowncloudinstallation1.png|thumb|center]]
 
----
 
 
----
 
  
 
=== Configuring Owncloud.org  ===
 
=== Configuring Owncloud.org  ===

Revision as of 12:16, 3 November 2011

Introduction

Objectives

This project aims to create a local file system server using ARM Platform. It is very useful for this purpose for the next reasons:

-ARM is designed for low power consumption. This server should be connected to power supply all the day, if you use this architecture you can lower your electric bill.

-ARM-Embedded is usually cheaper than a X86-Embedded processor.

-If you have a good internet broadband, is not difficult to configure your server to accept external http request.

-Your data are 100% under your control, other services you don't know where are your files.

-Commercial services offer premium accounts with extra hard disk space, in your server you can use all the space as your HD or SD supports.


When you finish this how-to, you will have your own local web service similar than Dropbox and SugarSync. Your service will powered by Owncloud.org software. I used for this tutorial Owncloud 3 alpha 1 release to prove all new characteristics, but you can follow this tutorial using the stable version. There characteristics are: File management, WebDAV access, sharing, music streaming, calendar, contacts, users & groups, image gallery, online text editor, online task manager and bookmarks. For more information go to Owncloud.org page.

Limitations

When i finished this project, i tested the system performance making some tests. After this i did the next conclusions:

- If you upload a folder with more than 100 files, i recommend that you compress it before the upload.

- Don't compress via Web a folder large than 100 MB, use WebDAV for download it.

- Don't upload more than 750 MB via Web, use WebDAV for this purpose.

- The Web uses HTML5 technology, it tested with Firefox 7 and Chromium 14 browser and mobile phone with IOS 4.3.3. Older browsers maybe have problems.

Hardware Used

The hardware used for this project is:

- IGEPv2 Board Revision C with 1 GHz Processor and 512MB Ram.

- 5 V power supply.

- MicroSD card 2GB at least with SD card adapter.

- IGEPv2 Serial Debug cable, it isn't necessary later.

- Ethernet cable.

- Switch or Router.

- External USB Hard Disk with USB cable.

Software Used

I used the following software:

- Linaro Headless

- Gparted

- Igep-x-loader-2.1.0-3.tar.bz2

- Owncloud software

- Kernel 2.6.35.y

- LAMP

- OpenSSH Server

Installing Linaro Headless

Using this tutorial(microSD) and this other(IGEPxloader) to install Linaro Headless in your SD card. It runs well with the software detailed above.  You can compile the IGEPxloader and Kernel, but is not necessary.

NOTE: Use FAT16 for boot partition and EXT3 for rootfs partition.

Create a new file into the boot partition named igep.ini with these content and save the file.

[kernel]
; Kernel load address, NOT Modify
kaddress=0x80008000
; RAM disk load Address, NOT Modify
;rdaddress=0x84000000
; Board Serial ID
serial.low=00000001
serial.high=00000000
; Board Revision
revision=0003
; Kernel Image Name
kImageName=zImage
; Kernel RAM Disk Image Name
;kRdImageName=initrd.img-2.6.35-1010-linaro-omap
MachineID=2344
; Where Machine ID = 2344 for IGEPv2 and ID = 2717 for IGEP Module
 
[kparams]
;buddy=igep0022
;buddy=base0010
; Setup the Kernel console params
console=ttyS2,115200n8
; Enable early printk
;earlyprintk=serial,ttyS2,115200
; Setup the Board Memory Configuration
;mem=430M
mem=512M
; Setup the Boot Delay
boot_delay=0
; Setup the ARM Processor Speed
;mpurate=800
; Setup the loglevel
;loglevel=7
; Enable Kernel Debug Output
;debug=1
; Fix RTC Variable
;fixrtc=1
; Configure nocompcache variable
nocompcache=1
; Configure Frame Buffer Configuration
;omapfb.mode=dvi:1280x720MR-16@60
;omapfb.mode=dvi:hd720-16@60
; Configure Video Ram assigned
vram=40M
; Configure Video RAM assigned to every frame buffer
omapfb.vram=0:12M,1:16M,2:12M
; Configure frame buffer debug output
;omapfb.debug=1
; Configure DSS Video Debug option
;omapdss.debug=1
; Configure the Board Ethernet Mac Address
smsc911x.mac=0xb2,0xb1,0x1f,0xb5,0xcd,0xdf
;  --- Configure UBI FS boot --- 
;ubi.mtd=2 
;root=ubi0:igep0020-rootfs 
;rootfstype=ubifs
;  --- Configure NFS boot --- 
;ip=192.168.2.123:192.168.2.129:192.168.2.1:255.255.255.0::eth0:
;root=/dev/nfs
;nfsroot=192.168.2.129:/srv/nfs/igep_rootfs
;  --- Configure MMC boot --- 
root=/dev/mmcblk0p2 rw rootwait
; Assign Init program
;init=/bin/bash

NOTE: I recomend change MAC adress.

Set up internet connection

Login as root via serie, we use "vi" editor to add the following lines to the bottom of /etc/network/interfaces

auto eth0
iface eth0 inet dhcp

NOTE: Some routers give a static IP via Dhcp identifying the MAC address, others give a free IP when we send Dhcp request. Also you can configure /etc/network/interfaces to get a static IP with the following lines:

auto eth0
iface eth0 inet static
address <type your address>
netmask <normally: 255.255.255.0>
gateway <where send Dhcp request>

Save changes and restart the system with "reboot" command.
After reboot,if you don't know private ip of your server, find it typing:

ifconfig

Search in eth0: "inet addr:X.X.X.X", where X.X.X.X is the private IP server.

Test your server connection sending a ping request:

<pre>

ping X.X.X.X

</pre>

After this, upgrade your system with "apt-get".

Installing Open SSH Server

Type login as root via serie:

apt-get install openssh-server

Change root password typing:

passwd root

Enter new password, i recommend use letter, numbers and symbols like:?¿!...

Search in eth0: inet addr:X.X.X.X, where X.X.X.X is the server private IP. We are going to prove it login as root via ssh:

ssh root@X.X.X.X

Using the password typed above, we be able to connect to server via SSH.

The next steps are not necessary use serial communication .

Creating and editing Server Users

Using root user can be dangerous, for this reason we are going to create a new user named adminserver to access server. Create new user typing:

adduser adminserver

Follow the assistant entering a password and your user data.

Once adminserver user was create, we are going to give sudoers privileges. Type:

visudo

Go to: # User privilege specification, and add below:

adminserver ALL=(ALL) ALL

Defaults:adminserver    timestamp_timeout=0, runaspw, passwd_tries=1

The first line says that adminserver user can access like root with sudo command.

The second line, configure some paremetres to adminserver sudo access: adminserver needs root's password to run sudo (runaspw), the password will not be remembered (timestamp_timeout) and he gets only one chance to enter it (passwd_tries).
NOTE: Is important use visudo editor because it can detect spelling errors before write sudoers file.

Installing LAMP

Apache

We are going to install Apache HTTP Server:

sudo apt-get install apache2 apache2-mpm-prefork

After installation, we are going to make some configurations:

mkdir /home/<user>/web/

We create that folder called web to store all the web files.

Now we are going to change some basic Apache configuration, edit: /etc/apache2/sites-available/default

Search line:

DocumentRoot /var/www/

Replace by:

DocumentRoot /home/<user>/web/

Search line:

Directory /var/www/

Options Indexes FollowSymLinks MultiViews

Replace by:

Directory /home/<user>/web/ 

Options FollowSymLinks

Search line:

AllowOverride None

Replace by:

AllowOverride all

Save and exit.

Add the following lines to the bottom of /etc/apache2/apache2.conf

ServerSignature Off
ServerTokens Prod

Restart Apache:

sudo /etc/init.d/apache2 restart

Now we have a Apache with basic improved configuration.

Under construction: Explain configuration

PHP

Now we are going to install, the required packages to run Owncloud, if you want to install more Webs like Wordpress, Joomla, etc. Maybe you need install others. Type:

sudo apt-get install php5-mysql php5-sqlite php5-json php5-curl libapache2-mod-php5 libxml2 php5-cli php5-common sgml-base xml-core php5-ming libcurl3 libfreetype6 libgif4 libming1 libmysqlclient16 libsqlite0 mysql-common php5-curl php5-ming php5-mysql

Restart Apache:

sudo /etc/init.d/apache2 restart

MySQL + PHPmyAdmin

sudo apt-get install mysql-server mysql-client phpmyadmin

When we are installing MySQL, we configure it entering password for root MySQL database. Also when we are installing phpmyadmin we should choose: configure database for phpmyadmin with dbconfig-common, type root MySQL password again,  type phpmyadmin password database, choose apache2 confiuration .

Restart Apache:

sudo /etc/init.d/apache2 restart

Make a simbolic link to phpmyadmin:

sudo ln -s /usr/share/phpmyadmin /home/adminserver/web/phpmyadmin

With phpmyadmin you can handle your mysql databases (managing databases, tables, fields, relations, indexes, users, permissions, etc) via web browser. It is useful if you for Owncloud or another program than uses MySQL.

Enabling Automatic Updates

Automatic updates can be used to automatically install updated packages. You can configure it to update all packages or just security packages. Install the following package:

To configure unattended-upgrades, edit:/etc/apt/apt.conf.d/50unattended-upgrades and adjust the following to fit your needs:

The double “//” serve as comments, so whatever follows "//" will not be evaluated. Coment/uncoment the repositoris that you prefe, i recommend this configuration:

Unattended-Upgrade::Allowed-Origins {
        "${distro_id} stable";
        "${distro_id} ${distro_codename}-security";
//      "${distro_id} ${distro_codename}-updates";
//      "${distro_id} ${distro_codename}-proposed-updates";
};

You can blacklisted some packeges, you can enable automatic removes, autoremove orphans packages,etc.

To set everything first create a file: /etc/apt/apt.conf.d/10periodic and edit it with your favorite editor, my configuration is:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

The above configuration updates the package list, downloads, and installs available upgrades every day. The local download archive is cleaned every week.

For more information go to here.

Set up a External HD

External HD is useful to get more space for our project. In this part we are going to set up our HD when it is connected to server.

Format your HD with a EXT3 Filesystem.

Create the following script: /etc/udev/rules.d/50-mount-external.rules:

KERNEL!= "sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"

# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"

# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"

# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"

# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"

# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"

# Exit
LABEL="media_by_label_auto_mount_end"

Stop/start the udev deamon:

/etc/init.d/udev stop
/etc/init.d/udev start

Connect your HD to server. Use "mount" command to see External HD information.

/dev/root on / type ext3 (rw)
none on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/kernel/debug type debugfs (rw)
none on /dev type tmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
/dev/sda1 on /media/usbhd-sda1 type ext3 (rw,relatime)

Where our HD si mounted in media folder, and its name is usbhd-sda1

Set up Owncloud.org Software

Installing Owncloud.org

Owncloud software need some packages:

For improved scanning of music files:

sudo apt-get install mp3info

For downloading multiple files:

sudo apt-get install zip

For the OpenID plugin

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

This how-to uses the lastest release of Ownlcoud but if you use stable version it would be similar. Download Owncloud in your root Apache folder.

sudo apt-get install wget
cd /home/adminserver/web/
wget http://gitorious.org/owncloud/owncloud/archive-tarball/master

Uncompres it:

tar -zxvf master

Make Root file folder in External HD:

cd /media/usbhd-sda1
sudo mkdir DATA
sudo chown -R www-data:www-data DATA

Make ownCloud directory accessible to Apache:

cd /home/adminserver/web/
sudo chown -R www-data:www-data owncloud-owncloud/

Open your web browser and finish your Owncloud instalation. Go to: http://<IP PRIVATE SERVER>/owncloud-owncloud/ Put your personal information and select MySQL Database. once finish, click Finish Setup.

Previewowncloudinstallation1.png

Configuring Owncloud.org

Under construction

Configuring Apache and PHP for Owncloud

Under construction