Beaglebone Black : Get More Space From Your SD Card

sandisk-micro-8While researching for my post, “Backing up your Beaglebone Black“, I came across an article that demonstrated how to expand the linux partition from the standard image size.  I use an 8GB card and after flashing my sd card with the Ubuntu image, I had roughly 4GB of unused space.  Since space is at a premium, I have added external USB drives to help with that but leaving 4GB on the table is just silly.  So I decided to fix that today.

Even though I’m doing this on an Ubuntu instance, this should work for Angstrom instances as well.  However, be forewarned that this is potentially dangerous for your file system.  Make backups, double-check your work, and test this out on an install you can afford to lose before doing it on one you can’t.  Warning over.  Let’s get back to throwing caution to the wind.

First, let’s take a look at what we’re working with.  As root, run:

fdisk -l

This will spit out a list of all the partitions on your BBB.  The one we are concerned with today is mmcblk0.

Now, using the fdisk utility, we can resize the card while in the BBB.  We’re going to delete the existing partition, then create a new one, expanding its size and then wrap it all up with a bow on top.

Let’s start with:

fdisk /dev/mmcblk0

You will get a prompt:

Command (m for help):

If you’re curious, enter ‘m‘.  You should be safe here, just don’t enter ‘w‘ which is write! If you’re unsure at any time, you can enter ‘q‘ to bail without committing.

Here’s the sequence to resize the card:

root@ubuntu-armhf:~# fdisk /dev/mmcblk0

Command (m for help): d
Partition number (1-4): 2

Command (m for help): n
Partition type:
 p primary (1 primary, 0 extended, 3 free)
 e extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (4096-15523839, default 4096): <enter>
Using default value 4096
Last sector, +sectors or +size{K,M,G} (4096-15523839, 
default 15523839): <enter>
Using default value 15523839
Command (m for help): w

The partition table has been altered!
Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 
Device or resource busy. The kernel still uses the old table. 
The new table will be used at the next reboot or after you run 
partprobe(8) or kpartx(8)
Syncing disks.


Now, since the partition is currently in use, we won’t see any change until we reboot. Let’s do that now:

shutdown -r now

When the BBB comes back, you will have a 4GB partition in an 8GB partition.  We can fix that with a utility called resize2fs.  Here’s how to use it.  As root run this command:

resize2fs /dev/mmcblkp2

When this command completes, reboot again and then run ‘df -h‘.  Here’s what mine looks like:

dfrey@ubuntu-armhf:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mmcblk0p2 7.3G 1.4G 5.6G 20% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
devtmpfs 248M 4.0K 248M 1% /dev
none 50M 244K 50M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 248M 0 248M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/mmcblk0p1 1004K 472K 532K 48% /boot/uboot

Personally, I think this is a better solution than the USB drive but the USB drive works for backups and supporting content like MP3s, videos etc to host on my WordPress site. Space is still at a premium but at least now I have a little more breathing room.


Beaglebone Black : Issues with Java on Ubuntu

java-duke-logoWhile I was starting work on my next walk-through, I discovered that I had not installed Java on my Ubuntu instance.  I don’t know why other than it simply didn’t come up.  When I originally installed it, I did it on Angstrom and had no issue.  Well, it was most certainly a different story with Ubuntu.

I downloaded the ARM version of JDK 1.7 from and attempted to unpack it with this command:

tar -xvpzf jdk-7u40-linux-arm-vfp-hflt.tar.gz

Instead of a stream of files being strone across my screen, I received an error message:

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

I thought that I had corrupted my instance so I unpacked my latest backup.  As a side note, I dug around a bit and discovered how to overwrite existing files.  Here’s that command:

tar --overwrite -xvpzf bbb-ubuntu.tar.gz

This reset my BBB to my standard setup.  After attempting to unpack the Java tarball again, I received the same error.  I also unpacked the package on my host machine and then moved it over to the BBB and attempted to run Java.  It looked at me like I was daft and replied with:

-su: jdk1.7.0_25/bin/java: No such file or directory

Hmmmmm.   Time for Dr. Google.

I found the answer in teensy sized print in the middle of a answer:

sudo apt-get install libc6-*

This adds/updates a buch of files (took about 15 minutes to download and install) but it didn’t seem to be too large (about 50MB).

Once this was complete, I was able to unpack my JDK files, then from the bin directory,  I ran java -version and received:

java version "1.7.0_25"
 Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
 Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode)

Now I can get back to work

Beaglebone Black : Cloud9 and Bonescript Install Guide

beagleIn my previous post about installing the GateOne terminal emulator, I mentioned that I wanted to replicate the experience and features for the OOTB Beaglebone image of Angstrom only on Ubuntu.  Well, I’m getting a little closer day by day.  This post was originally intended to be the installation of Cloud9 but as I was reviewing my notes, I decided to try getting Bonescript installed as well.  Both installations are contained in this guide.

Since I am fairly new to the BBB, I haven’t spent much time with Cloud9 or Bonescript. I was initially attracted to it because of its power to size ratio and that Ubuntu was an option.  However, I am planning to do some maker projects with the BBB, so I will get to test my handiwork.  Just understand that even though I got them running, I have yet to extensively test them.

Like with WiFi, a lot of people have struggled with getting Cloud9 running and I am no different.  Others mentioned and blogged about their successes but I was unable to replicate their success.  However, I will include the links to a couple blogs where I gathered information and inspiration.  I hope that this method works for you.  Let’s get started.

NOTE:  We will be removing the current version of Node from this instance, so if you have any dependencies on the current installation, you may wish to think twice before you proceed.

Installing the Prerequisites

First, we need to prepare our system for the install.

sudo apt-get install -y build-essential g++ curl libssl-dev apache2-utils git libxml2-dev

Also, we will need to remove node.js if it exists:

sudo apt-get remove nodejs

One of the blogs I used (Sam’s Site) indicated that downloading NVM (Node Version nodejs-logoManager) but I wasn’t able to get this to build correctly.  So I downloaded the latest version of Node and attempted to build it but it didn’t work either.  So, I split the difference between the minimum (v.0.6.16) and the latest (v.0.10.18) and settled with v.0.8.25.  I found it on the nodejs distribution page. I unpacked it, navigated into directory created, and then ran this sequence.  A word of caution: The ‘make’ step takes a while.  I literally burned hours compiling node on the BBB while I was working out which version would work.

sudo make install

After the install completed, rebooted the BBB and then when it came back, I ran the command:

node --version

and the return was:


Now, that node was installed, I cloned the Cloud9 repository (repo) from here:

I'm on Cloud9

I’m on Cloud9

I attempted the install instructions by changing directories to Cloud9 then executing:

npm install

This resulted in a miserable failure.  However, since with the node installation came the npm (node package manager), I thought there might be a Cloud9 package and sure enough, there was. So I changed to my home directory and altered my command to:

sudo npm install Cloud9

This actually worked.  However, I was trying a bunch of stuff and it all kind of got messy and I had 3 files.  I found them by typing in:


The one I was looking for was under ~/node_modules/cloud9. I changed directories to this directory and then executed:


The resulted in the application actually starting, much to my surprise.  However, when I navigate to the site (ex. http://bbb.local:3131), nothing came up.  After going back to the Cloud9 repo page on github, I found the configuration under the Installation and Usage section.  Adding the -l hostname flag will allow you to specify what machine can access the IDE.  You can use a wildcard and allow any machine to access the IDE, like so:

./ -l

Going back to my browser and navigating to the BBB on port 3131, The IDE finally came up.  Allowing any workstation to access the IDE can be risky.  You can add some additional security by specifying a username and password: -l --username test --password test2

When you open the web page, you will be challenged with a basic auth login modal.

Keep in mind, we are working on a Beaglebone Black, not an NSA network.  However, good security should always be considered.  As with the GateOne app, this one is rather new to me but when I start it up, I see the file structure of my Cloud9 folder.  I will need to figure out how to fine-tune this.

Finally, as promised, the installation of Bonescript was bloody easy.  Change your current directory to your Cloud9 folder and enter:

npm install bonescript

…and shortly, bonescript will be installed as well.  I am not going to explore the configuration or usage of bonescript yet because I simply haven’t used it yet but at least it didn’t blow up in my face when I installed it.

Bonus Round

I did some tidying up to release some space that was taken up from the install process. First I copied the the node folder from my home folder to /opt.  Next, I copied the cloud9 folder from ~/node_modules to /opt.  Then I removed the node, node_modules, tmp, and cloud9 folder from him home folder.  This released more than half of my previously free space.  What I learned here is that if you don’t  plan to use these tools, don’t bother to install them.  They use up precious space and are a bit slow.

I have yet to add cloud9 to my startup process but that shouldn’t be too difficult.  I already have a script that is kicked off from a cron job using the @reboot trick I mentioned in the Ubuntu Guide.  I will simply add this to it.

I hope that if you use the Cloud9 on the Angstrom image and are looking to moving to Ubuntu, you don’t hesitate because of this process.  I found it challenging but I learned about NodeJS, NVM, NPM, and the build/install process which I have not had much experience with before.  It’s fun and a great way to get to know your Beaglebone.  Best of all, if it fails miserably, you can always reimage and go back to the OOTB image anytime.

Let me know if you have any questions or if you discover some neat trick that expands this.  I would love to know more and to hear from you.

Related links: (Google search resulting in a log of crying and nashing of teeth)

Beaglebone Black: GateOne Terminal on Ubuntu


Liftoff GateOne on the BeagleBone Black with Ubuntu

If you have been following my series about installing Ubuntu on Beaglebone Black, you might have wondered about some of the stock tools like Cloud9 IDE (an installation guide coming soon) and GateOne that aren’t on the Ubuntu image.  This post will help you to get GateOne installed.

Just a word of caution:  This guide discusses the technical steps in getting the GateOne Terminal Emulator on your BBB.  It does not go into details as to how to configure it, specifically security.  If you attempt to do this, please be aware of the potential security risks involved.

After my last few posts, I was planning to start on the IO Python Library but I began to think of the other tools that make BBB easy to use out of the box.  The two things that I recall from my first impression experience was the Cloud9 IDE and GateOne Terminal Emulator.  I wanted to at least have the option of these tools.  GateOne has a ton of options that allows you to configure it for just about any need.  Since it’s an OOTB offering with the default Angstrom distro, I figured I would be able to get it running on my Ubuntu install as well.  It’s really easy to do:

You may find it helpful to review the Installation instructions prior to getting started.  When all else fails, RTFM.  Here’s the link:

We need to do some prep to get ready for the installation.  You will need the following:

  • GIT
  • PIP
  • Python Tornado
  • Source Code for GateOne

Note: Since the BBB is not the never-ending well of space, you should be ever-mindful of how much stuff costs (size) before installing it.  I will discuss some commands to help clean-up previous installs using apt-get later.

Time to get the Beagle Ready

We don’t need to configure git after installation to retrieve the source but if you use git, you should.  Here’s a link for Configuring GIT but it’s optional for this guide. In your BBB terminal, type:

sudo apt-get install git

After this installs, you will be able to download source code from GIT repositories.

Next, we need to install PIP.  PIP is a Python package management app, similar to ‘apt-get.’  We will need this to install Tornado.  Tornado is essentially a Python web server.  To get this installed, we need to install PIP:

sudo apt-get install python-pip

Yay! Now that we’re done with that, let’s get Tornado installed:

sudo pip install tornado

Download and Install GateOne

Now that we have our house in order, we can get busy.  There’s a bunch of ways to get the source, but I found that this is the easiest:  We can clone the code right to your home directory because the install process will put the final product in the /opt directory.

First change to your home directory then clone the code with this command:

git clone

This will put a folder called ‘gateone’ in your home directory.  Now let’s get inside this folder and install this puppy:

sudo python install

Now we will wait for a bit.  There’s a lot happening.  It seemed to take about 5 minutes but I was dodging baby bottles and Wii remotes at the time.

When this is done, you should be ready to give it a try.  Change your directory to /opt/gateone then execute this command:

sudo ./

A bunch of feedback it going to dump to the terminal.  If you don;t see red, you should be good.  Give a close look for any error messages.  If all looks good, then it’s time to try it for a spin.  Quick note:  You won’t be able to use it yet but we want to see if it works.  Open up your favorite web browser on a computer on the same network and enter the address:

https://<your BBB IP or BBB hostname>

You should see the familiar charcoal screen.  It’s going to start yelling at you about not having permissions and what not.  We’re about to fix that.  Go back to the terminal and stop the service (ctrl+c).  The problem is that the app has not been given permission to allow your workstation access.  To do this we will add a parameter “–origins=*”  Also, you can add an extra layer of security by specifying a layer of authorization, you can use kerberos, google, or none.  I gave Google a try and it sorta worked but we’ll skip that for now.  First, here’s the command:

sudo ./ --origins=* --auth=none

Head back to your browser and go to the same address.  You might get an error but just refresh the page and you should see the login prompt.  I tooled around and it seems to work exactly the same as a regular ssh session.  Let’s take look at the Google authorization.   You are going to need a Google account for this.

Stop the app and change the auth parameter like this:

sudo ./ --origins=* --auth=google

When you go to the page this time, you will instantly be redirected to Google to log in and/or authorize the app.  Do so and you should be redirected back to your GateOne interface.  In my case, it didn’t happen.  I just refreshed and since I authorized, it presented me with the GateOne Login interface.

So, my initial impression was it was really easy to install and give me yet another tool to leverage with the BBB.  This was a quick and dirty install and I look forward to exploring the many options with tool.  I’ll be sure to post my findings here when I find something cool or useful.

I mentioned that I would talk about drive space management using apt-get.  Well, I’m running out of steam but I will say quickly that you can safely delete the source files from the git branch we downloaded to the home folder.  I’ll put up something on apt-get shortly but in the meantime, you can do some reading here:

This guide applys to all versions of supported Ubuntu and this link starts you at maintenance.  Keep scrolling down to the removal section.  If you’re nutty or curious, read the whole bloody thing.  🙂

UPDATE:  I found a simple way to start up the script on boot.  First, you will need to modify the /opt/gateone/settings/10server.conf file to add/modify the two parameters that we added when running the script manually.  Here’s what they look like:

"origins": "*",

Save that and test it with:

sudo ./

If everything is good, then run this command I found in the INSTALL.txt, found in the source files folder (remember me saying RTFM?  It applies to me too):

update-rc.d gateone defaults

Here are a couple links for the install files and instructions:

Beaglebone Black – Set Up Wireless on Ubuntu

Not Hard but Not Easy

wifiThis guide is the culmination of several dozens of hours or trial and error, cursing, and perhaps a little alcohol.  In my Ubuntu on Beaglebone Black setup guide, WiFi was conspicuously missing.  I did this because I felt WiFi needed its own treatment and the subject can differ radically based on the user’s WiFi card, experience with Linux, and comfort level with BBB.

Historically, I have been pampered by Ubuntu’s nature of “Just works.”  Having run my workstation for just over a year, there have been several little glitches but nothing that vexed me so much that I was ready to go “Office Space” on any machine.  However, getting WiFi running on my Beaglebone Black took me to the brink.  I know that I am not alone and I wanted to save anyone reading this from the same huge, frustrating exercise that so many before me have had.

Before we get started, let me set the stage and define the scope.

When I purchased my BBB from, I picked up the WiFi dongle at a price that was very reasonable.  With the community of BBB users, I thought if I can’t get it running surely someone else has.  Well, this is true but the path to success is long and meandering.  I had such a difficult time with it, I walked away from Angstrom and sought safe haven elsewhere, hence Ubuntu.  Now being on the other side of the WiFi issue, I cannot say that Angstrom was the problem (I still am not convinced it’s the answer).  I have read through countless numbers of posts on the subject and have seen every kind of solution, each of which, have failed.

A side note: I must apologize that I do not have the address for the blog that helped me get this working.  When I was setting this up, I was just trying the next in a long line of failed attempts to get the dongle working and I seriously did not expect it to work.  I have yet to find the blog but when I do, I will put the link here.

Finally, I was trying to configure the WiFi with Ubuntu and I stumbled upon a blog where someone pointed readers to some files.  I downloaded them and I was surprised that I was actually starting to make some progress but the instructions went on to give instructions that ended up not working.  However, I found another site that had a different network configuration that ended up working.  The following instructions provide the steps I followed to get Wifi working for my BBB:

auto wlan0
iface wlan0 inet dhcp   
   wpa-ssid "URANUS"   
   wpa-psk "PASSWORD"

Finally, I started the WiFi interface by entering this command: sudo ifconfig wlan0 up.  When I ran ifconf, my wlan0 had an IP address.  I was able to ping it and ssh to the BBB through this.

But I was skeptical.  So I bounced the BBB and when it came back, I attempted to SSH to the BBB though the wireless and… SUCCESS!

So far, this seems to work.  I’m not crazy about putting any password into a config that’s not encrypted or somehow obfuscated but I have locked my BBB down pretty tight and it’s not exposed externally, so in this case, I’m ok with the risk but understand that it is a risk.  I was just not able to get any other configuration methods with iwconfig or wpa_supplicant to work.

Also, I am not really worried about my BBB getting an IP from DHCP while at home.  I prefer to create an IP reservation in my router’s DHCP table.  This allows me to change other network-related configurations on my router and I know that my clients will get the updates.  With static assignments, you will have to manually change these configurations on your client.

Maybe it’s not pretty but it gets the job done.  I will continue to work on this when I can get more sd-cards because I’m not crazy about roaching my current installation for the sake of experimentation.  When I have other results to report, I will post them here.

Good Luck!

Links related to this post:

BeagleBone Black – Installing Ubuntu – Part 2

OM Nom Nom

OM Nom Nom


Let’s Keep Going…

Back in Part 1, we got a lot done:

  • Installed Ubuntu 13 -Raring to a sd-card
  • Configured network stuff
  • Added IP Mailer script
  • Learned I don’t feed trolls

but there still so much more to do.  Let’s keep going…

System Updates

We really need to update the OS at this point.  Thankfully, this is wicked easy:

sudo apt-get update

When that’s done…

sudo apt-get upgrade

This second one will take about 3-5 minutes.  Once done, we are ready to rock! \m/

User Administration

Right now, we are still working under the default ubuntu user account.  This might be handy to have as a OSIS (oh s**t I’m screwed) account but we have to lock it down so we don’t invite trouble.  We also need to create our own user account and get our groups sorted out so we have access to sudo and continue our quest for BBB-Ubuntu nirvana.

First, lets get a new account going.  I created a user account by typing in the following:

ubuntu@ubuntu-armhf:~$ sudo adduser dfrey
[sudo] password for ubuntu: ****************
 Adding user `dfrey' ...
 Adding new group `dfrey' (1001) ...
 Adding new user `dfrey' (1001) with group `dfrey' ...
 Creating home directory `/home/dfrey' ...
 Copying files from `/etc/skel' ...
 Enter new UNIX password: ********************
 Retype new UNIX password: ********************
 passwd: password updated successfully
 Changing the user information for dfrey
 Enter the new value, or press ENTER for the default
 Full Name []: David Frey
 Room Number []:
 Work Phone []:
 Home Phone []:
 Other []:
 Is the information correct? [Y/n] y

(I added the asterisks for effect.  You will not see them when you create the user.)

Ok, so now we have a user with a default group of the same name.  We still need to grant access to the sudo group:

sudo usermod -a -G sudo dfrey

Here’s what’s going on with this command:

  • -a allows the group to be appended instead of being replaced
  • -G adds the specified group as supplemental group (-g) would be primary)
  • the second ‘sudo’ is the group designator
  • dfrey‘ is the user to which all this will be applied

You can test out your handy work by typing:

ubuntu@ubuntu-armhf:~$ su dfrey

Note:  This password prompt is for the ‘dfrey‘ password, not the existing user.  With this, we are actually logging in as ‘dfrey.’  Next, try:

dfrey@ubuntu-armhf:/home/ubuntu$ sudo date
[sudo] password for dfrey: 
Wed Sep 11 01:16:49 UTC 2013
dfrey@ubuntu-armhf:/home/ubuntu$ exit

Now that we have tested our user account, let’s reboot the BBB to make sure everything is working.  We are going to test a few things here:

  • We haven’t broken the BBB
  • The IP Mailer script works
  • We can log into the system with our new user

Cross your fingers, say a little prayer, and type in:

sudo shutdown -r now

When you get kicked out of your SSH session, start pinging the BBB with the address you’ve been using or use the Hosts file entry we talked about in Part 1.

If you start seeing this:

Host Unreachable

That’s a pretty good sign that the IP assignment has been changed for your BBB.  If your IP Mailer script is working, you should have an email waiting for you with your new IP.  Actually, it should be there with your current one whether or not it’s new.

If you have a valid IP address, then SSH back into the system. If you are having trouble, didn’t get the email and SSH doesn’t work with your current IP, go back to Part 1 and look for “The Hard Way.”  This process will help you get your IP.

However, we’re moving on, so catch up with us when you get done goofin’ around.

Secure The Default User

This distro of Ubuntu (as you are already aware) comes with a default user account, ubuntu.  The password is cleverly disguised as “ubuntu”  All the forces of the universe call on us to either disable this account or at the least, change the password.  We’ll go through both processes and you can choose which one is right for you.

Disable The “ubuntu” Account

To protect your new BBB, you need to shut this account down.  Since its preconfigured to the distro, you may be able to leverage it later so were just going to shut it down rather than outright delete it (which might still be a good idea for public accessable installations).

In the terminal simply type:

sudo passwd -l ubuntu

Now the account is still on the BBB but locked.  To unlock it is just as simple:

sudo passwd -u ubuntu

Voila!  Security! Just keep in mind that this may not be a fool-proof method.  If someone has accessed your BBB with a SSH key, this might not stop them.  Just keep an eye on who’s logging onto your system with the ‘last‘ command.

Now, don’t go and get all nutty and do this until you have a fairly secure system.  The “ubuntu” account may still come in handy.  Let’s make is a bit more secure though.

Change The Default Account Password

Assuming we logged in with the new user that we created above (in my case “dfrey“), let’s change the password for “ubuntu.”  In the terminal, follow along:

First, let’s log in as “ubuntu“:

dfrey@ubuntu-armhf:~$ su ubuntu
Password: <should still be 'ubuntu'>

Then we will issue the password change command:

ubuntu@ubuntu-armhf:~$ passwd
Changing password for ubuntu.
(current) UNIX password: <still 'ubuntu'>
Enter new UNIX password: <super difficult-to-remember, impossible-to-guess password>
Retype new UNIX password: <see above>
passwd: password updated successfully

Finally, let’s test that (the password verification was a test but we go above and beyond):

dfrey@ubuntu-armhf:~$ su ubuntu
Password: <super difficult-to-remember, impossible-to-guess password>

UPDATE: After posting this, I got to thinking that if changing the password or disabling the account is a good measure, one could change the password then lock the account and that gives you extra protection.  Just take this message home with you.  There are a lot of very cleaver people out there looking for an opportunity to mess with your chi.  Be proactive about your system security.

That’s all there is to that.

Save The Date

Because the BBB doesn’t have a real-time clock, Ubuntu needs to be configured to fetch the time on a regular basis.  You may not care but time can be an issue with regards to certificates and security tokens, so lets run though this exercise to get things up to snuff.

First, let’s see where we are.  Type in the following:

dfrey@ubuntu-armhf:~$ date
Wed Sep 11 01:20:23 UTC 2013

Since it is 9:20 PM where I’m at, we’re a bit off.  Navigate to /etc remove or backup your localtime file:

sudo rm localtime


dfrey@ubuntu-armhf:/etc$ sudo mv localtime localtime-orig

Now lets update the time file.  You should be able to navigate to /usr/share/zoneinfo and see a bunch of countries or zones.  Find the one you are in and if it’s a country drill down into that.  For instance the America folder has a file, New_York, which is in my time zone.  Yours will probably be different.

You will need to create a symbolic link in /etc to your timezone file.  This is how I did mine:

sudo ln -s /usr/share/zoneinfo/America/New_York /etc/localtime

Now we can see if your locale-base date will work.  We can update the date from a date server by entering the following:

dfrey@ubuntu-armhf:~$ ntpdate -b -s -u
dfrey@ubuntu-armhf:~$ date
Wed Sep 10 21:23:12 EDT 2013

So, we are mostly done here but we still need to check in with the time server to keep everything in lock-step.  If you are just browsing around, getting familiar with your BBB, you can do this maybe 2 – 4 times a day.  If you have date/timing apps, you will need to increase this due to clock drift.  Over at, dwatts has a section called “Setting the timezone.”   I used his awesome tutorial to initially setup up my BBB and I’m happy to report that the Timezone section works for Ubuntu.

So, let’s get to time-synching eh?

Back in Part 1, we added a script to cron so that it would run every time the system rebooted.  Well, we’ll be doing the same thing here but we need to set an interval.  I will give you two examples and you can choose which one you want.

For an update twice a day, add this line to your crontab file:

00 */12 * * * ntpdate -b -s -u

For updates every thirty minutes, add this line:

*/30 * * * * ntpdate -b -s -u

Either of these should work.


Ok, so you guys have been pretty good (except for those two goofs in the back) so I’ll throw you my alias list.  It’s not much but it keeps me cozy at night.

First, here’s the list:

alias c='clear'
alias reboot='sudo shutdown -r now'
alias la='ls -als'
alias lt='ls -alt'
alias mkdir='mkdir -pv'
alias path='echo -e ${PATH//:/\\n}'
alias sudo='sudo env PATH=$PATH'
alias now='date +%T'
alias nowtime=now
alias nowdate='date +"%d-%m-%Y"'
alias ports='netstat -tulanp'
alias apt-get="sudo apt-get"
alias updatey="sudo apt-get --yes"
alias update='sudo apt-get update && sudo apt-get upgrade'

Now, let’s get these squared away.  By default, Ubuntu is going to set your profile to Bash (Borne-Again SHell).  It’s my favorite and it’s what I’ll be using for the example.

The cool thing is that Ubuntu was ready for you.  In your home directory, is a hidden file called .bashrc.  It contains a couple of the most popular aliases but there is an option for you to add more.  Simply create a new file in your home directory called: “.bash_aliases” and paste whatever you want in there and save the file.  Everytime you log in, your aliases will be loaded and available to you.

The final step is to log out (exit) from your SSH session and then log back in.  All your aliases will be ready to serve you.  .bashrc is parsed every time log on so doing this will update your personal profile configs.

In my next post, I will be installing and configuring several applications that I use including:

Oh and I haven’t forgotten the BeagleBone Black Ubuntu Wireless Configurations Throwdown.  That’s coming soon as well.

Please check back soon for that.

BeagleBone Black – Installing Ubuntu – Part 1

bbbLet’s Get It Started…

This is Part 1 of the setup walk-through.  It is continued with Part 2 (Wireless and Adafruit IO Python library coming soon),

Ubuntu on a BeagleBone Black (BBB) is a glorious thing.  Since I use Ubuntu as my primary workstation, I am very comfortable with this OS.  Having it on my BBB is like an old friend in a new box.

This series of posts will serve as documentation as to how I was able to install and configure my BBB with Ubuntu 13 – Raring.  I hope that others may find it useful as well.  A couple of notes before we get started.  I used several blogs and sites to build this document and all the links can be found below.  Some are modifications for setting up Angstrom on BBB, others for configuring Ubuntu in general.  It’s really an aggregation of information for me to have a single source for setting up my BBB.

DISCLOSURE:  As the subtitle of this blog says, “I HAVE NO IDEA WHAT I’M DOING.”  Use this information for what you will but don’t take my word for it.  Be careful and don’t brick your BBB (can such a thing be done?).  I do not get paid for writing this.  I am not endorsing any site, blog or manufacturer (though I do shop from many of them).  I openly state that this work is a derivative of the hard work of others and that I am merely standing on the shoulders of giants.  Be cool, give me your hand and you can stand on mine.

Here’s the list of things I had at my disposal when doing this:

  • BeagleBone Black
  • USB wireless dongle from
  • Ethernet connection and cable
  • 5v, 1A wall wart power supply
  • Wireless network
  • 8GB SD-Card

You might not need all this stuff but I assume that you do.

First Things First – Get Ubuntu Image on an SD Card

I’m not going to go into the ugly details of how this is done.  However, here is what I did:

  • Downloaded the image file
  • Booted into Windows and used Win32DiskImager to build out the image onto my SDCard – I was never able to get ‘dd’ on Linux to work on Ubuntu.  It wouldn’t recognize my card.  Most likely, it’s a driver issue.
  • Wait 10 minutes
  • Image is baked onto card.

I have opted not to burn the image to the BBB because of the Network Tango that might take place.  I will use the Angstrom image as a “Get out of network hell FREE” card.  Later on, when I have things tightened down, I might burn the image to BBB.

The details on how to do everything up to this point can be found on the site.  Have a look around while you’re there because there is so much electronical coolness to be seen there.

The Networking Tango

Since I do not have a monitor/keyboard/mouse connected to my BBB, this part get’s a little tricky.  While on a home network, it’s pretty straightforward b/c you should be able to find the IP address that DHCP has assigned to your BBB.  If you are on a network where you don’t have access to the DHCP tables, then there is a magical trick that works most of the time (60% of the time, it works every time).

Easy way:

Connect an Ethernet cable to the BBB, put the sd-card in the BBB and reboot.  The wait isn’t terrible.  Next, head over to the admin web site of your router and find the IP address allocated to the BBB.  If the address doesn’t show up, just wait a minute for the boot process to finish.  While you’re waiting, check the connector on the BBB and verify that you see green blinky lights (it’s an industry term).  If you don’t, you need to troubleshoot your cable/connection. If you have the ability to do so, create a reservation for your IP in DHCP or create a static entry.

Next, take that IP address and create an entry in your host file.  I am only discussing how to do this on a Ubuntu workstations but if you don’t know how for your OS flavor, then google, “create host entry for <insert OS name here>”

For me, I go to the terminal on my workstation and put in, “sudo vi /etc/hosts” and the editor will load up my host file.  I use the following:       bbb.local #stock USB ip… not always but nice to have
192.168.X.X       beaglebone.local #IP assigned by my router.

So, this allows me to not have to memorize my IP address (though I often do anyway) and it’s easier for me to type.  Finally, it’s consistent with my systems.  If your not familiar, the host file is like a poor man’s DNS server.  It maps IP address to human-friendly names.  You can put most anything in here but a word of caution.  The Network service checks here first before looking outside of the system.  So if you map to your local system (, the networking service will always redirect requests for this domain to your local system and you will never get again (well, at least until you take the entry out of the hosts file).

But I digress…

Now that the IP is mapped to a friendlier name, I can SSH (Secure SHell) into my fresh version of BBB-Ubuntu. Here we  go…

ssh ubuntu@beaglebone.local  
ubuntu@beaglebone.local's password: ******
Welcome to Ubuntu 13.04 (GNU/Linux 3.8.13-bone20 armv7l)

 * Documentation:

(the default password is ‘ubuntu’… don’t worry, we’ll fix this shortly).

and it worked.

The Hard Way

Let’s say you are visiting someone and have permission to use there hard-wired ethernet network connection but you have no access to find out what the IP might be when you boot your BBB.  You can fall back to the standard install of Angstrom to help you here.  Plug in the USB and ethernet cable to the BBB then, with the sd-card our of the BBB, power it up.  After a minute or so, the BBB will be started and you can navigate either the internal web server or SSH.  I use SSH

ssh root@bbb.local (or

This is the USB interface and when you login to BBB, you can type in:

ifconfig eth0

This will return you a bunch of stuff.  In that stuff, you should see

inet addr: <ethernet address>

This is the DHCP address currently assigned to your BBB (in most cases).  Copy or write it down.  Then power off the BBB, unplug the USB, put the sd-card back in and plug in the power to boot.

You should be able to proceed as I discussed in “The Easy Way.”  You may also have to do this a couple times if the IP shifts on you.  It’s not a perfect process but it worked for me.

The next thing we need to do is to get our IP address emailed to us in case the assigned one ever gets changed.  Let’s do that now before anything else:

IP Mailer

So, I pried this python script up from the interwebs.  You don’t have to do too much to actually get it to work but this script assumes that you have a gmail account.

Using your favorite terminal editor, create a file called, ‘’

import subprocess
import smtplib
import socket
from email.mime.text import MIMEText
import datetime

# Change to your own account information
to = ''
gmail_user = ''
gmail_password = 'yourpassword'

smtpserver = smtplib.SMTP('', 587)
smtpserver.login(gmail_user, gmail_password)

today =

# Very Linux Specific
arg='ip route list'
data = p.communicate()
split_data = data[0].split()
ipaddr = split_data[split_data.index('src')+1]
my_ip = 'Your ip is %s' %  ipaddr

msg = MIMEText(my_ip)
msg['Subject'] = 'IP from BBB on %s' % today.strftime('%b %d %Y')
msg['From'] = gmail_user
msg['To'] = to

smtpserver.sendmail(gmail_user, [to], msg.as_string())


You will only have to change the ‘to’, ‘gmail_user’, and ‘gmail_password’ account.  You can create a gmail account specifically for this purpose so that if your bbb is stolen or compromised, you don’t have the plain-text password to your personal stuff in your scripts.  This is what I did.

Next, let’s make the script executable by running:

chmod +x

That’s it.  All that’s left with this is to test it:


if you just get a prompt after running the script, that means it probably ran without an issue.  Let’s go check:

Yup.  There it is:

Your ip is

So now your saying to yourself, “Well, this is just great Dave, but how do I get it to trigger the email?  Magic?”

Well, almost… Ubuntu has a really cool feature I haven’t seen in other distros with regards to ‘crontab’ and thats the ‘@reboot’ feature.  Where is might seem that this would only fire at reboot, it fires anytime the system is started (cold or warm boot).  To be sure that I had this in place right up front, I put it under the ‘ubuntu’ user.  I will move this later but for now, this will work in case the system reboots or we goof something up.

sudo crontab -user ubuntu -e

You should be prompted to select your favorite editor.  For the initiated, VI is an option.  For ease of use, Nano is also available.  Next put add this line and save:

@reboot /home/ubuntu/

I make the assumption that the script was created in the home directory of the ubuntu user.

If your test was successful, then the next time we reboot (coming soon), you should receive an email with your IP Address.


Ok, so this post is getting pretty long so I am going to wrap it up here.  I’ll put up part 2 shortly with:

  • Setting the Date (since BBB doesn’t have a a real-time clock)
  • Creating a user, group and giving that user SUDO access
  • Updating/Upgrading the OS
  • My favorite alias list.
  • …and lots more

If you have any questions, comments, or suggestions, please feel free to leave a comment.  Please be advised that I warmly welcome input but trolls will be ejected from the conversation.

Some Links to sites that I referred to for this blog entry: