Step by step guide PART 1 Table of Contents 1. Hardware (0:05)... 3 RS Online (ex-tax prices)... 3 MSY... 4 ebay... 4 Centercom Computers... 4 2. Installing the operating system (0:21)... 5 Preparing the microsd card... 5 Copying the Noobs software to the microsd card... 5 Hooking up the hardware... 6 Installing the Raspbian operating system... 7 3. Configuring the Raspberry Pi 2b (4:19)... 8 Change the password... 8 Determine your IP address... 8 Set router to give the Raspberry Pi 2b the same IP address every time... 9 4. Remotely accessing the Raspberry Pi 2b (5:42)... 10 Access through SSH (Putty)... 10 Update & upgrade Raspbian packages... 11 Install tight VNC server... 12 Automatically start tight VNC server on boot-up... 13 Install autocutsel (Cut & Paste for VNC)... 14 Installing VNC Viewer (client) on your PC... 15 Setting VNC s screen resolution... 16 5. Backup and Recovery of Raspberry Pi 2b microsd card (11:07)... 17 Backup... 17 Recovery... 17 MDTV3 PAGE 1 OF 26
6. NAS - Network attached storage (11:44)... 18 Installing ntfs-3g (NTFS support)... 18 Connecting a USB memory stick... 19 Automatically mounting usb drives on boot up... 21 Connecting a USB hard drive... 22 Installing Samba to share files over your network... 24 Testing Samba over the network... 26 MDTV3 VERSION 1 PAGE 2 OF 26
1. Hardware (0:05) RS Online (ex-tax prices) My Raspberry Pi 2b [832-6274], Case [819-3655] & 16Gb microsd card [877-5557] was purchased through RS Online The Verbatim microsd card wasn t able to boot Raspbian, I replaced it with a Sandisk microsd card. MDTV3 VERSION 1 PAGE 3 OF 26
MSY Originally I used my HTC Phone wall usb power supply with micro usb connector, however to run external usb hard disk I purchased this hub so that it would run both the Raspberry Pi and the external hard disk. I also had to replace the Verbatim microsd card with this Sandisk due to compatibility issues with the Verbatim card. It s worth noting that the Raspberry Pi 2b can be particular about what it works with so please check the hardware compatiblity list before purchasing items. ebay HDMI cable for initial installation of operating system, (you could also use an AV cable). Centercom Computers I already had this external hard disk that I will use for storing shared files & downloads. MDTV3 VERSION 1 PAGE 4 OF 26
2. Installing the operating system (0:21) Preparing the microsd card Insert the microsd card into your PC computer/laptop card reader. Download SDformatter from www.sdcard.org Set format size adjustment to ON from the Option button Press the Format button. If you get an error that the disk is write protector try a different card reader. Copying the Noobs software to the microsd card Download the NOOBS zip file from www.raspberrypi.org and extract the contents to the root directory of the microsd card, make sure that you only copy the files and not the zip folder. The card should look like this: Eject the microsd card and insert it into the Raspberry Pi 2b MDTV3 VERSION 1 PAGE 5 OF 26
Hooking up the hardware You will need a keyboard/mouse for the initial installation of the operating system, I just borrowed my existing desktop pc s wireless keyboard & mouse (as you will only need it for a few minutes). Use a network cable and hook the Raspberry Pi 2b into your internet router/hub. Connect the HDMI cable to your monitor, (you can also use an AV cable to a TV). You can use a standard usb phone charger (or you could use a usb hub, but you will need something that supplies decent power amperage) to power the Raspberry Pi 2b. Insert the micro usb power cable into the Raspberry Pi 2b last. Figure 1. Raspberry Pi hardware connected and running MDTV3 VERSION 1 PAGE 6 OF 26
Installing the Raspbian operating system You will see the following installation menu appear on the screen, tick the box next to the first item, Raspbian. Then select your language, I chose English US, then click the Install button at the top left. Click Yes when asked to confirm overwriting data on the microsd card. Once the installation starts you will see a progress bar, it will take 15 minutes or so to install Raspbian. After the installation is complete you will see the Raspbian desktop. MDTV3 VERSION 1 PAGE 7 OF 26
3. Configuring the Raspberry Pi 2b (4:19) Change the password Click on the black computer screen icon at the top left of the desktop to run LXTerminal. Type in passwd then type in the current password raspberry then type in the new password topsecret [To make the text lager go to edit, preferences and change the font size] Determine your IP address Type in ifconfig and you will be displayed a lot of information about your network interfaces, take note of two values, your current internet address, in this example it is 192.168.1.68 and your hardware or mac address in this example it is b8:27:eb:59:31:e7 If you are not sure what IP address your router is on you can also type in the command netstat r which will show you the gateway device (router). In this example it has a name of Bigpond.Bigpond it may also have been displayed as an IP address. MDTV3 VERSION 1 PAGE 8 OF 26
Set router to give the Raspberry Pi 2b the same IP address every time Start epiphany web browser (click the icon of the globe) and type in the gateway address name (or IP address of gateway). On my router I need to go to Home Network to setup static IP for the Raspberry Pi 2b. Click Devices, then raspberrypi, click configure, then tick the box which says always use the same IP address Click apply. MDTV3 VERSION 1 PAGE 9 OF 26
4. Remotely accessing the Raspberry Pi 2b (5:42) Access through SSH (Putty) Download Putty from www.putty.org to your PC and open a connection to the Raspberry Pi 2b. You can save the connection settings so that you don t have to type in the value each time. Click Open Then log in with the default username of pi and the password of topsecret You can now remotely control the Raspberry Pi 2b MDTV3 VERSION 1 PAGE 10 OF 26
Update & upgrade Raspbian packages Before we start installing other applications lets update & upgrade our Raspbian packages. Enter the following command via putty (use the right mouse button to paste copied text) or LXTerminal. Type in sudo apt-get update Type in sudo apt-get upgrade Press Y and then press enter MDTV3 VERSION 1 PAGE 11 OF 26
Install tight VNC server https://www.raspberrypi.org/documentation/remote-access/vnc/ Also refer to Lynda.com training video Up and Running with Raspberry Pi with Mark Niemann-Ross (5.3 Installing VNC on raspberry pi) Enter the following command via putty or LXTerminal. sudo apt-get install tightvncserver Enter Y and press enter. Start the server by typing in tightvncserver Enter in a password for VNC less than 8 characters, passwords longer than 8 characters will be truncated. Type secret and press enter. Enter N and press enter MDTV3 VERSION 1 PAGE 12 OF 26
Automatically start tight VNC server on boot-up Enter the following command via putty or LXTerminal sudo nano /etc/init.d/tightvncserver and copy & paste the text below into the editor. Press control X enter Y and enter to save changes. ### BEGIN INIT INFO # Provides: vncserver # Required-Start: networking # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Starts VNC # Description: ### END INIT INFO #!/bin/sh # /etc/init.d/tightvncserver VNCUSER='pi' case "$1" in start) su $VNCUSER -c '/usr/bin/tightvncserver :1' echo "Starting TightVNC Server for $VNCUSER " ;; stop) pkill Xtightvnc echo "TightVNC Server stopped" ;; *) echo "Usage: /etc/init.d/tightvncserver {start stop}" exit 1 ;; esac exit 0 Type in sudo chmod 755 /etc/init.d/tightvncserver to make the file executable, then type in sudo update-rc.d tightvncserver defaults to make it execute when booting. Reboot the Raspberry Pi 2b by typing sudo reboot MDTV3 VERSION 1 PAGE 13 OF 26
Install autocutsel (Cut & Paste for VNC) Enter the following command via putty or LXTerminal sudo apt-get install autocutsel Then type sudo nano /home/pi/.vnc/xstartup Add the line autocutsel fork to the file, press control X enter Y and enter to save changes. Type in the command sudo reboot to restart the Raspberry Pi 2b. MDTV3 VERSION 1 PAGE 14 OF 26
Installing VNC Viewer (client) on your PC Download and install VNC viewer on your PC from www.realvnc.com Type in the IP address for your Raspberry Pi 2b and ad a full colon followed by the port number 5901 Click connect. Tick the Don t warn me about this again check box and click continue Enter in the password for VNC (secret) and click OK You will now see the Raspbian desktop. Do not use this outside your home network as the connection is not secure (use Putty instead). MDTV3 VERSION 1 PAGE 15 OF 26
Setting VNC s screen resolution On my desktop PC I like to use VNC set to 1024x768, full screen would be 1920x1200 (or 1600x900 on my laptop). Control the resolution (geometry) and the colour depth by editing the startup file by typing sudo nano /etc/init.d/tightvncserver After the line that has /usr/bin/tightvncserver :1 add the word geometry 800x600 and depth 24 make sure it is inside the quote marks. You can change the resolution to whatever size you want. Press control X enter Y and enter to save changes. Type in sudo reboot to restart the Raspberry Pi 2b. MDTV3 VERSION 1 PAGE 16 OF 26
5. Backup and Recovery of Raspberry Pi 2b microsd card (11:07) Now that our system is up & running it is prudent to save what we have done so far in case something goes awry, I would also suggest you keep multiple versions of your backup because you may not detect when something went wrong and it is handy to have multiple recovery options to different states. Backup Shut down your Raspberry Pi 2b and remove the microsd card and put it in your PC, download the program win32 disk imager from http://sourceforge.net/projects/win32diskimager/ Select the drive letter of the microsd card from the drop down list. Press the folder icon and browse to the location that you want to store you backups in, then give the backup a filename, be as specific as you can so you can understand which backup you want to restore later on. Press Read to begin the backup of the microsd card. Recovery To restore a previously backed up image to the microsd card select the drive letter, then press the folder icon to browse to the location of the backup file and then press write to restore the backup to the microsd card. http://raspberrypihq.com/how-to-backup-your-raspberry-pi/ MDTV3 VERSION 1 PAGE 17 OF 26
6. NAS - Network attached storage (11:44) Installing ntfs-3g (NTFS support) Enter the following command via putty or LXTerminal sudo apt-get install ntfs-3g MDTV3 VERSION 1 PAGE 18 OF 26
Connecting a USB memory stick All my media is formatted with NTFS, if you are using FAT or FAT32 remember to adjust the commands accordingly. Before you put the usb stick in the Raspberry Pi 2b it is a good idea to create a file or folder on it from your desktop PC so that once the drive is mounted you can look for this file to verify the mount has been successful. If the mount is not successful you could accidently fill up your microsd card instead of the usb memory stick. Create the following folder on your usb memory stick. Eject the usb memory stick from your PC and insert it into a usb port on the Raspberry Pi 2b or into the usb hub. If you have the Raspbian desktop open you can file manager to browse to the /media folder or use the ls command via putty or LXTerminal, the usb memory stick has been given the lovely name of AA87A7EA87A5929 MDTV3 VERSION 1 PAGE 19 OF 26
If for some reason you need to find out this information manually just type in ls -l /dev/disk/by-uuid/ The usb memory stick is the last entry (sda1). Create a directory in the /media folder to mount the usb memory stick as, I am using the name usbstick, type in sudo mkdir /media/usbstick then type in sudo chmod 770 /media/usbstick/ Then type in sudo chown -R pi:users /media/usbstick/ Now try to mount the ubs memory stick with the command: sudo mount -t ntfs-3g -o uid=pi,gid=pi,umask=007 /dev/sda1 /media/usbstick/ If the usb memory stick is already mounted (my Raspberry Pi 2b automatically mounted my usb memory stick and gave it that really ugly name), if this is the case just unmount it by typing sudo umount /dev/sda1 and then retry the mount command above. Check to see if the usb memory stick has been mounted correctly by typing ls /media/usbstick/ You should be able to see the file or directory you created on your desktop PC (SanDiskUSBstick). MDTV3 VERSION 1 PAGE 20 OF 26
Automatically mounting usb drives on boot up To automate the mounting of the usb memery stick everytime the Raspberry Pi 2b boots we need to edit the fstab file, but first we should make a backup by typing sudo cp /etc/fstab /etc/fstab.backup Now edit the file by typing sudo nano /etc/fstab Add the following fine to the bottom of the file (replace the ugly number with your devices name) UUID=74C65315C652D748 /media/usbstick ntfs-3g auto,users,rw,uid=pi,gid=pi 0 0 Press control X enter Y and enter to save changes. Reboot by typing sudo reboot You can now check under the /media directory and find your usb memory stick is ready to go, type ls /media/usbstick/or browse to the location with File Manager. You should be able to see the file or directory you created on your desktop PC (SanDiskUSBstick). When you want to remove the usb memory stick you can either shut the Raspberry Pi 2b down then remove it or you can use the command like we did before typing sudo umount /dev/sda1 Make sure you are not accessing any files from this directory at the time of un-mounting. MDTV3 VERSION 1 PAGE 21 OF 26
Connecting a USB hard drive You can add a usb hard drive the same way you did the usb memory stick, however you may find that you can only get the hard drive to power up from the usb hub. Here is a look at my system with 1 usb memory stick and 1 usb hard disk drive Figure 2. Raspberry Pi, D-Link USB hub and Hitachi Touro USB hard disk. Find out the of the usb hard disk by typing ls -l /dev/disk/by-uuid/ reference name The usb hard disk is the 2 nd line item from the bottom (86A8CAD5A8CAC343) MDTV3 VERSION 1 PAGE 22 OF 26
Add the automatic mounting of the usb hard disk to the fstab file by typing sudo nano /etc/fstab Add the following line to the end of the file; UUID=86A8CAD5A8CAC343 /media/usbhdd ntfs-3g auto,users,rw,uid=pi,gid=pi 0 0 Press control X enter Y and enter to save changes. Reboot by typing sudo reboot You can now check under the /media directory and find your usb memory stick is ready to go, type ls /media/usbhdd/or browse to the location with File Manager. You should be able to see the file or directory you created on your desktop PC (Touro). Another useful command is sudo fdisk l it will list all of the disks attached to the Raspberry Pi 2b. http://www.techjawab.com/2013/06/how-to-setup-mount-auto-mount-usb-hard.html http://www.howtogeek.com/139433/how-to-turn-a-raspberry-pi-into-a-low-power-network-storage-device/ MDTV3 VERSION 1 PAGE 23 OF 26
Installing Samba to share files over your network https://www.maketecheasier.com/turn-raspberry-pi-into-file-server/ Type sudo apt-get install samba samba-common-bin to install Samba, enter Y when asked if you want to continue. Create a samba password for the pi user account by typing???????????????????????????? sudo smbpasswd a pi and entering a password secret [Optional] Create a user account just for accessing the files over the network, set the password then add the users samba password. sudo useradd nasuser -m -G users sudo passwd nasuser sudo smbpasswd -a nasuser Backup the config file before editing it by typing sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old Then edit the file by typing sudo nano /etc/samba/smb.conf MDTV3 VERSION 1 PAGE 24 OF 26
Scroll down the file until you get to the Authentication section and remove the # hash from in front of the line security = user Add the following details of the folders you want to share over your network at the bottom of the file. [usbstick] comment = usb memory stick path = /media/usbstick valid users = @users force group = users create mask = 0660 directory mask = 0771 read only = no [usbhdd] comment = usb hard disk drive path = /media/usbhdd valid users = @users force group = users create mask = 0660 directory mask = 0771 read only = no MDTV3 VERSION 1 PAGE 25 OF 26
If you created the optional user then add the following lines to hide their home folder from view. [nasuser] browsable = no read only = yes valid users = nasuser path = /home/nasuser hide unreadable = yes Press control X enter Y and enter to save changes. Testing Samba over the network Either browse the Network or type in \\raspberrypi into file explorer. Enter in pi as the user name and the password or if you created the NAS user type in nasuser and their password. Tick the box to remember your credentials click OK Create a folder to ensure you have full read/write access. MDTV3 VERSION 1 PAGE 26 OF 26