Sunday, 5 October 2014

BeagleBone: Running out of space issues

If you run out of space on your beaglebone device and you are pretty sure that you haven't installed much applications on your device, then you might probably have hit the issue of excessive journal logs created under /var/log/journal directory.

To verify if you have hit same issue as described here:

ls -lah /var/log/journal/3e6dbfde94404a9ead5480caeac3ef4f
    The directory under journal may vary in your case. If it some hundred of MB or even some value which you think is probably high in your case, then you are hitting same issue.

Steps to clean space:
a. rm -Rf /var/log/journal/3e6dbfde94404a9ead5480caeac3ef4f/*
    Again the directory name under journal may vary in your case.
b. Edit /etc/systemd/journald.conf to change journal settings.

Content of journald.conf file from my device

=======================================================================
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# See journald.conf(5) for details

[Journal]
Storage=volatile
#Compress=yes
#Seal=yes
#SplitMode=login
#RateLimitInterval=10s
#RateLimitBurst=200
SystemMaxUse=16M
#SystemKeepFree=
#SystemMaxFileSize=
#RuntimeMaxUse=
#RuntimeKeepFree=
#RuntimeMaxFileSize=
#MaxRetentionSec=
#MaxFileSec=1month
ForwardToSyslog=no
#ForwardToKMsg=no
#ForwardToConsole=no
#TTYPath=/dev/console
MaxLevelStore=4
MaxLevelSyslog=4
MaxLevelKMsg=4
MaxLevelConsole=4

=======================================================================

For details on these values and attributes check http://www.freedesktop.org/software/systemd/man/journald.conf.html

c. Reboot the device.

BeagleBone: micro-SD card

The beaglebone black has 2 GB of built-in flash storage which also included pre-installed operating system. If you try installing other applications you will soon run out of space. To overcome this issue, we can use a micro-SD card as an external storage

Follow these steps to enable and use micro SD card as external storage
a. Connect beaglebone to 5V power adaptor. Also connect the device using USB to access it through VNC.
b. Using USB Adaptor, insert micro-SD card into USB port.
c. Open VNC, go to Applications --> System tools --> Disk Utility
d. Unmount the microSD card volume.
e. Format the drive using "Master Boot Record" as scheme and "ext4" as partition type. You can choose any name and mount point say '/media/drive'.
f. Now go to the drive and create a file uEnv.txt
g. Put following as content of the file:
    mmcdev=1
    bootpart=1:2
    mmcroot=/dev/mmcblk1p2 ro
    optargs=quiet

h. Disconnect the micro-SD card from the USB adapter and insert the card into micro-SD card slot.
g. Reboot the device and SD card will be automatically mounted. It can be used as external storage.

BeagleBone: Connecting Via USB

The BeagleBone black comes with a USB cable that can be used to connect it to your computer/laptop. The cable at the one end has standard USB plug that would go into free port of your main computer and at the other end it has mini-USB plug that would go into mini-USB port of beaglebone black.

After the connection is made, the beagle bone will quickly boot up (roughly 10 sec) and you will see blinking LEDs just above mini USB port.

Connecting to Web Server:

BeagleBone also runs a mini web server. We can connect to this web server by connecting beagle bone to our network hub or router via Ethernet cable.

The alternate to this is to use USB Network bridge capability of beaglebone. To use this feature, you need to install drivers on your main computer, follow instructions on http://beagleboard.org/getting-started

When using USB Network bridge, web server running on beagle bone can be connected using
http://192.168.7.2/

You will see something like


Connecting via SSH using putty:

a. start putty and type following details
    host name: 192.168.7.2
    port : 22

b. When it prompt for 'login as :', type 'root' and press enter.
c.  For password, just hit enter.

If you face issue when connecting first time using SSH, then try this:
a. Disconnect from mini USB Port and connect it to 5V USB adaptor that comes along with it.
b. Connect device  to some monitor/LED tv using HDMI cable, attach a mouse to it's USB port for navigation.
b. Once the device boot up, you would be able to see screen similar to some linux startup screen.
c. Navigate to file system --> etc --> dropbear
d. Notice that the size of file dropbear_rsa_host_key is Zero bytes.
e. Delete this file dropbear_rsa_host_key.
f. Disconnect the device from HDMI cable, 5V adaptor and mouse.
g. Connect the device again using mini USB port to you main computer.
h. The file dropbear_rsa_host_key will automatically get created at startup and will not be zero byte file anymore.
i.  Connect using SSH and it should work fine.

Dropbear is default SSH server running on beaglebone. If you need to start/stop SSH server use following commands:
a. /etc/init.d/dropbear start
b. /etc/init.d/dropbear stop

Connecting via VNC:

Install x11vnc on your beaglebone device. x11vnc might pre-installed on your device, if not follow below steps for installation.[ Note: you will require internet connection for this. Connect Ethernet cable to beaglebone Ethernet port and connect other end to home router/hub., DON'T forget to power up device with 5V adaptor]

a. opkg update
b. opkg install x11vnc
c. x11vnc -bg -o %HOME/.x11vnc.log.%VNCDISPLAY -auth /var/run/gdm/auth-for-gdm*/database -display :0  -forever




To start VNC server automatically on start-up, you can create a file startVNC.sh under home directory and provide execute permission to this file. Put the command (c) as the content of this file.
Now navigate to System --> Preference --> Startup Applications, put entry for this script file.

BeagleBone black


BeagleBone black is single board linux computer that can be used as a general purpose linux computer or as a platform for embedded hardware project. I am using BeagleBone Black rev 0A6A S/N 0414BBBK2103.

Some of the features of BeagleBone black are:
  • 1 GHz ARM processor.
  • 512 MB of RAM.
  • Angstrom Linux operating system installed out of the box to 2 GB built-in flash storage.
  • Capability of booting directly from micro-SD card.
  • Quick boot time roughly 10 seconds.
  • 7 Analog and about 60 digital input/output pins that can be used for communicating with various electronic devices.
  • An Ethernet network port.
  • A micro-HDMI socket.
  • A USB port to attach peripherals.
  • USB Network bridge capability.



There are different ways for connecting to beaglebone black. The easiest of them is to connect via USB. Other ways include connecting via HDMI or though internet via Ethernet cable.

a. Connecting Via USB

Some other things that you would probably need to know:
a. To Shutdown the device, on the shell prompt type 'shutdown now'

b. To change system date of device, on the shell prompt type
date -s "16 SEP 2014 18:31:00"
If you connected to network, time can be updated over network using
ntpdate -b -s -u pool.ntp.org

c. Sometime you may need to sync hardware clock with system clock, this can be achieved using
hwclock --systohc
 
To see current time on hardware clock type,
hwclock --show or hwclock -r

d. Cloud9 IDE: This is default IDE installed on the beaglebone. When connected using USB, type in browser http://192.168.7.2:3000/



References:
a.Programming the BeagleBone Black: Getting Started with JavaScript and BoneScript