This article shows how to do it on an Ubuntu machine. But the procedure will be the same on all the Unix and Linux machine. You will need to look for equivalent command for Windows platform. Essentially, this is what I am doing:
- Formatting and copying Raspbian OS to the SD card
- Editing /etc/network/interfaces file
- Putting the SD card in Pi and plugging it to router.
- SSHing to Pi and running a couple of commands
This post is geared towards getting Raspberry Pi set up to work from network.
- You will not need a separate keyboard or monitor for installation and setup.
- You will need a router to access your Pi via VNC or SSH.
- Keep handy: an 8GB SD card, Raspberry Pi, network/LAN cable to connect your Pi to the router, access to the Internet.
Lets get started:
- Insert the SD card, run
df -hto see where it is mounted:
$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda8 35G 28G 5.1G 85% / none 4.0K 0 4.0K 0% /sys/fs/cgroup udev 2.0G 4.0K 2.0G 1% /dev tmpfs 392M 928K 391M 1% /run none 5.0M 0 5.0M 0% /run/lock none 2.0G 17M 1.9G 1% /run/shm none 100M 44K 100M 1% /run/user /dev/mmcblk0 7.4G 4.0K 7.4G 1% /media/nishant/naishePi
- Format the SD card
$ sudo mkdosfs -F 32 -v /dev/mmcblk0or you can use disk utility GUI tool by typing "Disks" in Ubuntu HUD
- Get a copy of Raspian from http://www.raspberrypi.org/download
- Unzip it:
$ unzip 2014-01-07-wheezy-raspbian.zip Archive: 2014-01-07-wheezy-raspbian.zip inflating: 2014-01-07-wheezy-raspbian.img $ ls 2014-01-07-wheezy-raspbian.img 2014-01-07-wheezy-raspbian.zip
- Copy the image file to the SD card using
$ sudo dd if=2014-01-07-wheezy-raspbian.img of=/dev/mmcblk0 bs=1M 2825+0 records in 2825+0 records out 2962227200 bytes (3.0 GB) copied, 588.065 s, 5.0 MB/s
syncto ensure nothing it left to write:
- Unmount the SD card:
$ sudo umount /dev/mmcblk0
- Remove the SD card from the slot and reinsert. It is required because the file system table has changed.
- Now if you browse the SD card it will look like you are browsing a Linux distro. Also, you will see two partitions:
$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda8 35G 28G 5.1G 85% / none 4.0K 0 4.0K 0% /sys/fs/cgroup udev 2.0G 4.0K 2.0G 1% /dev tmpfs 392M 932K 391M 1% /run none 5.0M 0 5.0M 0% /run/lock none 2.0G 17M 1.9G 1% /run/shm none 100M 52K 100M 1% /run/user /dev/mmcblk0p2 2.6G 1.9G 586M 77% /media/nishant/fc254b57-8fff-4f96-9609-ea202d871acf /dev/mmcblk0p1 56M 19M 38M 34% /media/nishant/boot
Here you are 80% done. We now need to setup the network configuration so that we can SSH to our RasPi.
This is my plan. I should be able to place this SD Card in my Raspi and I shall be able to access it via SSH when I power it and connect it to the router that my laptop is connected to.
- Lookup your configuration using
$ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth1 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth1 192.168.2.0 0.0.0.0 255.255.255.0 U 9 0 0 eth1
- We have mask, and gateway from last command. We know that the IP is going to be in 192.168.2.X series. So, lets assign 192.168.2.42 to RasPi. To do this, we need to edit
/etc/network/interfaceson the Raspbian OS ***in the SD CARD** which is located at
/media/nishant/fc254b57-8fff-4f96-9609-ea202d871acf/etc/network/interfaces. MAKE SURE YOU DO NOT END UP EDITING YOUR UBUNTU'S CONFIG.
iface eth0 inet dhcpline with this:
iface eth0 inet static address 192.168.2.42 netmask 255.255.255.0 gateway 192.168.2.1
DONE! Now place this SD card in your RaspberryPi, power it up, connect it to your router. Wait for 5 minutes. Now, try SSH from your laptop:
$ ssh email@example.com
The password is "raspberry" by default. Now you are in Raspberry shell. You need to configure it.
Configuring the system: Execute the following, one by one:
$ sudo apt-get update $ sudo apt-get upgrade $ sudo raspi-config
Use up, down, tab, shift-tab to navigate through the wizard. Enter/space for selecting an option, and esc to going back to previous option.
Remember, unless you Finish this wizard, Raspbian will keep complaining that the config is not yet complete. So, make sure you finally select the "finish" button.
With basic configuration done, I wanted to use the hostname to SSH to the machine. If you wanted to do that, install Avahi.
$ sudo apt-get install avahi-daemon
sudo reboot -n
Wait a couple of minutes. Now, ssh firstname.lastname@example.org (e.g. ssh pi@
Setting up VNC: If you wanted to work on Raspberry GUI. You will have to run VNC server on that so that you can access GUI through network. Here are the steps
- SSH to your Raspberry Pi.
- Install and run Tight VNC Server
$ sudo apt-get install tightvncserver $ tightvncserver $ vncserver :1 -geometry 1024x728 -depth 24
- Access the GUI by using your favorite VNC client I use Remmina Remote Desktop Client on Ubuntu.
- If everything goes fine, you will see your RasPi Screen on your computer. And you could play with it as if you are directly connected to it.