Archive for September 29th, 2014

Backup your PI SD Card

After customization the Raspberry Pi, you may want to take a backup of it so that in case the SD card gets corrupted, you can easily restore the image.

  • Plug the SD card into the Mac or card reader
  • In Terminal, execute diskutil list to find your SD card make note of the disk number (/dev/diskX)
  • Then execute the following command for a backup: sudo dd if=/dev/rdiskX bs=1m | gzip > /path/to/backup.img.gz
    Replace the X with your disk number that you found in the previous step. Note the ‘r’ in /dev/rdiskX is intentional to take advantage of better performance (see the blog post I linked for details).
  • For a restore, the command would be: gzip -dc /path/to/backup.img.gz | sudo dd of=/dev/rdiskX bs=1m

Of course there is an app for that too if you aren’t comfortable with the command line. Its called Apple-PI Baker and its available for download from here. It currently at version 1.6 at the time of writing this.

Comments below please.

September 29, 2014 | By | Reply More

Setting up VNC Access on the PI

I wanted to set up VNC on my Raspberry Pi so I could use it via a remote desktop on my MacBook Air. There are lots of instructions scattered in various places around the web, and I guess I’m going to add to that here. This is not a replacement for all the others but just how I did it.

Firstly, I completed the installation through a ssh session. You could also acheave the same through terminal through the GUI on the PI.

Right… At the terminal enter.

sudo apt-get update
sudo apt-get install avahi-daemon
sudo update-rc.d avahi-daemon defaults

So now I have installed the bonjour service on the PI. I can now find my PI on the network by using it’s hostname.local. In my case raspberry.local and so now pi@raspberrypi.local allows me access.

The next step is to configure the avahi service by entering

sudo vi /etc/avahi/services/afpd.service

And enter the following

<?xml version=”1.0″ standalone=’no’?><DOCTYPE service-group SYSTEM “avahi-service.dtd”>
<service-group>
<name>replace-wildcards = “yes” >%h</name>
<service>
<type>_afpovertcp._tcp</type><port>548</port>
</service>
</service-group>

Then I ran

sudo /etc/init.d/avahi-daemon restart

That got the bonjour service runing and configured.

Now the VNC Server

Back at the terminal I entered these commands…

sudo apt-get install tightvncserver; vncserver

You should now be able to set your VNC password. Choose wisely. The next step is a little configuring. Change in to the init.d dir buy entering

cd /etc/init.d; sudo vim tightvncserver

And enter the following in to vim

#!/bin/bash

### BEGIN INIT INFO

# Provides:          tightvncserver

# Required-Start:    $syslog

# Required-Stop:     $syslog

# Default-Start:     2 3 4 5

# Default-Stop:      0 1 6

# Short-Description: vnc server

# Description:

#

### END INIT INFO

# Carry out specific functions when asked to by the system

case “$1” in

  start)

    su pi -c ‘/usr/bin/vncserver’

    echo “Starting VNC server “

    ;;

  stop)

    pkill vncserver

    echo “VNC Server has been stopped (didn’t double check though)”

    ;;

  *)

    echo “Usage: /etc/init.d/blah {start|stop}”

    exit 1

    ;;

esac

exit 0

Save that with :wq and…

sudo chmod +x tightvncserver; sudo pkill Xtightvnc

Now check that VNC Server is NOT running with

ps aux | grep vnc

Which came back with

pi        3724  0.0  0.1   3520   740 pts/0    S+   14:07   0:00 grep --color=auto vnc

This shows no VNC server running only the command I ran to check.

Now… Almost there

[code language=”plain”]sudo /etc/init.d/tightvncserver start
cd /etc/init.d
sudo update-rc.d tightvncserver defaults[/code]

The next step will announce the VNC Server using bonjour. It just make life easier on the Mac.

Now I created the avahi rfb service by…

sudo vim /etc/avahi/services/rfb.service

And entering..

 

<?xml version=”1.0″ standalone=’no’?>

<DOCTYPE service-group SYSTEM “avahi-service.dtd”>

<service-group>  

<name replace-wildcards=”yes”>%h</name>  

<service>    

<type>_rfb._tcp</type>    

<port>5901</port>  

</service>

</service-group>

Finally restart the newly created service

sudo /etc/init.d/avahi-daemon restart

Now if all has gone weel and I’m sure it has you should see screen sharing being announce in the finder window

[code language=”plain”][/code]

September 29, 2014 | By | Reply More