Jump to content
xisto Community
Ahsaniqbalkmc

Raspberry Pi Headless First Boot (Without Monitor)

Recommended Posts

Raspberry pi is a wonderful piece of hardware. The possibilities of doing all kinds of stuff with it are enormous. Moreover, it has a very active online community and people are trying to do all kinds of things with it and sharing it with the world. So if you are having any issues with the raspberry pi, you are most likely to find solutions online.

 

My problem:

 

The issue I had was absence of a display device for the raspberry pi. As you might know, the pi supports only hdmi and composite video interface. The HDMI is common in new monitors and HD TVs while the composite video (RCA) is common in older tvs and smaller displays.

 

My problem was that I have a spare monitor which only has VGA interface and there is no VGA interface in the raspberry pi. So in order to connect this monitor to the pi, I needed a small device called “HDMI to VGA adapter”. A simple cable won’t do because HDMI and VGA are two different kinds of signals and need to be converted by proper electronic components.

 

However, the price of the adapter is an issue. I tried to find it in a local store and I was told that it would cost me PKR 4500 (about $45). This is way too much when I can spend the same amount of money and exchange my current monitor with one that has built in HDMI support.

 

But presently, I don’t intend to spend money getting a new monitor. So the only option I was left with was booting my raspberry pi headless (i.e. without a monitor). I did some quick research on Google and found without spending much time that it is possible and not very difficult (thanks to the active raspberry pi community)

 

Raspberry pi first boot in normal scenario:

 

For a raspberry pi to function in a normal scenario, the following components are needed:


  • Power supply (most smartphone chargers would work fine)
  • SD card (more than 4 GB is recommended and 2GB is the least requirement)
  • Monitor (not absolutely necessary but we are talking about normal scenario here)
  • An input device (such as a keyboard)

It should be noted that raspberry pi has no storage of its own. It depends on the SD card to store the OS that would make the raspberry pi to work. So in order to boot the raspberry pi in a normal scenario, first of all you need to place the raspberry pi OS onto the SD card, and this would require another computer (not a problem nowadays). Before this it is recommended to format the SD card using the “SD Association’s Formatting Tool

 

Placing a raspberry pi OS on the SD card can mean simple copying of the contents of the NOOBS.zip file (NOOBS = New Out Of The Box Software) onto the SD card or it can mean writing on OS image (such as Raspbian Wheezy OS) on the SD card with the help of special tools like Win32DiskImager.

 

When you have successfully placed the OS on the SD card, all you need to do is insert the SD card properly into the pi, plug in the power supply and connect the monitor. That’s it.

 

The remaining setup is easy and you just have to follow the instructions appearing on the screen.

 

Principle of headless booting:

 

Headless booting (i.e. booting without a display device) is a bit different that normal booting. In this scenario you don’t have monitor or any other display device. And since you don’t have monitor the use of keyboard becomes pointless as well.

 

But you need some means of connecting to the raspberry pi and talking to it. And this is where SSH (Secure Shell) comes to the rescue. SSH is a network protocol that among other things, enables you to use the command line remotely. For SSH to work, you need a network connection to the pi which can be obtained by connecting the pi to the router using an Ethernet cable. Then using SSH, you can easily install VNC server for a graphical connection to pi where you can actually see the desktop of your pi as you would see on a directly attached monitor. So using SSH and VNC, you can operate the raspberry pi via your laptop or home PC.

 

So for headless booting, three things are required:


  • Power supply (same as above)
  • SD card
  • Network Connection (preferably via Ethernet cable to the router)

It should be noted here that the NOOBS package won’t work with headless first boot because it requires you to perform a few actions before actual OS is installed onto the SD card. And it is not possible to perform these actions without monitor and keyboard attached. So in this scenario, the NOOBS package is not going to work.

 

Instead you would need to write the image of an OS (Preferably Raspbian Wheezy) to the SD card using Win32DiskImager (if you are on windows) or dd tool (if you are on linux).

 

Procedure for headless first boot:

 

First of all, make sure that you have all the required components ready and in working condition. The components required for headless first boot are:


  • Raspberry pi itself
  • Power Supply
  • SD card
  • Network connection

 


  • Format the SD card using the SD Associations Formatting Tool (link above).
Posted Image

Download the latest Raspbian OS image.and write it to the SD card using Win32DiskImager (in windows) and dd tool (in linux)
Posted Image

Posted Image

 


Plug in the SD card into the raspberry pi, insert the Ethernet cable and connect the power supply. You would see the lights of the raspberry pi turn on.
Posted Image

Posted Image

 


Wait for a minute or two so that the pi can boot up completely.


To connect to the pi via SSH, you first need to know the IP address of the pi. For this, you can login to the admin section of your router and check the DHCP client list.
Posted Image

 


If you are on windows, you would also need a SSH client (because there is not built in one). Putty is a good SSH client, and is also free so I recommend it. If you are on a linux machine, you don’t need to install anything new.


Windows users: After installing putty, open it, you would see a window like the image below. You need to enter the IP address of the PI and click connect (I have entered the IP address of mine).
Posted Image

 


After the connection is established, you would be presented with a window similar to the following:
Posted Image

 


Enter the username “pi” (without quotes) and password “raspberry” (without quotes). And you SSH connection with the pi would be established.
Posted Image

 


That’s it, you are now connected to the pi. It is a good idea to run the config utility, because its your first boot and you may need to set certain things up. To run config utility, enter the following command:

Sudo raspi-config

After the configuration is complete, it is a good idea to update your raspberry pi. You can easily do it by running the commands:

Sudo apt-get updateSudo apt-get upgrade

After that, if you wish to install the VNC server, so that you can operate the pi in a graphical way, run the following command:

Sudo apt-get install tightvncserver

After tightvncserver is installed, run the following command to start the vncserver on the pi:

Sudo vncserver :1 –geometry 1024x768 (or any other desired window size) –depth 16 (or any other colour depth)

After running this command, you would be asked for a password for the vncserver. Use your desired password. You would also be asked if you like to use a password for read-only mode. Provide one if you want to use read-only mode.
Posted Image

 


To interact with the vncserver on the pi, you need to install a vnc client on your windows machine. For this, install Ultravnc on your windows machine.


Once ultravnc is installed, open the ultraVNCviewer, enter the IP address of the pi followed by “:1” (without quotes) and click on connect button.
Posted Image

 


You would be asked for a password. Provide the password you used when setting the vncserve on the pi. If you want to enter the read-only mode, provide the password you set for read-only mode.


And that’s it. You would see a screen showing you the desktop of the pi. From here, you can use pi like you would use it in a normal scenario,

 

Share this post


Link to post
Share on other sites

Using WIFI instead of the Ethernet Cable for Headless PI:

 

After successfully booting up Raspberry pi without a monitor, its time to move forward and make my pi more mobile and easily accessible. The first step to achieve this is to get rid of the ethernet cable, which limits the pi to be placed near the router only as far as the length of the ethernet cable. I want to get rid of this limitation so that I can keep my pi near me (instead of the router). And for this, the first thing that comes to mind is "establishing connection with the router via wifi instead of the ethernet".

 

A USB WIFI adapter is needed:

 

Now the pi doesn't have built in wifi module. So you have to buy an extra device called "USB WIFI Adapter" or "USB WIFI Dongle". Luckily for me, I had one laying around so the process became easier and natural for me.

 

The device I have is TP-Link TL-WN727N. It is considerably cheap. I bought it for PKR 900 (about $9) some time ago. Below is the picture of the device with its packaging:

Posted Image

 

Luckily for me, the USB WIFI adapter worked with pi out of the box. I.e. it didn't have to install any drivers and face other mess. So if you are not familiar with installing drivers and stuff on linux (which for newbies is significantly harder than installing drivers on windows), then make sure that the wifi adapter you buy works with pi out of the box.

 

Basic Principle:

The principle behind this is simple. Previously we used an ethernet cable to connect the pi to the router and then obtain access via SSH. And through SSH do things on pi like set up VNC server and other things. And then via VNC server operate the pi like a normal scenario (i.e. pi with monitor attached to it). Here we will just change the means of connecting pi to the router from ethernet to wifi. Thus the pi would be connected to the router without any cables and therefore the limitation of placing the pi at one place is omitted.

 

I should clarify one thing here. Prior access to pi is needed before we can set up the wifi connection. So you cannot make a FIRST HEADLESS BOOT with wifi. You still need to connect using ethernet (or use a monitor) to set up wifi and then when all is set, you can say good bye to the ethernet (or monitor).

 

Procedure:


  • Follow the procedure in the first post so that you are able to interact with the pi and perform necessary setup for wifi. Make sure you follow all the steps till the last (18th).

  • Once it is confirmed that you are able to view the raspberry pi desktop and interact with it, open a terminal window and enter the following command to turn your pi off
sudo poweroff

Posted Image

 


Once the pi has powered off. Insert the usb wifi adapter into a usb port. Leave the ethernet cable inserted as before. Start the pi by unplugging the power supply and plugging it again.


Once the pi has restarted, start putty on your windows machine and connect via SSH to the pi by following method described in first post. Also start a vncserver on the pi by method described in the first post.


Start vncviewer and connect to the vncserver of pi (as described in the first post). Once you are able to see the desktop, start the "wifi config" tool on the desktop.
Posted Image

 


Click the scan button. This would open the scan results dialogue box. Click the scan button on dialogue box.
Posted Image

 


The pi will start scanning for your wifi network. Once it has been found, double click on it. A new dialogue box would open. Here insert the password (in the PSK field) and click add
Posted Image

 


You should now be connected to your wifi and should see something similar to the image below:
Posted Image

 


You can also see your IP address here. From now on you can unplug the Ethernet cable permenantly and use the ip address of your wifi connection for both SSH and VNCserver.

NOTE:

The IP addresses in these tutorials are automatically assigned by the DHCP server. These can change overtime so it is a good idea to confirm the ip address of your device by checking the DHCP client list (as described in the first post step no. 5). If your router supports it, you can reserve specific IP addresses for your device so that it would always be given the specified IP address. For this you need to check your routers manual. It is also possible to make the PI use fixed IP address. But as of now, I don't know how to do this. :P

Edited by Ahsaniqbal111 (see edit history)

Share this post


Link to post
Share on other sites

It might not be necessary. But I was assuming the scenario where a person would want to shift to the wifi directly after first boot. As I have also told to run the commands for updates:

sudo apt-get updatesudo apt-get upgrade

So it will be a good idea to power off the system and restart it. Normally a "reboot" command would be preferred but the reboot behavior doesn't fit well with access via SSH (at least I feel this way) so I decided to opt for "poweroff".

Share this post


Link to post
Share on other sites

Using WIFI instead of the Ethernet Cable for Headless PI

 

There is a stand-alone program that will allow you to easily setup your wifi information before burning the disk image to an SD card. The main benefit of this is so educational organizations aren't forced into spending an extra $10 per pi (model A vs. model B) just so they can setup the wifi.

 

You must run this program on a fresh copy of the Raspbian disk image file. It is also easier if you place this program in the same folder as the Raspbian disk image. This program can also be run from the command line:

 

Download it here: https://github.com/jasond-/Win32-Raspbian-Wifi-Injector/releases/tag/v1.2

 

NAME    Win32-Raspbian-Wifi-Injector - Sets up wireless before burning to SD card.SYNOPSIS    Win32-Raspbian-Wifi-Injector-v0.9.8    Win32-Raspbian-Wifi-Injector-v0.9.8 [OPTION]... [IMAGE_FILE]DESCRIPTION    Injects wireless information into a Raspbian disk image file. This    enables a truly headless and wireless setup. Never connect anything    more than a wifi dongle and power supply to your Raspberry Pi.    -a <mode_number>              This sets the connection type. These are the accepted modes:              1 - Open connection              2 - WEP              3 - WPA/WPA2    -d       Experimental - This option will choose the default disk image and essid if available    -D       Experimental - This option will choose the default disk image, essid and access mode [3] if available    -h       Displays this menu    -p <password>              The password for the wireless router    -s <essid>              The name of the wireless router

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.