Official website

Monday, February 2, 2015

Setting up Banana Pi/Lubuntu, running and tweaking

In this post I will describe some things I did to the Banana Pi/Lubuntu in order to match my requirements for a smooth operational Jubito server, as well, fixes on some issues I've been faced.

I'll bypass the installation process on SD card because it's pretty easy.

Step 1:
Resize and expand the partition.
I'm using a 16GB SD card so when I flash the image, which is approximately 3.7GB I end up with an unmanaged partition. To make it available I did the steps that follow...
(*) Do this only right after flashing the image on the SD-Card, so if anything goes wrong you do not lose any data.

sudo fdisk /dev/mmcblk0
  • Press ‘p’ to print the partition table
  • Press 'd' to delete a partition
  • Enter '2' to choose the second partition
  • Press 'n' to create a new partition
  • Enter 'p' to select primary as partition type
  • Partition number: enter to accept 2 as default partition number
  • First sector: enter to accept default
  • Last sector: enter to accept default
  • Press 'w' to write the new partition table
Reboot to force the kernel to recognize the new partition table.

sudo reboot

After the system has come back up you still have to resize the partition.

sudo resize2fs /dev/mmcblk0p2

[ Source: http://gleenders.blogspot.gr/2014/08/banana-pi-resizing-sd-card-root.html ]

Step 2:
Use sudo apt-get update && sudo apt-get upgrade or Menu->System Tools->Software Updater to download the latest patches and updates that fix issues, like Firefox crash.

Step 3:
Change the default username (I), password (II), hostname (III) [ Source: http://banoffeepiserver.com with minor changes ]

(I) Many Linux images have a default username and password. The default username and password for the Raspbian image are 'pi' and 'bananapi' (in many of the Banana Pi Linux distributions, the default username is bananapi). It's best to change these login details so that no one else can log into your Pi.

You need to configure your Pi to boot to a command line - the following procedure won't work if you're logged into a desktop session. Once you've booted to a command line, you need to change the shell session to the root user. This is necessary because you can't modify a user account while you're logged in as that user.

exec sudo -s

Now all commands are executed as the root user. Change to a different directory than /home/bananapi:

cd /

Use the usermod command to change username of the default account.

usermod -l <newname> -d /home/<newname> -m <oldname>

When you reboot, you'll need to log in using the new username. Optionally you can change the group name.

groupmod -n <newgroup> <oldgroup>

Instructions above may damage or cause dis-behaviors. For your convenience, I suggest you to make same actions or create a new user from a controlled environment. That can be easily managed from User Settings under Menu->System Tools->Users and Groups.


(II) One of the most important things to change is the password.  Using the default password is a monumental security risk.  The default password for most Banana Pi Linux distributions is simply bananapi. Change it using the passwd command:

passwd
Changing password for john.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:


You will be prompted to enter your current password, followed by your new password twice.

(III) The hostname is the name of your server as it appears on your local network.  You may need to change the hostname if you have more than one Banana Pi on your network. You'll need to change it in two places:

/etc/hostname
/etc/hosts


The hostname is set in /etc/hostname.  This file only contains the hostname. Open it as root, and change the name.  I've change it from 'lemaker' to 'jubito'.
In /etc/hosts, there's a list of IP addresses and their host names. This file contains a table mapping IP addresses to host names.  Open it with this command:

sudo leafpad /etc/hosts

Look for an entry with IP address 127.0.1.1 lemaker, and change the host name as required.
Reboot your Banana Pi, and you should see that its host name has changed.

Step 4:
I've tried the Banana Pi in various monitors and I noticed that screen resolution doesn't fit automatically. I decided to set it up manually, by disabling the EDID auto-detection. To do so, edit the uEnv.txt file located in a small partition and mounted in Desktop and remove the EDID like this:

disp.screen0_output_mode=EDID:1280x720p50
to
disp.screen0_output_mode=1280x1024p60 (example for a non wide 15" monitor)


Step 5:
Auto login feature is necessary, if you're using Banana Pi as a standalone server with no peripherals (monitor, keyboard, mouse). When its rebooted or reset we need to restore Jubito and x11vnc server (described at Step 6) at startup without user interference. I tried the "Don't ask for password on login" from System Tools->Users and Groups->User Settings without luck. The workaround came with a lightdm hack.

Edit or create a file -if not exists /etc/lightdm/lightdm.conf and add the following content:

[SeatDefaults]
autologin-user=<YOUR USER>
autologin-user-timeout=0
user-session=ubuntu
greeter-session=unity-greeter


Step 6:
Remote desktop using the lightweight x11vnc server.

Install
sudo apt-get install x11vnc

Set password protection

mkdir ~/.x11vnc
x11vnc -storepasswd <YOUR PASSWORD> ~/.x11vnc/passwd

Create a shell script in any directory, for example in /home/<YOUR USER> and call it start-vnc.sh. This will used as x11vnc launcher.
Run leafpad leafpad ~/start-vnc.sh and paste the code below.

#!/bin/sh
x11vnc -forever -display :0 -rfbauth ~/.x11vnc/passwd


Now save and close the file.

Finally add it to LXSession configuration under Autostart tab.
Go to Menu->Preferences->Default applications for LXSession and add the line below...

lxterminal -e bash /home/<YOUR USER>/start-vnc.sh


or do the same by edit the local ~/.config/lxsession/<profile>/autostart file.
At next reboot the x11vnc server will be run.

Step 7:
Since there’s currently no build of the Dropbox sync client that runs on ARM devices and at this time I don't want to spend my time seeking for a solution, I'm going to use  the ownCloud alternative for syncing security breach videos.

Create an account to blaucloud.de and get the free plan that gives 2GB of space and then install the ownCloud client:

sudo apt-get install owncloud-client


Open the program and set your preferences. It's very easy.

I chose this service, because it does its job well. I get set up my own independent cloud-space instance on basis of ownCloud within a few minutes. They are also providing an android app that makes it more comprehensive solution, much like Dropbox.

Step 8:
With most Linux distributions special configuration for USB devices like Arduino are mostly needed, to workaround or fix common issues, when run as a normal non-root user.

First thing is to apply udev rules. To proceed you need to know vendor ID and device ID. Open a terminal and type lsusb to locate your Arduino and keep values in mind (i.e. 2341:0001).


Now create a file /etc/udev/rules.d/99-arduino.rules and paste the lines below where idProduct and idVendor values from the previous step:

SUBSYSTEMS=="usb", ATTRS{idProduct}=="2341", ATTRS{idVendor}=="0001", SYMLINK+="ttyACM%n", MODE="0666", GROUP="dialout"
SUBSYSTEMS=="tty", ATTRS{idProduct}=="2341", ATTRS{idVendor}=="0001", SYMLINK+="ttyACM%n", MODE="0666", GROUP="dialout"


Next you'll need to reload udev's rules so that they are properly applied.  You can restart your machine, or run a command like the following:

sudo reload udev

If the command above fails, try instead running:

sudo udevadm control --reload-rules
sudo udevadm trigger



You can also add yourself to the dialout group (which requires re-login to enable) with...

sudo usermod -a -G dialout $USER

In addition, change the owner of the port.

sudo chown <user>:<group> <file>
e.g.: sudo chown john:john /dev/ttyACM0

Another effective way that worked for me in the past was to change the access permissions.

sudo chmod a+rw /dev/ttyACM0

To take effect in each reboot, you have to edit /etc/rc.local and add the line that works for you (except dialout). Don't forget to follow by exit 0.


I document all the steps I've tried. Probably, not all of them are needed. Try it with your own configuration to ensure what suits you.
That's all for now. I hope to find some of these useful for your setup.
More close to a JubitOS image (?)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.