Linux : Mounting A Remote Network Folder Locally

SSHFS and FUSE To Mount Remote Network Resources

UPDATE (2014.04.09): I may have been premature with the startup script mentioned below.  This doesn’t seem to work.  I am assuming the failure is because my profile isn’t loaded at the time the script is run or my account isn’t allowed to to run scripts using @reboot in a cron config.  Whatever the case, I have found a configuration that works.  I put the startup script call in my ~/.bashrc file and it works as intended.  Here’s the line I added after my environmental declarations (near the bottom):


Everything else worked pretty well.  I am getting the following message when I open a terminal and I will need to do more research as to how to resolve this:

fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the 'nonempty' mount option

</UPDATE> At work, I have a network homedrive for my Linux systems that I only have access network-drive-connectedto once logged into one of my systems.  Once I am in one system, it’s easy for me to move scripts and files around but I have always struggled with the overt disconnection between my local workstation andy my network.  My requirements were straightforward: Easy to configure locally, no network/remote configuration required, maintains solid security, and scriptable. Today, I made a push to get some level of resolution to this issue and I was finally successful using sshfs and FUSE.  While not strictly work related, this will be a huge improvement for my BeagleBone Black projects as well.  It was much easier than I thought it would be.  Let’s say I want to mount the remote home drive from my BeagleBone (hostname: ‘trisket’, user: ‘dave’). NOTE: These instructions assume Ubuntu, but I’m sure the process is the same for other distros

1. Install (if it’s not already installed) ‘sshfs’ on my client

sudo apt-get install sshfs

2. Verify that my user account is in the fuse group.

groups dave

which returns:

dave adm dialout cdrom sudo dip plugdev fuse lpadmin sambashare

If not, add user:

sudo adduser dave fuse

3.  Verify ownership of /dev/fuse and make sure it’s root:fuse.  This is important!

ls -la /dev/fuse


crw-rw---- 1 root root 10, 229 Apr  3 09:12 /dev/fuse

I fixed this with:

sudo chown root:fuse /dev/fuse

4.  Create a mount point:  (I wanted this in my home folder)

mkdir ~/bbb

5: Mount the remote resource:  sshfs remoteuser@remotehost:/remote/resource /local/resource

sshfs dave@trisket:/home/dave ~/bbb

Success!  Now I have the remote BBB home folder mounted on my local workstation. This worked amazingly well and it was very easy to to add others.  In retrospect, I think I will centralize the mount points that I bind to much like the mount folder.  I am keeping these separate from /media or /mnt for my own sanity. Finally, a quick word on persistence.  After I mounted the drive, I logged out and back in and the mount was still there.  However, after a reboot, it disappeared.  So, as I have mentioned in previous posts for my BeagleBone Black initial configuration, I created a startup script that runs on reboot.  There’s lots of ways to do this but this is my method which helps me keep everything organized and within scope. First I added the mount line to my ~/ script:

#! /bin/bash

sshfs dave@trisket:/home/dave ~/bbb

Because I have this already to run on reboot/startup, I don’t have to do anything else.  However, if you are setting this up for the first time, you can have the cron service run this file for you.  I have other posts that go into more detail but you can simply add one entry in your crontab to get this done:

crontab -e

then add the following line:

@reboot /home/dave/

Just make sure you change the path to where your script is saved.  Also, don’t forget to make your startup script executable:

chmod +x

Overall, this was a very easy feature add to my local client configuration and the value is huge, especially at work.  I hope this helps someone and if you have any questions, feel free to post comments.

Simple Santa-Cam Hack with BeagleBone Black

Merry Christmas and Happy Holidays to all! I hope this post finds you in a cheerful and festive way.


Chippy, the Christmas Elf on the Shelf

This past month, my son and I have been thinking about a way to get a picture of the elusive Santa Claus!  We got the Idea from a Make! Weekend Project post. We’ve had to be extra careful because Santa has his embedded helper (spy), Chippy,  watching our every move.  Since Chippy has gone back to the North Pole to help Santa with his last minute preparations, Xander and I found our opportunity get this next project done.  It is a simple frame capture using some inexpensive items we already had, so this didn’t cost us anything.  However, if you were starting from scratch, I estimate this project would cost between $90.00 – $120.00.

Operation Polar Bear

First, here’s a list of the items we used to pull this off:

  • BeagleBone Black
  • Logitech HD C525 Webcam
  • 4-port USB Hub (as small as you can get it – I had to take the cover off mine)
  • 8GB thumb drive (for storing images)
  • Radio Shack Project Box
  • 5V Power Supply
  • Drill and various drill bits

First, I put everything together and proto-typed the build.  Once I verified everything was working as I had intended, I reached for the Project box.

Polarcam – Camera lid

I drilled one hole in the center of the lid for the camera and two holes on left-hand side of the box for power and networking (left or right makes no difference but you will want to position the BBB length-wise to make room for the USB hookup).  I turns out that my double-sided tape was used by Chippy (do you think he knows something?) so I had to improvise and use a combination of medical and painters tape to secure everything to my box.

Temp Mounting Solution

Temp Mounting Solution

Since we have very little time and this is a temporary installation, I was not very tidy with the side hole.  NOTE:  Be tidy with the side holes and give yourself plenty of space.  You will thank me later.

I then mounted the BBB, the USB hub, and the thumb drive into the box.  After one last check, I sealed it up and did a test. (See my post on mounting a USB drive HERE)

USB Hub with Camera and Thumb Drive attached

USB Hub with Camera and Thumb Drive attached

Once everything was working, it was time to fine tune the system.  Here’s what I did to get the system running:

I am running Ubuntu 12.10 on my BeagleBone Black.  I have mounted a 16GB thumb drive to it using my USB passive hub to “/media“.  I created the folder structure under media to hold my images “/media/capture/polar-bear”.

Next I installed fswebcam.  I based my fswebcam build off a blog post HERE:

apt-get install fswebcam

To make this process work (time-lapse style), I created a configuration file and saved it in my home folder, called “polarcam.conf“, which I will explain:

device /dev/video0
input 0
loop 2
skip 10
resolution 640x480
set brightness=60%
set contrast=13%
font /usr/share/fonts/truetype/msttcorefonts/arial.ttf
title "Santa-CAM"
timestamp "%m-%d-%Y %H:%M:%S (%Z)"
jpeg 95
save /media/capture/polar-bear/polarcam-%Y%m%d-%H:%M:%S.jpg
palette MJPEG

Device: this is your webcam.  In most instances, it will be /dev/video0 unless you have other video sources plugged in.

Loop: this is the delay between frames, in seconds.  Since I figured Santa was a busy guy and would be trying to get in and out rather quickly, I set this for 2 seconds.

Skip: this is the number of frames to skip at startup.  Most camera have a short warm-up period where colors and brightness are not exact.  I set mine for 10 seconds but you can adjust for your particular device.

Background: runs the app in quiet mode if you are using it interactively.  I leave this commented out until I am ready to put it into “production”

Resolution:  This is the video resolution.  A smaller image size saves space and bigger has better image quality.  Based on your needs, and storage, you will be able to modify and adjust accordingly.

Top-banner:  This puts a banner at the top where you can put the name of the camera and a time stamp.  I haven’t played around with this but I believe you can put this at the bottom too.

Title:  Whatever you want to call this camera.  It will be superimposed in the banner on every frame.

Timestamp:  Puts the date and time on each image as it was taken.  This can be modified.

Save:  This is the path to where I want to save my images.

I really didn’t mess with the other parameters but you can get the details on all the available parameters and add them to your config by using the “fswebcam –help” command.

To test this, I simply entered the following:

sudo fswebcam -c <path-to-config-file>/fswebcam.conf

If the background parameter is commented, then the output should look something like this:

dfrey@ubuntu-armhf:~/fswebcam$ sudo fswebcam -c polarcam.conf 

>>> Next image due: 2013-12-24 09:59:52 (EST)
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
--- Capturing frame...
Skipping 10 frames...
Capturing 1 frames...
Corrupt JPEG data: 1 extraneous bytes before marker 0xd3
Captured 11 frames in 0.34 seconds. (32 fps)
--- Processing captured image...
Putting banner at the top.
Setting font to /usr/share/fonts/truetype/msttcorefonts/arial.ttf.
Setting title "Santa-CAM".
Setting timestamp "%m-%d-%Y %H:%M:%S (%Z)".
Setting output format to JPEG, quality 95
Writing JPEG image to '/media/capture/polar-bear/polarcam-20131224-09:59:52.jpg'.
>>> Next image due: 2013-12-24 09:59:54 (EST)
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
--- Capturing frame...
Skipping 10 frames...
Capturing 1 frames...
Corrupt JPEG data: 1 extraneous bytes before marker 0xd1
Captured 11 frames in 0.34 seconds. (32 fps)
--- Processing captured image...
Putting banner at the top.
Setting font to /usr/share/fonts/truetype/msttcorefonts/arial.ttf.
Setting title "Santa-CAM".
Setting timestamp "%m-%d-%Y %H:%M:%S (%Z)".
Setting output format to JPEG, quality 95
Writing JPEG image to '/media/capture/polar-bear/polarcam-20131224-09:59:54.jpg'.
>>> Next image due: 2013-12-24 09:59:56 (EST)

… and so on until you stop it (CTRL-C).  I noticed that there were a couple error messages regarding corrupt images but when I looked back at them, they looked ok, so I disregarded them.

If the “background” parameter is uncommented, you will see nothing and the app will run until the cows come home (translation: until you run out of storage space or turn off the BBB).  However, you can shut it off using this command:

sudo pkill fswebcam


Now that I have the app and hardware to get the job done, I have to make a decision as to how I want to start and stop the application.  I tried putting the start command in my .bashrc file and it worked but it just runs forever and that’s just not enough control for me.  After talking with Xander, we decided that we needed to limit the amount of time the camera ran so we could get as many images as possible.  We decided that between 11:30pm and 1:00AM would be fine b/c Santa has historically made his rounds in our town by 1:00AM (based on NOAA, NASA and NORAD data).  I elected to start and stop the process with a cron job (pronounced: CRAN JAB).

Here’s my script for root:

sudo crontab -e -l root

@reboot /opt/

00 */12 * * * ntpdate -b -s -u
30 23 * * * fswebcam -c /home/dfrey/fswebcam/polarcam.conf
00 01 * * * pkill fswebcam

The last two lines are where the magic happen.  At 11:30PM, the fswebcam process will start, using my polarcam config file.  This will run continuously until 1:00AM, where the process is killed.

Last night, I tested this a couple times.  I did have some trouble with it not actually running but I think that this was because I didn’t give the BBB enough time to boot up after moving it to the target location.  However, my final test was successful and I was able to capture 30 minutes of images @ 1 per 2 second intervals.  Something else to note is that this camera has an IR filter on it, so it cannot use IR LEDs to illuminate dark rooms.  I will have to insure that the room has adequate lighting for our “Polar Bear.”  I will be upgrading this project to include and IR-ready camera and a PIR motion sensor.

Well, today is the big day.  After 46 years of trying to catch that Jolly Ol’ Elf in the act, I think I finally have a solution.  Check back in a couple days to see Santa in Action!

Thanks for stopping by.  Merry Christmas and a Happy New Year to all!

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: