Tech reviews and tutorials on the likes of Raspberry Pi, Arduino, Microchip PIC but also Virtualisation and computing in general.
Learn to share is my motto. The 80s are back and technology is fun once again.
Have you ever wondered what to do with that old laptop you kept for so long because you never had the heart to trough it away?
Plug a Raspberry Pi2 into your old laptop and give it a second life! Also wouldn't it be great to get your Pi around the house with a very portable setup? I know you get a Pi-Top (I'll admit it's cool but $269.99 without the Pi!!!), you can get a Touchscreen even the original from the Pi Foundation, but the recycler in me sometimes screams for justice.
This setup I am using costs near to nothing and gets the dust off those useless laptops in the loft.
The idea is pretty easy; we get a Pi, plug it in two USB ports of the laptop via a Y cable, connect it via the Ethernet port to the NIC of the laptop, VNC into the Pi, configure the Wi-Fi and job done.
Fix the Pi on the back of your laptop's screen with whatever you can think of and enjoy a Pi with no dangling cables but with a nice keyboard, video and mouse setup.
I made sure that the steps to follow are as simple as possible and that the configuration should work in the majority of situations. By all means this can be further improved and I'll be glad to hear from anybody who might have suggestions.
The configuration and setup can be replicated pretty much on any laptop you might have, even a new one!
The requirements for the laptop are:
2 USB ports
1 NIC ethernet
1 Working keyboard and 1 Working Touchpad/Mouse :)
1 Working Screen :))
This is essentially it from the HW point of view. The reason for the Y cable is to make sure that the Pi receives enough current to power itself correctly. Each USB ports in USB1/2 delivers a maximum of 500mA so if you have a laptop of that era you certainly need the Y cable.
The Ethernet cable doesn't need to be a cross-over although that wouldn't hurt if it is. The Pi is capable of Auto MDI-X and will be able to adjust to a straight or a crossover cable directly connected to the laptop; no Ethernet HUB/SWITCH required.
Software wise the Pi will come with its usual distro Raspbian and the Laptop in my case is Elementary Linux. Different combinations of distros should certainly work but might require adjustments compared to what I am showing here.
06-02-16 Please check the information at the bottom of this page before going ahead with the ICS setup. The quickest A quick way to have the best "Plug & Play" experience is to configure the laptop to work as a DHCP for the Pi, this will ensure that the Pi can just come out of a freshly burned SD card (If you use NOOBS you need to install an OS first) with no need for any configuration only requiring to only install VNC server on your Pi but with no need to configure its networking.
Most NetworkManager distributions should allow for "internet connection sharing" for each network cards. This allows for the laptop to use a service called Dnsmasq to provide automatic configuration of networking parameters for the guests, in our case the Pi. Great!
This is how I configured my laptop:
Once the "internet configuration sharing" is setup our Pi can be plugged in in the USB ports of the laptop and hooked to the Ethernet cable.
After a while we should have an IP for the PI but we are not going to know which is going to be that easily. Luckily both Rasbian and Elementary (Linux in general does) support something called mDNS out of the box. mDNS is for DNS what Link-local address is for IP (you know those 169.254.x.y addresses?) and it allows for DNS names to be setup "democratically" amongst computers in the same network. Raspbian sets its name as
and once it gets an IP you should be able to ping raspberrypi.local without knowing the IP, excellent!
If you can ping it, you can SSH to it and that's the next thing to do.
We SSH to the Pi and start the VNC server (of course there will be a one off password to setup, keep it simple and use the Pi user password).
The server should be started with the same resolution of your laptop screen as we want to run the Pi in full screen on the laptop. The command to run on the Pi will be something like:
vncserver -geometry 1280x800
or whichever is the resolution of your laptop, I hope you know how to find it :)
We now have a VNC server to connect to, note that it runs on screen :1 but don't try yet to get on the Pi until you have done the steps below otherwise you won't be able to use F8 to close the session as the keyboard might not work.
One thing you may find in fact is that once in fullscreen the keyboard is not working on the remote session. To fix this I had to edit /etc/X11/app-defaults/Vncviewer as sudo
sudo nano /etc/X11/app-defaults/Vncviewer
This is distribution dependant and you might have to look elsewhere for this file depending on what you run on the laptop.
The line that we are uncommenting is:
on the laptop we should now be able to VNC safely to the Pi. The command I am using is:
we are connecting on host raspberrypi.local on screen 1 in fullscreen and compress the session to get better performance. I made a script just not to have to type that all the time.
You can play with compresslevel from 0 to 9 where 9 is less compressed. The network should not be the bottleneck as it is a dedicated fast-ethernet connection but the video card on you old laptop might be the one not actually able to keep up.
If the command above succeeds you should be prompted for the VNC server password you set earlier on and after that you should finally be in your Pi's desktop!!
We are not done yet unfortunately, a few more tweaks.
The first thing to do on the Pi is to configure the eth0 card as static IP.
The reason is still within the realm of keeping things as simple as possible. You remember that Dnsmasq you mentioned earlier? Well as a good DHCP it will keep on refreshing periodically the information of the Pi's Ethernet adapter not only with IP and Mask but also with Gateway, DNS and default route. Now, after we will enable the Wi-Fi card on the Pi we'll want for the default route and the DNS server to be only the ones of the Wireless card not the ones configured from the DHCP server on the laptop. This will ensure that the Pi will be able to connect to the internet only through its Wi-Fi card.
The best thing to do is to configure the IP address of the Pi's eth0 as the one it used to receive from the DHCP's laptop and
uncheck "Automatically configure empty options"
leaving the Router and DNS sections empty.
Note that this will configure the network mask of the Pi as 255.0.0.0 whilst the laptop interface will have a mask of 255.255.255.0. This is not going to cause any problems although it is quite an horrible thing to live with if you have done any serious networking in your life!
Next we need to edit:
sudo nano /etc/resolv.conf
on the Pi to remove the settings obtained from the laptop. We need to remove the line that says:
or whichever is the IP of your laptop
it should look like this:
Lastly we need to remove the default route 0.0.0.0 associated with the laptop's address, in my case:
sudo route del -net 0.0.0.0 gw 10.42.0.1
so that the routes will look like this:
At this point we'll need to configure the Wi-Fi connection on the Pi in the standard way and we should be done!!!
After these steps connecting again should be just a question of powering up the laptop, starting the VNC server on the Pi (which can of course be set to start automatically) and VNC into the Pi.
What is left to do
A lot more automation can be done. When the laptop shuts down for example we should be able to also run a clean shutdown and wait for the Pi to be off before shutting down the laptop. The VNC session could also be run automatically at the startup of the laptop including passing the password for the Pi. The initial configuration of things for both the Pi and the laptop could be scripted to make things easy even for the less expert.
Finally get a better networking configuration, I hate that thing about the network mask!!
Also some good designer cloud come up with maybe a 3D printed enclosure or VESA fix like structure that can be adjusted to most laptop screens. It'll be nice to find a way to accommodate a breadboard too although having it always fixed on the back of the screen might not be ideal.
I leave it here I guess but this is clearly far from being something to "resell".
If your laptop comes with a Wi-Fi interface then you could use that to connect the Pi to the internet in a much more traditional ICS configuration. This hides the Pi behind a NAT and for the majority won't be a problem and work great, I preferred to use the laptop just as a KVM though.
I must admit that I have tried to find out whether the Pi supports Link-local address which would have made things less complicated but I couldn't find much about this and eventually opted for the more cumbersome "internet connection sharing" approach.
In the long run having to type a password for the laptop and one for the Pi can be tedious so my advice is to at least enable autologin on the laptop and disable the password prompt when exiting the screensaver
06-02-16 - UPDATE
Since I wrote this article I researched a bit more into the matter of Link-Local Address and specifically with regard to the support of this in Raspbian. It turns out that the Pi is more than capable of supporting IP auto configuration and this is in fact the quickest way to go about configuring the Pi in tailless mode (I like calling it this way!).
By configuring the laptop Ethernet interface as Link-Local only the adapter will get a 169.254.x.y address and will be immediately ready to resolve raspberrypi.local.
This doesn't mean that the steps I discussed in the main part of this article are wrong only that the networking setup can be achieved in a much easier way if using Link-Local address instead of ICS.
Do you have some old laptops sitting around that aren't quite good enough to run a full desktop? Do you also have a good enough PC that could run some virtualisation platform? Then there is hope yet!
As I am writing this article I am using a rather old laptop with an Intel Atom with 2GB of RAM and everything is running pretty smoothly.
I have just renewed my home server running ESXi 6 on which I have installed Windows 7 in a VM. I then acquired 5 free VNC licences of RealVNC and installed a VNC server on the Windows box.
The laptop runs a light version of Linux, in my case Elementary.
I have set the resolution of the Windows box to match the one of my laptop and simply run VNC viewer from my laptop to the Windows box in full screen.
The result is actually quite good!
There are enterprise level protocols that can serve the purpose in a much better way; smoother video refresh, better compression, multimedia support but for most of what I do VNC is absolutely fine.
I have no audio support, the videos are not very fluid but in general the experience is very good.
Also my session always stays there where I left it which is a good bonus because I can take that same session from pretty much any device I have in the house including my tablet.
Once you have one desktop floating in the house nobody will stop me from having two three more, no need for a beefy laptop, no need for dual boot, simply switch your session!
As I am writing about the upgrade process of my ESXi server in a bit more detail I will also go through what I did to setup the Desktop Virtualisation (strictly speaking this is not VDI in fact) so stay tuned!