While this setup is extremely quick, but as a programmer, it is one of my favorite uses for the Raspberry Pi. I have to admit that it makes life so much easier for me that I keep a dedicated Pi just for the purpose of keeping my private projects, deployments, and backups in sync.
- Raspberry Pi – 256mb model works great. Really unless you are using it for large projects with lots of commits, this headless server would be overkill on the 512mb Rev b (use that one for RaspBMC)
- SD Card with the latests Wheezy Rasbian Distro. The size and the class of the card are not super important since your repos will actually live on item 3 but these class 10 cards are pretty cheap from Amazon.
- USB Jump Drive or external hard drive – only you know what you are wanting to save so you have to pick the size. Note – with some usb flash drives and a lot of external hard drives, you will want to use a self powered hub.
Why not use a big SD card and forget the hassles of another storage device and possibly a hub? You can – I like to separate the Git files to a device / partition that is easily readable on my other computers in case of failure. If Pi dies, I just plug it in to my Mac or Windows machine and ‘GIT’ back to work.
Setup of your GitPi
- Get the updates “sudo apt-get update && sudo apt-get upgrade
- Change the hostname –
- Sudo echo “gitpi” > /etc/hostname
- sudo nano /etc/hosts (change any raspberrypi to gitpi – might not be there anymore)
- I find accessing my Pis by hostname work better on my mixed operating system network when I have Avahi running.
- To download the quick installation script, run ‘sudo apt-get install wget git-core’. This step also takes care of getting the Git server and client software.
- When that has completed, type: “wget http://goo.gl/P1ZyC -O setupAvahi.sh”
- chmod +x setupAvahi.sh && sudo ./setupAvahi.sh
- rm setupAvahi.sh
- rebootNow you should be able to access your Raspberry Pi from any computer on the network with the hostname “gitpi.local”.
- Now it is time to mount the drive. We are going to set it up so it automatically mounts every time we start the GitPi.
- First make a mount point, “mkdir /usbdrv”
- Now we have to get some information about the drive with “sudo blkid”My output looks like this for my usb drive:
/dev/sda1: LABEL="Lexar" UUID="71A3-E047" TYPE="vfat"
- My jump drive has type “vfat”. Some of you will see “NTFS”; in which case, you would replace vfat with ntfs-3g in the line we are adding to fstab. I have to give you a warning here. If you mess up your fstab file, you are going to have problems so make a backup (really not a big deal since we are doing this with a fresh disk image). So now the editing: ‘sudo nano /etc/fstab’ and add the following line to the bottom of your fstab with the appropriate uuid and type values (the entire bit below should go on one line).
UUID="71A3-E047" /usbdrv vfat uid=pi,gid=pi,umask=0022,sync,auto,nosuid,rw,nouser 0 0
- Save and reboot.
You should now be good to go. You should be able to ‘cd /usbdrv’ and then create or clone your repos.