Category Archives: Linux

Setting up raspberry pi

Here’s a list of things I do to set up my raspberry pi and a small note, the purpose of this list is to help me remember what all I need to setup if and when I start from scratch the next time around.

1. Finding your pi’s IP on the local network!

I don’t have a dedicated monitor and run my pi headless. I used to do this by running a for loop and finding the ips of all my devices on the local network and then sshing into them until I found my pi but this is easier and um.., more scientific!

2. Setup Vim and fish on pi.

I don’t like editing files with nano and so setting up Vim is essential and fish is an awesome replacement to bash/zsh you may want to give it a spin. It’s history management is way better than ohmyzsh.

3. Setup Avahi or Zeroconf

It’s always easier to remember hostnames than it is to remember ips and this is where Avahi shines. Now I can access my pi with pi.local even if it’s local ip changes.

4. Remove Xorg and the desktop packages

I like to run my pi, lean and mean there is no need for the desktop when I run it headless, this saves both the disk space and data with updates

5. Setup a bittorrent web client

The folks at howtogeek have an excellent tutorial on setting up deluge, there are a couple of other alternatives as well but deluge works for me quite well.

6. Give your pi a public ip/domain

What good is your pi if you can only access it over the local internet. The whole point of setting up a bittorrent web ui was to be able to download stuff remotely and watch it after you get home. You can also point your subdomain to your pi as I did in my last post.

7. Set up your external hard drive and samba to share it over the network.

To watch the TV shows or movies that you downloaded on your pc/mac you need to set up samba and also to connect your external hard drive to pi. Connecting the external hard drive is the same as connecting to any other linux box and so I’m omitting the steps here.

I’ll probably add more stuff here in time but this is my barebones pi setup.

Raspberry Pi tip : Map your Subdomain to Pi

After I had my Raspberry Pi setup, I wanted to create a subdomain which would point to it.
This is trivial to set up if you have a static IP but I’m assuming that like me you don’t have that.

The way that I have set this up is by following this excellent post on superuser. First you need to set up a dynamic dns for your pi. I use DNSDynamic for this, a tutorial on how to set this up for your pi can be found here. With dynamic dns set up, it’s like having a static ip.

All you need to do after this is to create a CNAME record which points to your dynamic dns. This can be created using your domain registrar’s web interface. A CNAME is basically a pointer and can point to any IP or domain. In my case I set up pi.nikhilbhardwaj.in to point to my dynamic dns. If you’ve set that up correctly you can use dig to verify this. Here’s what I get, babypi.ssh22.net is my dynamic dns. I’d advice you to choose a better name!

After this it’s a matter of forwarding the right ports on your home router and viola you have a subdomain that points to your pi!

dig pi.nikhilbhardwaj.in

; <<>> DiG 9.8.3-P1 <<>> pi.nikhilbhardwaj.in
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57260
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 4

;; QUESTION SECTION:
;pi.nikhilbhardwaj.in.      IN  A

;; ANSWER SECTION:
pi.nikhilbhardwaj.in.   13171   IN  CNAME   babypi.ssh22.net.
babypi.ssh22.net.   60  IN  A   106.51.135.186

Downgrade grub2 to grub

There was this weird issue that I’ve been facing for some time with both ubuntu 12.10 and 12.04, what happens is that my Acer Aspire One 722 netbook doesn’t boot into linux at times. The first couple of times I dismissed it as a one off but that didn’t stop the problem from recurring. Then I blamed my exotic grub2 setup wherein I had installed grub2 to /dev/sda5 and then was using the windows 7 bootloader to chainload it.
Continue reading Downgrade grub2 to grub

Keep Windows and Linux time in sync

Every time I log into windows after having used linux on my netbook there is a problem with the system time. It is because linux treats the time set in your BIOS clock to use the UTC clock, this is a problem as windows treats it to be set to your local time. If you’re using only one OS then both of these choices are acceptable design choices but when you use it becomes a problem. When I’m online it’s not a problem as both windows and linux sync their times with the internet but when offline it’s irritating to look at the clock and see a time that makes no sense.

Fortunately you can tell linux to follows the convention that windows follows, telling windows to behave like linux on the other hand is significantly harder. The best thing about linux is that it makes it’s assumptions and lets you change them to suit your preference. We need to edit this file /etc/default/rcS for ubuntu 12.10


# assume that the BIOS clock is set to UTC time (recommended)
UTC=no

By default the option is yes but we need to change it to no and from the next reboot the problem is solved!

Reliance Netconnect+ Settings for Ubuntu

I had written a post on how we can easily get MTS Mblaze to work under linux and as it turns out, the Reliance Netconnect+ is equally easy to set up and use. Instead of repeating the entire procedure which I have already mentioned here, I’ll just post the relevant wvdial configuration file. You need to add the following snippet to your /etc/wvdial.conf

[Dialer netconnect] 
New PPPD = yes 
Init1 = ATZ 
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 
Modem Type = USB Modem
Baud = 460800 
New PPPD = yes 
Modem = /dev/ttyUSB0 
ISDN = 0 
Username = 9388****** 
Password = 9388****** 
Phone = #777 
Stupid Mode = 1 

It goes without saying that you need to replace the username and password with your netconnect phone no. To connect simply type this in a terminal

sudo wvdial netconnect

Here’s what I get

 ➜  ~  sudo wvdial netconnect 
--> WvDial: Internet dialer version 1.61 
--> Initializing modem. --> Sending: ATZ OK 
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 OK 
--> Modem initialized. 
--> Sending: ATDT#777 
--> Waiting for carrier. ATDT#777 CONNECT 3100000 
--> Carrier detected.  Starting PPP immediately. 
--> Starting pppd at Mon Dec  3 15:45:39 2012 
--> Pid of pppd: 3981 
--> Using interface ppp0 
--> local  IP address 115.242.128.198 
--> remote IP address 220.224.141.145 
--> primary   DNS address 220.226.6.104 
--> secondary DNS address 220.226.100.40
 

Happy browsing with Reliance Netconnect+, I suspect that the MTS device and the Reliance device are actually identical, the only difference being the firmware. As usual let me know in the comments if this helped or if you have some clarifications.

Using the Windows 7/8 bootloader to dual boot linux

In the past whenever I had to install linux along with windows I would install grub and it works flawlessly most of the time. Sometimes however when you’re experimenting with something unusual, it is handy to know how to load linux using the windows bootloader. I used it when I was transferring my ubuntu installation from my laptop to my netbook.
Continue reading Using the Windows 7/8 bootloader to dual boot linux

gprs and wvdial over bluetooth

I must say that the network manager handles ppp connections rather poorly, sometimes they work but most of the times they don’t. The situation is worse still with mobile phones, I have a nokia series 40 mobile phone and when my mts subscription expires, I need to use it for a couple of days. I’ll walk you through the steps that allowed me to connect to the internet using my tata docomo gprs connection over bluetooth.

Continue reading gprs and wvdial over bluetooth

Kde4 map windows key to kickoff launcher

KDE’s equivalent to the windows start menu is the kickoff launcher, being a windows user for a long time before I moved to linux some habits just don’t go away. I tried to change the shortcut key associated to kickoff but as it turns out, KDE treats the Win Key as a meta key. That basically means that just like the Shift, Control and the Alt keys it too has no meaning on its own and must be paired with another key to perform some useful function.

Continue reading Kde4 map windows key to kickoff launcher

Installing ubuntu to a usb drive using vmware

In this post I’m going to walk you through installing ubuntu on a usb drive using vmware, that can boot any system not only virtual machines also we’ll create an ntfs/fat32 partition so that we can use it with windows computers as an ordinary pen drive too.

The first step is to partition the pendrive, I have a 16 GB device and I’ll use half of it for the linux installation and the other half for data. We can use either gparted or cfdisk from the live cd to do this. Another important thing to note is that for any usb storage device, it’s life is affected more by the number of writes that reads. So we’ll also tune a few parameters after the installation to maximize the life of the usb drive.

Partitioned USB drive - VMware Player_2012-06-25_16-10-56

Once the device is partitioned correctly we can install ubuntu as we would on an ordinary hard drive be sure to install the boot loader to the usb drive too. Don’t create any swap partition during the installation that will literally kill your usb drive because it continuously writes data to and from the swap.
Also, having a swap partition on a usb drive doesn’t make too much sense. There is no way you can compare the performance of the RAM to a cheap usb disk.

Once you are done with it, you have successfully installed ubuntu to a usb drive, you can use this to boot any computer. Your OS form now will be in your pocket but I’ll mention a few tips that will make your performance slightly better by using the usb drive more efficiently. Linux keeps a track of the timestamps when files are accessed, this involves writing data to the disk whenever a file is used on a usb drive this is something we don’t need. You can disable this using the noatime option in /etc/fstab. Also we shouldn’t keep update the systemeach time a tiny update is released and ther is no benefit of caching the packages or letting ubuntu install multiple kernels. It may also help to use cinnamon, I have described how that can be used in an earlier blog post. Another thing is that you shouldn’t install restricted drivers or vmware tools as they will create a problem when you boot on machines where that specific piece of hardware isn’t present.

To summarize, keep the usb install lean and mean, you can install the gcc compilers and configure vim and you now have a world class OS in your pocket to use anywhere you want. Let me know how your install went and feel free to ask if you have any doubts in the comments.

Creating a usb recovery image for a netbook using dd

Yesterday I got my new shiny Acer aspire one 722 netbook, it comes with windows 7 starter and I’m not going to stick with it for long but before I start with my experiments I thought of creating a recovery image for it. Having one is particularly useful if things go wrong and you want to use Acer’s warranty, trust me it’s a pain in the rear to explain to the customer support that you use linux or another operating system. Fortunately acer ships with Acer E Recovery Management which is an excellent utility to create a startup disk. I used my USB drive to create a restore disk and also to store my drivers. The only problem is that it took a total of about 12GB out of the 16GB available on my USB drive. I keep using the pendrive for other things too so this couldn’t be a permanent solution. Continue reading Creating a usb recovery image for a netbook using dd