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 : WordPress On Ubuntu


Installing LAMP and WordPress on Ubuntu Running on A BeagleBone Black

Since I have been using WordPress with a couple blogs for almost 8 years now, I am fairly comfortable with the platform.  With my weekly BeagleBone Black challenges of late, I felt that installing WordPress would be a great idea to try.  I can tell you that the BeagleBone Black, once again, didn’t disappoint.

Before we begin, I want to just say that running WordPress on the BBB is an academic endeavor.  I wouldn’t think about hosting a public blog due to performance with this configuration but it is perfect for my needs as a teaching tool.  My oldest son just turned seven and is incredibly inquisitive about science.  He catches bugs, lizards, etc. and takes pictures of them.  He loves astronomy and never stops asking when the sun will go supernova.  I thought it would be a great for him to document his findings in a blog to teach him more about the scientific method, documenting his findings and getting more comfortable with the computer.  As an added bonus, I want to see where this takes him.

Getting Started

penguin-ubuntuAs I mentioned my previous blog, I created a “snapshot” of sorts by starting off with a fresh version of Ubuntu then adding my base setup changes then finally creating the tarball of the entire OS.  This way, I can simply reflash the card, restore my base install and begin on the next project.  That’s what I am doing with this.  This is basically my setup:

BeagleBone Black – Installing Ubuntu – Part 1

BeagleBone Black – Installing Ubuntu – Part 2

Beaglebone Black : Back Up Ubuntu

I didn’t include the wireless, cloud9, or OpenGate for this because I wasn’t sure where I was going to put WordPress and was concerned with space.  Turns out, that space wasn’t an issue (other than bleeding off CPU cycles).

Once I had my base install configured, I needed to install and configure three additional components before WordPress:

  • mySQL Database
  • Apache Web Server
  • PHP Scripting Language

This comprises what is called a LAMP server (Linux Apache Mysql Php)

Installing LAMP on BeagleBone Black Ubuntu

At first, I thought this was going to be easy.  I found a package in the package manager for installing LAMP and tried it out.  I’m not saying it doesn’t work, but I will say that I had to reflash a couple times and it never really worked well for me.  Also, I really wanted to have a little more control over what I was installing, so I ended up installing and configuring each component separately.  We’re going to do that here.  I based my steps off a couple walk-through guides found on Ubuntu Server Guide and (links to these and other resources will be found at the end of this walk-through).

MySQL Installation and Configuration

Real quick, before we start installing packages, let’s make sure we’re up to date with everything:

sudo apt-get update
sudo apt-get upgrade

Since we already have the Linux part of LAMP, let’s move to mySQL. You can install this with a simple command of:

sudo apt-get install mysql-server

You will be prompted to provide a password for the root account.  It is always strongly advised to do so and remember this password.  If you forget, you won’t be able to move forward.

Once the install is complete, we need to test the install and then create a database for our installation.  Before we continue, think about the name or type of WordPress site you want to create.  Since mine is to help teach my son about science, I will call mine, ‘science’.  You want to keep it small and if you have more than two words, separate with underscores or dashes (‘_’ or ‘-‘).

To test your installation, type:

mysql -u root -p

You will be prompted to for the password you provided during the installation.  Once you have successfully done this, type:

show databases;

This command will list out a table of databases that are currently available.

mysql> show databases;
| Database           |
| information_schema |
| mysql              |
| performance_schema |
| test               |
4 rows in set (0.01 sec)

If you have made it this far, you are ready to continue.

Now we need to create a user, a table, and provide permissions.  I used ‘scienceadmin‘ for the username and ‘science‘ for the database.  Simply replace these with your credentials.  Oh, and with these commands, don’t forget the semicolon. If you do, it’s not a big deal, just type `;` on the next line and the command will execute.

Create the Database:

create database science;

Create the user:

create user scienceadmin@localhost;

Set a password for this user:

set password for scienceadmin@localhost=password("squirrelhunter01");

Create the permissions for this user to use the database:

grant all privileges on science.* to scienceadmin@localhost identified by 'squirrelhunter01';

Finally, let’s refresh MySQL:

flush privileges;

To get out of mySQL:


Installing Apache Web Server

beagleThis will be pretty straight forward.  To install the web server, you enter in:

sudo apt-get install apache2

After the install you can start it up with this command:

sudo service apache2 start

and test it in your browser: “http<beaglebone IP or personalized hostname>/”

You should see the “It Works!” page.

We’re done with Apache for now.

Installing PHP

To install or update PHP, run the following command:

sudo apt-get install php5 libapache2-mod-php5 php5-mysql

Once this is complete, let’s test it.  Navigate to /var/www and create a file named, ‘test.php‘ then add the following text:


Next, fire up a web browser and navigate to `http://<bbb_IP>/test.php`.

You should see a page filled with server/site/php goodness.

And we are done with the LAMP installation.  Easy right?

WordPress Install and Configuration

Now we get to the meat of this walk-through.  Let’s first decide where we’re going to put our WordPress site.  When you download WordPress and unpack it, you can put it in your root or in a sub-folder.  You an even have several instances running at the same time in several folders.  When I was working through this, I went a road less traveled by putting the site on a thumb drive and created a symlink from the web server root.  This creates quite a mess (I will write up a way to do this shortly) but for the purpose of getting a wordpress site up and running, we’ll start with the easy way.

The Easy Way

At this point, I am showing 1.1 GB of free drive space.  This should be more than apache_featherplenty to run WordPress right off the BBB.  First let’s download the WordPress files.  I can simply download the latest version to my home directory like this:

dfrey@ubuntu-armhf:~$ cd
dfrey@ubuntu-armhf:~$ wget -O wordpress.tar.gz
dfrey@ubuntu-armhf:~$ tar -xvpzf wordpress.tar.gz


Now, we should have the WordPress site files that I can copy to any directory.  Let’s try it out in the root of our web site.

sudo cp -r wordpress/* /var/www/

This just copied all the files to the root of my web server.  Let’s go check it out in the browser: `http://<bbb_ip>/`

huh?  We still get the same message as before.  Well, this is because we need to configure a couple things.  Since this is a manual installation of WordPress, we have a little more work to do but it’s easy.

In your browser, navigate to, `http://<bbb_ip>/wp-admin/`

You should see a message indicating the wp-config.ini is missing.  Click the `Create a Configuration File` button and you will navigate to the setup configuration introduction page.  You are going to need to have the following ready (we did most of this already so it’s no big deal).  I’ll add my info from above as an example:

  1. Database name – ‘science
  2. Database username ‘scienceadmin
  3. Database password ‘squirrelhunter01
  4. Database host ‘localhost
  5. Table prefix (if you want to run more than one WordPress in a single database) – You can create whatever prefix you like.  If I were going to put more than one WP site in the same database on this BBB, I would choose, ‘sci_‘, but for now we’ll go with ‘wp_

And click ‘Submit

When I ran this, The wp-config.php file couldn’t be written.  Not that this is a huge problem now but it will be shortly so let’s address this issue now.

We installed Apache as root, so the folders that where created by the installer are owned by root.  Apache runs under a user named www-data.  We need to change the ownership of the www folder so that apache can do it’s magic.  Navigate to /var then run this command:

sudo chown -R www-data:www-data www

This will change the ownership and group membership of the www folder and everything underneath it.  Now we can continue.  Hit your back button in the browser so you can see the configuration form again.  Click submit again and you should now get the “All right Sparky…” message indicating the config file was created successfully.

Now, let’s head on to setting up the actual WordPress site.   Click the “Run the Install” button.  Here, you will enter the title of the site that displays on the header,  the user name of the site administrator and the password for this user.  Don’t worry.  You didn’t miss anything, we’ll create this account inside of WordPress now.  These are for the site not the database.  They can be completely different or exactly the same.  It’s up to you.

Site Title:     Science
Username:  scienceguy
Password:   tesla@24
Email: (just made that up)
Privacy:       (turned this off)

Now click on the ‘Install WordPress` button.  The scripts will run for a while then take you to the `Success Page`.  Click Login then enter your username and password.  If everything was done correctly, you now have a spanky brand new WordPress site.

After installing, I still have just under 1GB of space left.  If you intend to install other things on your BBB, you might want to install other things off the board, on a thumb drive.  That walk-though will be coming in a couple days.

Oh, I forgot one thing.   You need to remove two files from your /var/www folder:

  1. index.html – this will override the WordPress pages (its why we didn’t get an error when we tried it before configuring WordPress)
  2. test.php – this has some server-specific information that a hacker could use against your BBB.

Now got to `http://<bbb_ip>/&gt;` in your browser and you will see the public version of your site.  Go WordPress Crazy and have fun.

Feel free to leave comments if you have any questions or if you found this walk-though useful.

I got so excited to post this, I forgot my link references.  Here you go:

Beaglebone Black : Back Up Ubuntu

backupOver the past few posts, I’ve been discussing how to convert a modest BeagleBone Black into a versatile, powerful little linux device.  Well, it was always a little powerhouse but, for me, Ubuntu just made it more accessible.  For the more seasoned linux users, this is nothing new but for us “Newbies”, sometimes, even the simplest tasks seems cryptic when facing a command-line.  Now, once we get to the GUI, things will get easier but I find that learning how things work in “the dark place” removes my dependance on the GUI and gives me the flexibility that most UIs just can’t provide.

This walkthrough is about backing up all your hard work thus far and restoring it later.

I don’t have a ton of disposable income so, I can’t rush out and buy up a bunch of sd cards.  I wanted to figure out a way to preserve what I have put together so far so that I can reimage the card and do other stuff (so much cool stuff to do).  After consulting with Dr. Google, I found a couple useful articles on backups and used examples from this one (Ubuntu Community Help) that fit the bill.  But I am getting ahead of myself. Backing up my system is one thing but the real question is where am I going to put it. Since I have a USB port, I thought that an external drive might work so I set out to make that happen.  On my workstation, I mounted a 2 TB USB hard drive (can you say overkill?) and formatted it with ext4 file system. Then I plugged it into the BBB.  I need to mount it but I don’t know what the device name is so I ran these commands:

First, I need to login as the root user (be careful when you do this):

sudo su -

Next, I need to identify my device:

fdisk -l

This will give you an output with a bunch of drive specs.  Here’s a copy of the one I’m looking for (/dev/sda1).

Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001b190
Device Boot Start End Blocks Id System
/dev/sda1 63 3907029167 1953514552+ 83 Linux

Now that I have what I need to mount the USB hard drive, I entered this command:

sudo mount -t ext4 /dev/sdb1 /media

Now, you should be set.  First, log out as root with the exit command.  Then navigate to the new drive by typing:

cd /media

I found a folder called “lost & found“. I then created a folder structure of /media/dfrey/backup to house my various backups and then changed to that directory.  Next, I made sure I could read and write to it by creating a file then reading from it:

echo "testme" >> testme.text && cat testme.text

This command takes the text, “testme” and saves it to a file then finally reads that file back to the terminal.  Success!

Create The Backup

Now that we have a place to put the backup, we can create the backup.  Since we are in the backup folder, we can keep this simple and run the command right here:

tar -cvpzf bbb-ubuntu.tar.gz --one-file-system /

tar is the backup utility.  It’s and acronym for Tape ARchive — It’s like zip but WAY faster.  It creates and explodes files we call ‘tarballs.’

-c is create new tarball
-v is verbose – this is going to dump a list of all the files to your terminal
-p is preserve the permissions of the files
-z is compress with gzip to make it smaller
-f is filename — you can include the path if you want to put the tarball somewhere else.

–one-file-system will not include other file systems.  The link above has a more detailed description.

After we kick this off, it spews a list of all the files it backs up.  At the end, it will save the file.

In order to test this, I then shut everything down, said a little prayer, flashed my sd card with the stock Ubuntu image and rebooted.  As a precaution, I stamped my file on the image once I was back in (see BeagleBone Black – Installing Ubuntu Part 1) and added the @reboot cron job.  Next, I logged in as root (sudo su –) and mounted the drive with the following command:

mount -t ext4 -o rw /dev/sda1 /media

A quick directory list of of /media/dfrey/backup told me that I was in business.

Now for the fun part.

Restoring The Backup

Let’s get back to the backup folder and run our restore command from there to keep it easy.  Be Warned!!! This is destructive so be careful and understand what you are doing before doing it.  (warning applied 🙂

cd /media/dfrey/backup

Now we can run this command (still as root):

tar -xvpzf bbb-ubuntu.tar.gz -C / --numeric-owner

This command tells the tar utility to unpack the entire contents of the tarball (including subdirectories).  The -C defines where to start unpacking.  Since we specified the root of the file system, this will overwrite everything on the sd card with what was in the tarball.  Anything that was created on the sd card but is not in tarball will remain intact.

This will take some time so we will fast-forward.  When the restore is done reboot your system with this command and you should be back to where you left off when you created the backup:

sudo shutdown -r now

Did it work?  Let’s see… instead of logging into the BBB with the stock ubuntu account, I’m going to use my ‘dfrey’ account that I created when I setup Ubuntu a few posts back.  If this works, then the backup most likely worked.

dfrey@ubuntu-std:~$ ssh beaglebone.local
beaglebone.local's password:
Welcome to Ubuntu 13.04 (GNU/Linux 3.8.13-bone20 armv7l)
* Documentation:
Last login: Thu Sep 19 14:06:03 2013 from

Woot!  Success!

Now, I can build different images for different tasks and flash them to my sd card to try out different apps, OS flavors, or get more BBBs and build SkyNet in my office.

I hope this was a useful walkthrough for you.  If you have any trouble, please let me know.  I ran through this a couple times and it seems to work fine but please be aware, your milage may vary.

Linux : Glances – An Eyeball On Your System

glances-white-256I found this at and it is a tool I wished I knew about long ago.  Glances is a System Monitoring tool for Linux that allows you to watch all the important stuff in real-time.  You can download the source or install it through most major package management systems.

For Ubuntu, enter:

sudo apt-get install glances

When the install is done, type:

sudo glances

You will see a dashboard of all the metrics you should see in the TOP command but you also get network and cpu usage as well.  Check it out over at:


Gimme More, You Ask? You Got It

happy_beagle_by_victoroflatviaHappy Friday!  I’m working on a few new posts for the BeagleBone Black including backups, mounting external hard drives, partitioning the 8GB sd-card I have for extra storage, BBB LAMP server… whew!

It’s gonna be a busy weekend.  Check back because there’s going to be a lot coming shortly.

Guitar Building : Great Resource

sully-garageThis is just a quick note asking anyone interested in building guitars to check out Sully’s Guitar Garage on YouTube (  Sully has been building custom guitars for a few years and I’ve been an avid fan.  He’s videos are well done and he knows what he’s doing.

Also, he’s a huge KISS fan, so that just puts him at the top of the coolness scale.  If you like his work, subscribe to his channel.  I promise you will not be disappointed.