Tuesday, April 9, 2013

Mele as a media server

Perfect media server

Your media (and general purpose) server should have:
  1. Torrent daemon
  2. samba share
  3. mysql + php + nginx
  4. software to queue, rename and organize your downloads (I'm using sickbeard+ couchpotato) 
  5. misc

Operative system

I'm choosing debian armhf, but feel free to try ubuntu arm or arch arm.
Follow either Guillaume's or Roman's instructions on how to install.


Software

Torrent daemon

I chose to use transmission-daemon over deluge (and didn't try any other) because deluged + deluge-web was eating up to 30MB of ram, where as transmission-daemon uses 2MB of ram, and the Mele has only 512MB.

Configuration

# apt-get install transmission-daemon
# service transmission-daemon stop
# vi /etc/transmission-daemon/settings.json

set rpc-whitelist-enabled to false
add
   "watch-dir": "/home/storage/torrentfiles",
   "watch-dir-enabled": true
at the end of the file if you want transmission to pick up the torrents placed in that folder (both couchpotato and sickbeard can do that)

# service transmission-daemon start

Log in to the default port http://127.0.0.1:9091. The default password is transmission.
On the webui I set up a watch directory because sickbeard stores the torrent files there, and transmission loads them.

Samba share

Configuration

#apt-get install samba-common-bin samba-common samba

Each samba share configuration is unique to the user, but I've set a share with read-write, anonymous access.
At the end of the /etc/samba/smb.cnf file add
[share-name]
  path = /path/to/share
  read only = no
  writeable = yes
  guest ok = yes



Mysql + php + nginx

#apt-get install nginx php5 php5-mysql php5-fpm mysql-server-5.5 mysql-client-5.5 php5-mysql

Mysql configuration

Remote access
I'm assuming  you used 'root' for your username.

mysql -u root
If you didn't set up a password
mysql> SET PASSWORD FOR 'ROOT'@'LOCALHOST' = PASSWORD('your_new_password');

To gain remote access with the username

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> exit


#vi /etc/mysql/my.cnf
comment out the line that says 
bind-address = 127.0.0.1
#service mysql restart

Optimize the ram usage of mysql


nginx

I chose nginx because of it's small memory footprint and high performance. Check benchmarks vs apache to see the difference.
Configuration
#vi /etc/nginx/sites-available/default

A webserver's config changes totally, depending the needs of the host. Here's an example link


Couchpotato, SickBeard

#apt-get install git-core python2.7 python-cheetah
$ git clone git://github.com/RuudBurger/CouchPotato.git
$ git clone git://github.com/midgetspy/Sick-Beard.git

Follow on-screen intructions for both.



Misc

Here's the server running all the processes (no couchpotato)

Mount ntfs with write permission
#apt-get install ntfs-3g
#mount /dev/sd# /path/you/want

Overclock

#echo '1110000' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

Leds

use "1" to turn them on, you might need to run #insmod sun4i-gpio
power off blue led
echo "0" > /sys/devices/virtual/misc/sun4i-gpio/pin/ph20
power off red led

echo "0" > /sys/devices/virtual/misc/sun4i-gpio/pin/ph10

Thursday, February 21, 2013

Ubuntu and XBMC on the MELE

Been trying to set up the MELE as a media/home server and found guillaume's blog (http://guillaumeplayground.net)

Get the ubuntu 12.10 armhf image with the patched 3.0.4.2+ kernel from here  (MD5: 32e181589ac4232fdaac3e9f86546e87)

Decompress the image and dd it to your SD card.
Put it in the MELE, connect VGA/Ethernet and turn it on.
Default user/password is: root/root

To modify the video output, led flashing and MAC address, run PIMP_MY_MELE as root.
It's a perl script located on /usr/local/pimpmymele/

Sata module is not loaded by default.
To load it until reboot, run
modprobe sw_ahci_platform
or load it on boot with
echo "sw_ahci_platform" >> /etc/modules; reboot
Check your MELE speed
# grep BogoMIPS /proc/cpuinfo
BogoMIPS : 1001.88

If not:
rm -f /etc/rc2.d/*ondemand
echo "cpufreq-set -g performance" >> /etc/rc.local
cpufreq-set -g performance


Overclocking
This is dangerous. You've been warned. This will set your frequency at 1.15GHz and it will be off when you reboot (stress test to see if your MELE is stable; glxgears is useful)
echo '1152000' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
If you want to make this permanent run
echo "echo '1152000' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" >> /etc/rc.local

Available frequencies are at /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequenciesConsider that you'll need overvoltage to pass 1.2GHz, and if you plug in an external HDD / sata HDD, the current might not be enough for the processor

This got me from 35.785 to 39.447 fps on GLXGears (~10% performance increase with a 15% OC)


XBMC
Download the files (compiled from 
git://github.com/empatzero/xbmca10) and decompress them to / (yes, to root)

You can run these from X
/allwinner/xbmc-pvr-binhf/bin/xbmc
/allwinner/xbmc-pvr-binhf/bin/xbmc-standalone
or this from a TTY
/allwinner/xbmc-pvr-binhf/lib/xbmc/xbmc.bin

Considering it runs on framebuffer, if you run it from SSH you'll see the cursor where it was; if you run it locally the cursor will go to the last row and it'll be unnoticeable

Before setting up XBMC on boot you should test audio and video; as well as automounting if you plan on using external disks or pendrives.


If you have dependecy problems launching xbmc 
Run 
apt-get install xbmc
You won't run the repo version, but some libraries/dependencies are not in the tar