Raspbian – VNC

Installing VNC on the Pi

We’re going to use Tight VNC here (server on the Raspberry Pi and Viewer on Windows).

There’s an excellent tutorial over at Penguin Tutor if you need more information.

First of all install the Tight VNC Server from the command prompt:

sudo apt-get install tightvncserver

Let it finish installing (if you’re asked to confirm anything, just hit ‘y’ on the keyboard). When complete start the server:


You’ll be asked to create a password, enter one and confirm. I used raspberry for ease of use, but probably not the most secure!

When asked to create a view only password, say No.

Every time you start VNC you’ll see something like:

New 'X' desktop is raspberrypi:1

Note the :1. This is the desktop session created. You can add more by running VNC again.

Head over to TightVNC on your windows box and install the viewer.


Source: http://www.neil-black.co.uk/raspberry-pi-beginners-guide#.UTk0TDC9t8F

Raspbian – Misc To-Done

Misc things I’ve done to configure my Pi for my personal usage.

Most have to be done via “sudo”

  • Create a new user, separate from “pi”
    • Command:  ‘adduser’
    • Appears to be a Debian specific command, different than the usual Linux ‘useradd’
  • Make new user’s primary group be “users”
    • Since I’m connecting to my Synology NAS over NFS, this allows any files I create as the new user to be part of a common group between the Pi and NAS
    • Command: ‘usermod -g users <newuser>’
  • As “pi” user, give new user ‘sudo’ access
    • Command: ‘visudo’
  • Create RSA key for authentication
    • Command: ‘ssh-keygen’
    • Be sure to keep your key safe and retrievable so that access is not lost… Don’t lose your key!
  • Add pub key to “~/.ssh/authorized_keys” file for new user
  • After achieving access via key authentication, disable SSH password authentication
    • Edit /etc/ssh/sshd_config
    • “PasswordAuthentication no”
  • Optional, specify SSH access for accounts
    • Edit /etc/ssh/sshd_config
    • At bottom of the file, add:
      • AllowUsers newUser1 newUser2
    • Good way to leave default “pi” user “active”, but not directly accessible via SSH
  • Changed hostname
    • nano /etc/hosts
    • nano /etc/hostname
    • reboot
  • Install rsync
    • aptitude install rsync
  • rsync backup script caused an error
    • Error: Too many open files
    • Testing solution: edit /etc/security/limits.conf
      • @users     hard     nofile     32768
  • Configure NTP to sync with NAS
    • Edit /etc/ntp.conf
    • Comment out existing lines starting with “server” that look like “server 0.debian.pool.ntp.org”
    • Add line like “server <nas IP>”
    • Save
    • service ntp restart

To be continued…

Raspbian – SSH Keys

Very important note: once you get access to your Pi, do regenerate the SSH keys.
Since Raspbian (and basically all the other distributions) are distributed as prepared images to copy onto the SD card, it is not safe to keep the default SSH keys.
To regenerate the keys proceed as follows:

# sudo rm /etc/ssh/ssh_host_*
# sudo dpkg-reconfigure openssh-server

Source: http://www.slblabs.com/2012/08/16/rpi-ssh-ip/

Raspbian – Updating & Upgrading

Updating and Upgrading Debian Raspbian “wheezy” Linux Distribution

Before you begin to install any software it’s best to make sure the package index files are up-to-date (essentially just a file pointing to the latest version of compatible software – for example when we install VNC later in the guide). Make sure you have an internet connection and run the following command. It may take a few minutes.

sudo apt-get update

Followed by:

sudo apt-get upgrade

Now’s also a good time to make sure the whole Linux distribution is up-to-date. You can do this now, or later (it may take a while). Again make sure you have an internet connection and run:

sudo apt-get dist-upgrade

You can run these commands every now and again to make sure you have the latest software. If you’re asked to confirm anything, just hit ‘y’ on the keyboard.


Source: http://www.neil-black.co.uk/raspberry-pi-beginners-guide#.US1NQTC9t8F

Synology My Old Backup Cleanup Script

Since I created my own rsync backup solution for my Synology DS’s, I knew I’d need a script to cleanup and remove the older incremental backups.

The good thing is that since I’m using rsync’s “–link-dest” option, it should be pretty straight forward to cleanup old backups.  Every incremental backup is really a full backup, so just delete the oldest directories.

At least, that’s my theory…

I now have over 30 days of backups, so I was able to create and test a script that follows my theory.

I’ve only run this script manually at this point.  Since I’m actually deleting entire directories, I’m somewhat cautious in creating a new cron job to run this automatically.

# Updated:
# Changes
# -

# Set to the max number of backups to keep

# Base directory of backups
dirBackups="/volume1/<directory containing all your backups>"

# Command to sort backups
# sorts based on creation time, oldest
# at the top of the list
cmdLs='ls -drc1'

# Count the number of total current backups
# All my backups start with "In"
cntBackups=`$cmdLs ${dirBackups}/In* | wc -l`

# Create the list of all backups
# All backups start with "In"
vBackupDirs=`$cmdLs ${dirBackups}/In*`


for myD in $vBackupDirs
# Meant to be a safety mechanism
# that will hopefully kick in if the other
# test fails for some reason
tmpCnt=`$cmdLs ${dirBackups}/In* | wc -l`

if [ $tmpCnt -le 14 ]; then

# Main removal code
# If wanting to test first
# comment the "rm" line and uncomment the "echo" line
# echo $myD
rm -rf $myD

# Track how many directories have been deleted

# Check to see if the script should exit
if [ $((cntBackups-vCnt)) -le $vMaxBackups ]; then

WHS 2011 Install

The install of WHS 2011 went pretty smoothly.

Biggest issue was a little static electricity that froze the system during the install.  Had to start over, but was not far in, so not a big loss. No hardware lost either (silver lining!).

The install automatically partitions the main drive, with no option to change.  Other than the feeling of losing control, I can understand this decision.

The install DOES require a network connection to perform.  Not sure why during… Afterwards when needing to do all the updates (and there are a good number) sure… But during?

I was worried that the Shuttle BIOS would not like the lack of a monitor / keyboard / mouse connected post-install, but it did not complain a bit.  Win!

I did disable “Shadow Copies” on my drives.  Primarily to reduce space usage since I cannot just add more drives to increase space (and got the biggest 2.5″ drives I could find).  We’ve never had a need for this feature, so its not a big loss.

The client connector installs were very time consuming.  The wizard says it could take 30 mins or more… Try well over 1 hour with little feedback that things are even working.  At least this time, patience worked.

One Issue / Resolution: I did hit a small snag when installing the client connector software.  I believe it may have been a conflict with the old client connector software, which I had already removed as a first step.  However, it kept saying that it could not install because of another software install was happening (or something like that).  So I restarted and that solved the problem. I guess there was something still hanging around from the uninstall.

My new WHS 2011

Had an HP EX485 running Windows Home Server.

We liked it.

It died.

Took the opportunity to get my hands dirty…

  • 4 GB DDR3 1333 G.SKILL Ripjaws
  • Intel Core i3-2120T (wanted low power)
  • 2 x Seagate 750GB 7200/16MB 2.5″ Mobile SATA HD
  • Shuttle XH61 Slim Barebone – Intel H61 Chipset
  • Microsoft Windows Home Server (WHS) 2011

Some Thoughts:

  • Used an external DVD drive for the install
    • Tried to use a USB key, but it did not work quickly, so moved on
  • No room for expansion beyond 2 2.5″ hard drives.
    • It should last a few years though and 2.5″ drives should get bigger…
    • Or I’ll build a 2nd server…
    • Or a replacement
  • The case has 4 SATA ports… But only room for 2 drives.  🙁
    • But it is quiet…
    • And small