How to transfer an existing Arch install onto a new laptop.

Quite recently I realized that I needed  a new laptop because my old one  was in pretty bad shape. It had been through 4 years of constant abuse and as a result it had busted speakers, a faulty touchpad and non-responding keys.

But I faced a daunting task. All of my work over the past one year and a half had gone into the Arch install on my old laptop. How was I supposed to ensure that the whole thing remained as it was on the new laptop? I looked at a few pages on the Arch wiki such as this one here, which dealt with this exact issue. I finally decided that I needed to take this plunge and so I went ahead with that article’s instructions.

Step 1 :

First, I followed this page and backed up my entire root tree onto my external hard disk with the command

# rsync --info=progress2-aAX --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /* /path/to/backup/folder

The contents of /dev, /proc, /sys, /tmp and /run were excluded because they are populated at boot (while the folders themselves are not created), /lost+found is filesystem-specific. If you are running this on the same folder, you may want to include the –delete option to keep the two folders in sync.

Step 2 :

In your old system, enter the following.

$ pacman -Qqe | grep -vx "$(pacman -Qqm)" > Packages
$ pacman -Qqm > Packages.aur

This creates a list of all installed packages on your system via pacman and also those from the Arch User Repository.

Step 3 :

Next, I installed Arch all over again on the new laptop, following the Beginner’s guide. Edit the pacman mirrors as you deem them fit.

Step 4 :

Plug your external hard disk into the new laptop, mount it and copy the old pacman cache (/var/cache/pacman/pkg) onto the new install. Now, the next command

# xargs -a Packages pacman -S --noconfirm --needed

Was not working for me as just read the existing package names and said it was skipping them as it was already installed. I didn’t figure out why that was exactly, and proceeeded as follows. I made a new list of installed packages on the new system ;

$ pacman -Qqe | grep -vx "$(pacman -Qqm)" > Packages-new

Next, get the old “Packages” file which you made on the old system and now sort the two files.

$ sort Packages-new > 1
$ sort Packages > 2

And finally.

diff 1 2 | grep "\>" | sed -e 's/> //' > final

The file “final” now contains File2 – File1, that is, the list of packages which are not in the new system. Now do the following.

for x in $(cat final); do pacman -S $x --noconfirm; done

Actually, this whole sorting and subtracting thing could have been avoided with an additional flag “–needed” for pacman, but somehow that wasn’t working for me. Hence this. Repeat the same process for AUR packages. If you use yaourt, replace “pacman” by “yaourt” in the last command and feed in the AUR package list.
Also if you have Vim plugins installed, make sure you install Pathogen again(if that is what you use, and if you haven’t installed Pathogen from the AUR like me).

curl -LSso ~/.vim/autoload/pathogen.vim

Step 5 :

Create a non-priviledged user, and make sure you’re able to execute startx as that user. Once you do, X creates an .Xauthority file in the home directory. Preserve that file somehow, say by changing it to .Xauthority-old temporarily. The reason I did this was before, I pulled in everything and it was using the .Xauthority file of the backup when I executed startx. This resulted in a “timeout in locking authority file” error and X wouldn’t start. I did the following for a fix.
Next, pull in your entire home directory from the backup.

rsync --info=progress2 -avh /path/to/backup/home/user /home/user

After this is done, make sure to delete the old .Xauthority file and rename the .Xauthority-old file to .Xauthority. Now startx should work normally.

Make sure you also have your locale set up correctly, using localectl, otherwise you might face some problems with correct rendering of unicode characters (for example, ● renders as â). Check this link out.

I found it pretty amazing that in essence, it’s just your home directory and your packages which control your entire system. Even though this might sound a little trivial, it still amazed me when everything worked perfectly finally. I even recovered my open tabs in firefox!



This content is password protected. To view it please enter your password below:

Setting up a DHT22 Temperature and Humidity sensor with the Raspberry Pi.

During the internship, bored out of mind, I was looking at a few cool Raspberry Pi related instructables on Instructables, and I found one particularly awesome one. The guy who made it hooked up a DHT11 sensor with a photoresistor and set that up in his basement, and then he made it upload the data read by the sensors to a website called ThingSpeak, which anyone can access and read. This seemed like it was pretty fun.

For one thing, Kolkata is a really humid place, so naturally I was excited about testing it out and see what kind of data I could take out of it.

And maybe after collecting enough data, I could use my sick data analysis skillz and maybe set up a regression model to predict the next day’s temperature and humidity?

With these thoughts in mind, I went ahead and

  1. Bought a DHT 22 sensor.
  2. (Almost) bought a BMP180 pressure sensor.
  3. Followed this instructable, and set everything up nice and sweet.

Here’s a pic.


And here is the data I managed to collect.

It was pretty good fun doing it. Thingspeak allows you to download the data in CSV format and then from there you can do all sorts of magic with it using SAS or something else. Infact, you can directly work on  your data using MATLAB in ThingSpeak itself. So that’s pretty awesome.

The Raspberry Pi foundation recently came up with a new tiny little add-on board for the Raspberry Pi, which they call the Raspberry Pi SENSE hat.

This add-on board has a temperature humidity sensor, a pressure sensor, an orientation sensor, a tiny joystick and an 8×8 LED matrix grid, all put into one. Buying this one thing can get rid of the need for buying everything else at once. I can’t wait to get my hands on one.

Getting started with electronics with the Raspberry Pi : LED Hello World.

This one was long overdue, and I finally got around to doing it, and even though it’s just a damn LED light, making it glow was an extremely pleasant experience.

I just followed this video and also this video on YouTube. I highly recommend following that channel, because almost all of his videos have to do with the Raspberry Pi and electronics.

Following these two videos, I learnt the following.

Here’s a picture.

An LED light glowing. Note that here I used a 5v pin and not the GPIO pin. This 5v pin is connected to the main powerline of the Raspberry Pi.
An LED light glowing. Note that here I used a 5v pin and not the GPIO pin. This 5v pin is connected to the main powerline of the Raspberry Pi.

I also modified the code in the video above to make a birthday gift for a friend.  I hooked up an LED light to a GPIO pin, and wrote a while loop in python to make the light blink as long as the happy birthday song was playing. Here is the code.

import RPi.GPIO as GPIO
import time
import pygame
import sys



while == True:
while == False:

OSMC-Kodi on the Raspberry Pi

Once after launching a deauthentication attack on my unwary brother who was watching a movie on YouTube, I was overcome by a sudden feeling of guilt, because he came to me immediately afterwards and asked me if I could fix his laptop because his internet wasn’t working. Then I realized that I shouldn’t be such an asshole and so I decided to make it up to him in whatever way I can (without telling him I was responsible for his laptop not connecting, that is).

Now a while ago, I came across OSMC, which is a Debain-based Linux distro which brings Kodi (formerly called XBMC) to a variety of devices, one of them being the Raspberry pi. Now my brother is a nut, one who prefers watching Sunny Deol bash up people to breathing, and since I had to make it up to him somehow, and since I conveniently had a Raspberry pi lying around, and also since OSMC is just so damn beautiful, I decided to install it and show it to him and let him stream some more Sunny Deol.

It turned out that installing OSMC is a breeze. You just need to download the installer for your system, plug in a formatted and wiped SD card, and click on the install and sit back and relax and let it work it’s magic.

After your SD card has the OSMC bootable image on it, simply plug it back in to the Raspberry pi, attach a HDMI cable to it and the TV, and plug in the power cable. If everything’s right, you should get a beautiful splash screen with the OSMC logo on it, and that’s it! If you have a keyboard, then plug that in to the Raspberry pi and you’ll be able to control it with the keyboard. Otherwise, you can simply download the amazing Yatse app for Android, and you’ll be able to control it from your phone. iOS remotes are also available.

Here’s how the Yatse app looks like.

Now by default, OSMC doesn’t ship with the (highly illegal and definitely not recommended (*wink*) ) movie and TV show streaming add-ons, but with a little help, you should be on your way to piracy. I dabbled in piracy of the above kind and it was a thoroughly enjoyable experience.

If you don’t have a TV or a HDMI monitor lying around (i.e., if you’re a stank cheap ass) I think you can set up a http server on the Pi and access it from anywhere within your local network. (Or, using ngrok, from anywhere in the world!)

I haven’t tried this yet, and I will update this blog when I have.

SSH-ing into the Raspberry Pi over the internet.

Sure, it’s easy to SSH into your Raspberry pi when you’re on the same network as the pi itself. You just do an nmap scan to map out the active IP addresses in your network, and you try them out one by one and eventually you’ll gain access. Once you gain access, you can set up your Pi to have a static IP so that you don’t have to bust your ass with nmap every time, and voila, you’re done. (To avoid nmap, one could also go to your router’s page and check all clients under the DHCP service. But this is only possible if you have access to the router.)

But what’s the fun in that?

Once you leave your network, you can’t access your Pi at all. So unless you’re a fat neckbeard spending your whole time in your mom’s basement, the above isn’t very exciting.

In order to get SSH access to my Pi from anywhere in the world, from what I could gather, these were the steps.

  1. Set up a static IP address for your Pi.
  2. Go to your router and forward a port. This is like punching a tiny hole in your firewall to allow any incoming connections from the internet (on the port you forwarded) to go through to the IP address in your home network.
  3. FInd out your network’s public IP
  4. SSH into your Pi!

The second step was the most irritating of all. I went to my routers page, and forwarded port 22 to my raspberry pi, and set up a static IP, and did everything else. But it just wouldn’t connect! I had no idea what to do.

I then searched for alternatives, and I found this amazing service called Weaved. Weaved is a service which basically cuts down all the irritating stuff you have to do in order to get your own connected Internet of Things. This was exactly what I wanted.

So I went ahead and made a Weaved account, and set up everything as shown here. It was very snappy and quick.

The next day I went to work, and opened up my Weaved page, and clicked on my devices which were online.


After clicking on my device, I found this.


I just followed the instructions and there I was, controlling my Raspberry pi from work. Oh man the sweetness.

But life rarely is so easy. The next day I came to work and did the same thing, and I got the dreaded “connection closed by foreign host” error, after being frustrated for a while, I gave up.

The next day I came and it worked! I didn’t know how but it worked. It was as if the universe was playing a cruel joke on me. Anyways, this kept happening. For no apparent reason, I’d get an erraneous ssh_exchange_identification, and for no apparent reason again, everything would go to normal. I searched high and low for an explanation, but I couldn’t get anything partly because Weaved is a new product and not many people are using it yet. So there wasn’t that big a community I could reach out to.

But nonetheless, the people at Weaved were kind enough (or rather, the person running the Weaved twitter handle) to note my excessive wailings on twitter, so they reached out to me, apologized for the inconvenience I was facing, and offered to bump up my account to allow 2 hour connections (previously it was just 30 minutes, which was even more frustrating). I was so touched.

But soon I got very frustrated and searched again for an alternative. Then I found this answer on the raspberry pi stackexchange and found the keyword “”.

This was really the answer to all of my problems.

Ngrok is a tool which creates secure tunnels to your localhost. For ssh, I needed TCP tunnels. To install ngrok on the Pi, I just had to download the Linux/ARM zip file on the pi, and unzip it. That’s it. Now to open a secure TCP tunnel to the localhost on port 22, type in the following.

                ./ngrok tcp 22

Once you have a Tunnel Status = Online, you should see a hostname and port in the “Forwarding” section, which, for an example, looks like

Now this tunnel is forwarded to the localhost. So to ssh into your Raspberry pi over the internet, fire up PuTTY when you’re at work, and enter the hostname and port and the username “pi”, or type in

ssh –p 510xx

and you should be through. This was even more beautiful! It is recommended to use ngrok with a terminal multiplexer such a screen or tmux. I personally used tmux.

A tmux session running a ngrok tcp tunnel to my localhost on prt 22.
A tmux session running a ngrok tcp tunnel to my localhost on p0rt 22.

That was that! For now I’m able to SSH into it pretty cleanly. I just hope this doesn’t die on me.

Lutyens’ Delhi.

A while back, I came across a blog post (of whose content I now have no recollection of), which just focused on praise of one particular thing. It was such a joy reading it, how the words flowed so smoothly out in praise…

That blog post made such a big impression on me that I decided to write something like it myself. I researched on what these types of rhetoric were called, and came across the encomium, which was supposedly the eight exercise in Progymnasmata, a series of rhetorical exercises for the students in Ancient Greece. But the problem was, what was I to write about?

There wasn’t anything which moved me to such an extent that I could write and write about it. Even if I did find something, would I have the skill to just go on and on about it without exhausting everything I could say about it? Like almost everything in my life, I just let this be, and moved on.

Today, however, we (a couple of brothers and I) went on an impromptu tour of Lutyens’ Delhi, and boy, did that shake me up. I wasn’t really a stranger to being shaken up as such, for instance, there was this time where I stood at the very edge of Mumbai, and gazed at it’s skyline, to spot, to my utter shock, Mukesh Ambani’s house. I couldn’t believe it. How rich must one be to have one’s house as a part of the Mumbai skyline? Somehow this filled me with a feeling of contempt, this tingling feeling of unpleasantness at the pit of my stomach.

But today I felt something similar, but it left me with such a drugging combination of emotions that I couldn’t help not recording it.

Looking up at the majesty of Rashtrapati Bhavan and Sansad Bhavan first sent a wave of patriotic pride across, and it made me feel small, almost puny. I felt as though I had reached the very heart of India itself.  All those times when I gazed at these things in movie screens or in pictures, and finally here it in real life, and I had NO idea it was like how it was. Then I looked at perfect it was, the architecture, and the symmetry. Rashtrapati bhavan on one end, and India Gate at the other, and Rajpath connecting them, so beautifully standing in tribute to the genius of Edwin Lutyens.