Switching Raspbian to Pixel desktop

Official Raspbian images based on Debian Stretch by default has the Pixel desktop environment and will login new users to it. But if you have had a Raspbian installation with another DE (such as LXDE), here are the steps to install and login to the Pixel desktop.

apt-get install raspberrypi-ui-mods
sed -i 's/^autologin-user=pi/#autologin-user=pi/' /etc/lightdm/lightdm.conf
update-alternatives --set x-session-manager /usr/bin/startlxde-pi
sed -i 's/^Session=.*/Session=lightdm-xsession/' ${USER}/.dmrc

Make sure the user’s ‘.dmrc’ file is updated with the new startlxde-pi session as that is where lightdm login manager looks to decide which desktop should be launched.


Convert iPhone contacts to vCard

On a recent troubleshooting attempt, I lost all the contacts in my Android phone. It had also received a recent update which took away the option to import contacts from another phone via bluetooth.
I still had some contacts in the old iPhone, but now that mass transfer via bluetooth is gone, it was a question of manually sending each contact in vCard format to the Android phone. That means I should probably find a less dreadful way to get the contacts back.

Here is one way to extract contacts en-masse from iPhone into popular vCard format. The contact and address details in iOS are stored by AddressBook application in a file named ‘AddressBook.sqlitedb’ which is an sqlite database. The idea is to open this database using sqlite, extract the details from a couple of tables and convert the entries into vCard format.

Disclaimer: the iPhone is an old 3GS running iOS 6 and it is jailbroken. If you attempt this, your mileage would vary. Required tools/softwares are usbmuxd (especially libusbmuxd-utils) and sqlite, with the prerequisite that openssh server is running on the jailbroken iPhone.

  1. Connect iPhone via USB cable to the Linux machine. Run iproxy 2222 22 to connect to the openssh server running on the jailbroken phone. iproxy comes with libusbmuxd-utils package.
  2. Copy the addressbook sqlite database from phone:scp -P 2222 mobile@localhost:/var/mobile/Library/AddressBook/AddressBook.sqlitedb .Instead of steps 1 and 2 above, it might be possible to copy this file using Nautilus (gvfs-afc) or Dolphin (kio_afc) file manager, although I’m not sure if the file is accessible.
  3. Extract the contact and address details from the sqlite db (based on this forum post):sqlite3 -cmd ".out contacts.txt" AddressBook.sqlitedb "select ABPerson.prefix, ABPerson.first,ABPerson.last,ABPerson.organization, c.value as MobilePhone, h.val ue as HomePhone, he.value as HomeEmail, w.value as WorkPhone, we.value as WorkEmail,ABPerson.note from ABPerson left outer join ABMultiValue c on c.record_id = ABPerson.ROWID and c.label = 1 and c.property= 3 left outer join ABMultiValue h on h.record_id = ABPerson.ROWID and h.label = 2 and h.property = 3 left outer join ABMultiValue he on he.record_id = ABPerson.ROWID and he.label = 2 and he.property = 4 left outer join ABMultiValue w on w.record_id = ABPerson.ROWID and w.label = 4 and w.property = 3 left outer join ABMultiValue we on we.record_id = ABPerson.ROWID and we.label = 4 and we.property = 4;"
  4. Convert the extracted contact details to vCard format:cat contacts.txt | awk -F\| '{print "BEGIN:VCARD\nVERSION:3.0\nN:"$3";"$2";;;\nFN:"$2" "$3"\nORG:"$4"\nEMAIL;type=INTERNET;type=WORK;type=pref:" $9"\nTEL;type=CELL;type=pref:"$5"\nTEL;TYPE=HOME:"$6"\nTEL;TYPE=WORK:"$8"\nNOTE:"$9"\nEND:VCARD\n"}' > Contacts.vcf
  5. Remove the empty content lines if some contacts do not have all the different fields:sed -i '/.*:$/d' Contacts.vcf

Now simply transfer the Contact.vcf file containing all the contact details to Android phone’s storage and import contacts from there.


Many years ago, when I first saw this thing called Linux and found that I could use it everyday (in the college Lab), it intrigued me so much that I spent days and nights with it. Learning new things every day.

I remember this particular story – trying to get MPlayer work on my friend’s desktop running RedHat 9. Only the college lab had internet connection, I was downloading the RPM, finds that it is too big to fit in a Floppy disk, so I cut it into smaller KB files, doing round trips from Lab to hostel room, finally stitch them together and try to install it. Then I got into fighting the ‘dependency hell’ – MPlayer had a lot of dependencies, so I have to then search for the dependencies individually in rpm.pbone.net and download all these RPMS, copy them into the floppy and try to install them all together – of course using ‘rpm -ivh‘. That, then would result into a new level of dependency, missing dozens of libxyz.so files. The end of the story is that I did manage to install MPlayer and play videos.

And then Fedora Core emerged. With it, we found Yum as the package manager and instantly found that it can solve the dependencies for me! Ever since then, the one single command I have run most would be “yum”. Over the years it gained a lot of new features and stability.

I have recently learned the tragic demise of Seth Vidal who developed yum; and though I never knew him personally; he has touched someone’s life at the other end of the world. Thank you, Seth.

Fedora 18 : Install from ISO file

I can’t remember the last time I burned a DVD when a new Fedora version releases. The preferred way of installing a new version is the ‘diskless’ install method provided the computer already is running one or the other version of Fedora. For guidelines, see the installation guide: http://docs.fedoraproject.org/en-US/Fedora/18/html/Installation_Guide/ap-medialess-install.html

As of Fedora 17, the Boot Options have been changed, and the “askmethod” parameter is deprecated, it is no longer recognized by the installer. Instead you need to use “inst.repo” parameter with appropriate syntax to specify install from network (http/ftp), nfs, hard disk et al.

I have obtained the Fedora 18 DVD ISO file, mounted it loopback, and copied the vmlinuz and initrd.img from isolinux folder to /boot/ and added a custom menu entry in /etc/grub.d/40_custom with the repo method as found in the documentation. Installer starts, but unfortunately fails, probably at stage2, with a dracut message saying “Cannot boot” and “Root device not found”. There’s no helpful error message or warning as to what could cause this.

Finally figured out that the repo parameter was missing a colon after the hard disk device. This had hit me during the Fedora 17 install too, so let it be documented for future reference. The proper parameter would be something like:

linux /boot/vmlinuz-fedora18-install repo=hd:/dev/sda2:/home/rajeesh/

Where the Fedora DVD ISO is placed at /home/rajeesh. Once that is fixed, installer boots into the graphical mode just fine. The new installer seems quite unstable – it crashed 4 times before I could complete installation – at disk probing, when switching to other terminals using Alt+Ctrl+F2, Alt+Ctrl+F3 etc. But once that phase is passed, the package installation is swift. There’s no way to customize and tweak package selection during the installation, which is quite limiting. That said, once the installation is done, the desktop is quite solid and polished.

On bufferbloat and shoulders of the giants

Is your internet connection slow?

Yeah yeah, you have connection with bandwidth of 7.2 Mbps but it sulks (no pun intended) and you wonder why.

The answer, mostly is, #bufferbloat [1]. In short, the data flows from Google+ to your computer sitting somewhere in the dark corner on the opposite side of the world, ‘packets’ of this data are stored and transmitted at each intermediate stop through which they are passed. The protocol used to communicate between your computer and a google server, and everything in between (the intermediate stops), is called TCP and that beast is pretty good at adapting to the best speed with which those two end points (your computer and the google server) can talk to each other.
The way TCP achieves that is – when google server sends a few thousand packets at a go with the maximum speed it has, your computer might be choking to cope up with the volume and it will start dropping the packets (UPDATE: and acknowledgements, hereafter referred to as ACK, are sent notifying the dropping ACK is sent on successful delivery of packets. Dropping is assumed if no ACK is received in a reasonable amount of time. For more technical details, see excellent comment from James Cape), and google server slows down sending packets accordingly.

Wondering where the problem is, then? Well, all those intermediate points – including servers, routers, your broadband ISPs, their servers, routers, your WiFi router and even the Network Card (NIC) on your computer – have ‘buffer’ to keep a large number of packets, before it could be processed/transmitted further. And that excessive buffering, is what the problem is, which defeats TCP adapting itself. +Jim Gettys was one mastermind who got irritated with the same, decided to investigate, zeroed in on the problem, created widespread awareness and coined the term #bufferbloat for it, towards the end of 2010.

Now the question is, how to fix it. Looks pretty simple – reduce the amount of buffer, right? Unfortunately, not quite. What is the standard size of the buffer to be used? If the size of the buffer is too small, slow connections suffer. If the buffer size is too large, fast connections suffer. What was needed is another algorithm, usually called Adaptive (UPDATE: corrected by Stuart Cheshire in comments) Active Queue Management. There were various attempts to find One True ™ algorithm independent of network/bandwidth/timing/buffer size/queue size, devoid of knobs for fine tuning.

Now, Kathleen Nichols and Van Jacobson (yes, /the/ Van Jacobson) have come up with an algorithm closest to that, called #CoDel [2]. The very first implementations of CoDel by +Dave Taht and +Eric Dumazet and are going into #Linux kernel now, along with similar implementations to #CeroWrt (based on #Linux ) for routers [3]. This is one of the pieces of solution to bufferbloat, not the only one, but definitely one in the right direction.

These extra ordinary people, today, are silently fixing tomorrow’s internet. And they deserve big props for that. All you technologists who didn’t get a chance to appreciate Nikola Tesla or Dennis Ritchie, here is your chance to do that for some of the real heroes of our time.

[1] http://gettys.wordpress.com/category/bufferbloat/
[2] http://queue.acm.org/detail.cfm?id=2209336
[3] http://lwn.net/Articles/496509/

Disclaimer: The descriptions of various technological aspects in this article are overly simplistic and may not be one hundred percent correct, please add a note or comment if you find an inaccuracy.