Einrichten Eines Heimservers Auf Cubietruck
Total Page:16
File Type:pdf, Size:1020Kb
Attempt to install a home server on a Cubietruck Dr Engelbert Buxbaum k [email protected] June 2016 This text is based on the manuals for Armbian (http://www.armbian.com/cubietruck/), Cubian (https://github/cubieplayer/Cubian/wiki/Get-started-with-Cubian), the tuto- rials on https://stefanius.de/category/minicomputer/tutorials-minicomputer/cubieboards- tutorials-minicomputer, https://doc.owncloud.org/server/9.0/admin_manual/instal, ! lation/source_installation.html and two papers in c’t (2016:8 106–111 and 2014:21 74–77). 1 Install operating system • Get Armbian_5.10_Cubietruck_Ubuntu_trusty_4.5.2.7z from http://www.arm, ! bian.com/cubietruck/, unpack and install the image on an SD-card. Under Win- dows this is done with Win32DiskImager after changing the ending of the image file to .img. Under Linux use dd). • Insert SD-card in Cubietruck, connect 2:5 00 HD, monitor, ethernet-connection to the network and switch on power. Wait for the boot process, login as root with password “1234”. The system will force you to change the root password and suggest that you define a user for every day work (in the following “Hugo”). This user has sudo-rights, Ubuntu automatically creates a group with the user name, too. • Further users may be created with: – root@cubietruck:~$ adduser <UserName> – root@cubietruck:~$ usermod -aG sudo <UserName> • Use dpkg-reconfigure keyboard-configuration to change the keyboard (de- fault is US). Similarly, use options locales, console-setup, or tzdata for lan- guage, font and timezone). 1 • The Cubie per default is connected to the net by DHCP, we leave it like that for the time being. It is, however, possible to assign a fixed IP-address. • Update the operating system: – root@cubietruck:~$ apt-get update – root@cubietruck:~$ apt-get upgrade • There is no graphical user interface, we use the lightweight and fast xfce: – root@cubiecubietruck:~$:apt-get install xorg xfce4 xfce4-goodies thunar-archive-plugin – root@cubiecubietruck:~$:apt-get install xdg-utils xfce4-power-manager htop bzip2 – root@cubiecubietruck:~$:apt-get install synaptic gdebi wicd zip un- zip unrar-free – root@cubiecubietruck:~$:apt-get install lightdm tango-icon-theme gnome-icon-theme – root@cubiecubietruck:~$:reboot – After login, use hugo@cubietruck:~$:startx • Partition the hard disk and create user-space: – root@cubietruck:~$ cat /proc/partitions major minor # blocks name 179 0 31166976 mmcblk0 179 1 65536 mmcblk0p1 179 2 31100416 mmcblk0p2 8 0 244198584 sda – Note: Should the list contain sda1 and higher, the disk has been partitioned already. In this case, once fdisk has been started (see below) first delete these partitions (command d). For new disks this step is not necessary. – root@cubietruck:~$: fdisk /dev/sda Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): <CR> Using default value 1 First sector (2048-488397167, default 2048): <CR> Using default value 2048 Last sector, +sectors or +sizeK,M,G (2048-488397167, default 488397167): +32G 2 – This partion will later contain the operating system. 32 GB should be suffi- cient even for a large Linux installation. Next create the partition sda2, using defaults for both first and last sector. This will be the data partition for the server. – Command (m for help): w – root@cubietruck:~$: mkfs.ext4 /dev/sda1, followed by a lot of messages. – This too we repeat for sda2 Problem: I haven’t manged to connect the Cubie to my wlan (operating with wpa2). The description in all the references cited is very unclear and this seems to be much more of a problem than with a windows or android client. Wicd can establish a connection and obtain an IP address, but that connection is closed without comment after a few seconds. 2 Create directories for the data • Mount /dev/sda2 as /media/srv, then create the subdirectories and set permis- sions. For this purpose open a terminal: – hugo@cubietruck:~$: sudo -i – root@cubietruck:~$: mkdir /media/srv – root@cubietruck:~$: nano /etc/fstab * Add the following line: /dev/sda2 /media/srv ext4 defaults 0 2 * Safe with “^o”, confirm the file name with <CR> and leave the editor with “^x”. – root@cubietruck:~$:mkdir /media/srv/music – root@cubietruck:~$:mkdir /media/srv/video – root@cubietruck:~$:mkdir /media/srv/pictures – root@cubietruck:~$:mkdir /media/srv/samba-private – root@cubietruck:~$:mkdir /media/srv/public – root@cubietruck:~$:mkdir /media/srv/owncloud – root@cubietruck:~$:chmod 775 /media/srv – root@cubietruck:~$:chmod 775 /media/srv/samba-private – root@cubietruck:~$:chmod 775 /media/srv/music – root@cubietruck:~$:chmod 775 /media/srv/video – root@cubietruck:~$:chmod 775 /media/srv/pictures 3 3 Install Samba server • root@cubiecubietruck:~$:apt-get install openssh-server x11vnc samba libpam- smbpass • root@cubiecubietruck:~$:x11vnc -storepasswd /etc/x11vnc.pass • root@cubiecubietruck:~$:nano /lib/systemd/system/x11vnc.service [Unit] Description=Start x11vnc at startup After= multi-user.target [Service] Type=simple ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared [Install] WantedBy=multi-user.target • Safe and leave the editor. • root@cubiecubietruck:~$:systemctl enable x11vnc.service • root@cubietruck:~$: reboot Error message: systemctl not found. Probably because the linux version is older (14.04) than that on which the c’t paper is based (15.10). Unfortunately, there are no Armbian images for Xenial (16) yet, those should solve the problem. 4 Install SSH on client computer • For windows download from http://www.chiark.greenend.org.uk/~sgtatham/, ! putty/download.html the putty-0.67-installer.msi and install. Start PuTTY, under “Host Name” enter the IP-address of the Cubie (can be found at the arm- bian start screen, e.g., 192.168.2.103) and under Connections SSH Tun- ! ! nels in Destinations enter: L5900 localhost:5900. Then you can log into the cubie from your desktop and remotely control it. You don’t have to walk to the basement anymore! • From a linux computer you achieve the same thing with ssh name@ip-of-server -L 5900:localhost:5900. Suboptimal: The connection to the cubie is lost if the desktop computer goes to sleep. 4 5 Create samba shares • hugo@cubietruck:~$: sudo -i • Enter the Samba/Public directory into /etc/samba/smb.conf in block [global]: workgroup = WORKGROUP security = user • Add the block [public] to the end of this file: [public] guest ok = no comment = Public Samba Share path = /media/srv/public browsable = yes read only = no create mask = 0755 force user = hugo force group = hugo • Create shares for music, pictures and video according to the same scheme. All users with account on the cubie can read and write to these directories • Samba can create private shares for the users: [homes] comment = Private Directories path = /media/srv/samba-private/%u browsable = yes read only = no create mask = 0700 directory mask = 0700 valid users = %S • Safe the file and leave the editor. • Create a shell-skript in /usr/local/sbin/adduser.local to generate a directory for each new user in samba-private (also with nano): #! /bin/bash mkdir /media/srv/samba-private/$1 chown $1:$2 /media/srv/samba-private/$1 chmod 775 /media/srv/samba-private/$1 • Make this script executable: root@cubietruck:~$:chmod 775 /usr/local/sbin/adduser.local • For the already existing user Hugo this has to be done by hand: root@cubietruck:~$: mkdir /media/srv/samba-private/hugo root@cubietruck:~$: chown -R hugo:hugo /media/srv/samba-private/hugo 5 • Each new user has to log in directly on the cubie or via SSH, bevor they can use Samba. This allows the communication of right management between windows and linux by libpam-smbpass. Problem: With Armbian 5.10 no cubietruck folders appear in the Windows network folder. 6 Set up DLNA-Server • root@cubiecubietruck:~$: apt-get install minidlna • minidlna is controled by /etc/minidlna.conf, which we edit with nano: media_dir=A,/media/srv/music media_dir=V,/media/srv/video media_dir=P,/media/srv/pictures • Then restart the server with root@cubiecubietruck:~$: service minidlna start. minidlna icon does not appear in the windows explorer. 7 Install a LAMP web server and OwnCloud LAMP is the abbreviation for Linux as operating system, Apache as web-server, Mysql as database and Php as script language. • root@cubiecubietruck:~$:apt-get install apache2 mysql-server phpmyad- min • Mysql asks during the installation for a password for the database manager and for the web-server (apache2). • phpmyadmin offers an installation script which wwe use to select Apache2 as server and to set a password for the database user phpmyadmin. This has to be identical to that for the mysql-administrator. • If you now open a browser with the IP of the cubie (that is, in above example 192.168.2.103), a message should confirm the correct installation of apache. OwnCloud cannot be installed from the package repository of Ubuntu, we get it di- rectly from owncloud.org: • root@cubiecubietruck:~$:wget -nv https://download.owncloud.org/download/, repositories/stable/xUbuntu_14.04/Release.key -O Release.key ! • root@cubiecubietruck:~$:apt-key add - < Release.key • root@cubiecubietruck:~$:rm Release.key 6 • root@cubiecubietruck:~$:sh -c “echo ’deb http://download.owncloud.org/download/, repositories/stable/xUbuntu_14.04/ /’ /etc/apt/sources.list.d/owncloud.list“ ! • root@cubiecubietruck:~$:apt-get update • root@cubiecubietruck:~$:apt-get install owncloud • If you open your browser on 192.168.2.103/phpmyadmin you should be able to log into the database and create the user “owncloud”. Problem: 192.168.2.103/phpmyadmin is not found, a2disconf phpmyadmin gives: Conf phpmyadmin does not exist. However, 192.168.2.103 is found and a reload of apache2 is also possible. According to M. Dölle Apache expects phpmyadmin in /var/www/html, however, dpkg -S phpmyadmin results in /usr/share/phpmyadmin and its subdirecto- ries.