Wednesday, October 16, 2013

Installing a new hard disk without reinstalling Ubuntu/Windows

I own a 7-year old Dell Inspiron 1420 laptop, which comes with a 160 GB hard drive. My optical drive stopped working a couple of years ago and I had been contemplating getting a secondary hard drive. The only thing that kept me from it was the whole process of reinstalling my dual boot configuration on it. While Ubuntu installation is not too difficult and is done pretty quickly, I really hate having to reinstall Windows. The OS installation alone takes up a lot of time, not to forget the time required for installing additional programs like a good web browser, PDF reader, a compression program, antivirus, an office suite and vlc/mplayer - these are perhaps the most basic necessities that are needed to make your Windows functional.

A couple of months back, I decided to finally get an additional drive 750 GB drive and a caddy to place it securely in place of my optical drive. Choosing a caddy is easy - you just need to take care of two things : the size of the optical drive (12.5 or 9 mm) and the interface (IDE/SATA) that it uses to connect the motherboard. This is the same interface which is used to connect your optical drive and can be checked when you take out your optical drive.

Cloning the hard disk

Important Note:  /dev/sda refers to the complete hard drive and includes all partitions. /dev/sda1 refers to a specific partition of the same hard drive.

My home folder is on the same partition as the Ubuntu install. So I just cloned the two partitions using the terminal. My Ubuntu and Windows partitions were on /dev/sda1 and /dev/sda2 respectively. A good way to make sure you have the correct partition is to use the GParted tool (included in the Live CD) or the fdisk -l command at the terminal.
user@pc: ~$ sudo fdisk -l
Then I connected my external drive and used the following commands:
user@pc: ~$ dd if=/dev/sda1 of=/media/EXTERNAL/Ubuntu.img bs=4096
user@pc: ~$ dd if=/dev/sda2 of=/media/EXTERNAL/Win7.img bs=4096
I used this method because it does not require installing additional programs. For more ways of cloning, this article on lifehacker is a good read.

In the meantime, I used unetbootin to create a Ubuntu bootable USB. When the backup was done, I simply shut down my computer and replaced my primary hard drive with the new spacious one I had bought. The next step was to boot into Ubuntu using the live USB I had just made and then partition the new drive. I made a partition system similar to my previous one -
1. ext4 (Ubuntu)
2. NTFS (Windows 7)
3. NTFS (storage of common data files like Dropbox/Firefox profile/Music/etc.)

Note that I do not use any separate swap partition on my computer.

Of course, I made sure that the new partitions were at least the same size or bigger than the previous ones to ensure that the image file can be written back on them. When the partitions were made and properly formatted, I restored the OS installations on my new drive using the following commands:
user@pc: ~$ dd if=/media/EXTERNAL/Ubuntu.img of=/dev/sdb1 bs=4096
user@pc: ~$ dd if=/media/EXTERNAL/Win7.img of=/dev/sdb2 bs=4096
Yes, the new hard drive was mounted as /dev/sdb in my case. But you should check using the fdisk -l command to make sure you are restoring the images on the correct drives/partitions. Now, we are almost done.

Reinstalling the bootloader

One thing to notice here is that I cloned individual partitions instead of the whole drive. While this would have been also possible, I did it this way because I did not have enough free space on my external disk. Which is why the next step becomes important. I have two OS installations on the new hard drive now but no bootloader. To make this computer recognize the OS installs, I installed grub2 on the drive in the following way (Source: HowToUbuntu):

1. While still in the live CD/USB environment, open a terminal and mount the partition your Ubuntu Installation is on. Again, it can be found out by using GParted or the fdisk command.
user@pc: ~$ sudo mount /dev/sdb1 /mnt  
2. Now bind the directories that grub needs access to to detect other operating systems, in the following fashion
user@pc: ~$ mount --bind /dev /mnt/dev && sudo mount --bind /dev/pts /mnt/dev/pts && sudo mount --bind /proc /mnt/proc && sudo mount --bind /sys /mnt/sys
3. Now we need to change the apparent root directory of the live environment to the one on the Ubuntu partition we just mounted
user@pc: ~$ sudo chroot /mnt
4. Now install, check, and update grub. Grub is installed on the whole drive and not a single partition, so use /dev/sdb instead of /dev/sdb1 for the following set of commands
user@pc: ~$ grub-install /dev/sdb
user@pc: ~$ grub-install --recheck /dev/sdb
user@pc: ~$ update-grub
5. Now the grub installation is complete. All that is left is to exit the chrooted system and unmount everything.
user@pc: ~$ exit && sudo umount /mnt/dev && sudo umount /mnt/dev/pts && sudo umount /mnt/proc && sudo umount /mnt/sys && sudo umount /mnt
6. Shut down and turn your computer back on, and you will be met with the default grub2 screen.

That's it! Now you should have a completely running system with the same configuration as you had before. I have not tried doing this with a significant change in the system configuration. Even with those changes, Ubuntu should port to the new system configuration just fine. The only problem that you could face is with Windows because sometimes its WGA kicks in if it detects a change in your hardware.

Thursday, March 28, 2013

Synchronizing Notes in XFCE with Dropbox/Ubuntu One


If you have a lot of notes like me, you would probably want instant access to them. While Evernote is a good application to get the same results, I find the everpad interface on ubuntu rather annoying. And I prefer to use the native app in XFCE for notes - conveniently called "Notes". This app has the advantages of being lightweight, fast and easily accessible - but only on my personal laptop. What if I need access to some of this information when I am at work? The answer is simple - your favourite online sync service.

The good thing about Notes is that it saves everything in the plain text format - no hassles there. You could just take these files with you and use any reader to open them. Even on your mobile device! All you need to do is sync them using Ubuntu One or Dropbox (or any other sync service of your choice). The folder to sync is :
~/.local/share/notes
Sharing this with Ubuntu One is easy. Just fire up Ubuntu One, and add the above folder and everything should be smooth.

For Dropbox, however, there is no straightforward way to accomplish this. But with a little trick, this should be as easy typing a line out on the terminal - literally. Open up your terminal and navigate to the Dropbox folder and type:
user@pc:~/Dropbox$ ln -s ~/.local/share/notes/
This command creates a symbolic link in your Dropbox folder that points to the location of your locally stored notes. Presto! Now your notes are synced across all of your devices with Dropbox. It also becomes easier to share specific notes with certain people through Dropbox. If I wish to share the travel notes I have made for the upcoming trip with my girlfriend, I could just share the ~/Dropbox/notes/Travel folder with her.

Wednesday, March 27, 2013

My Conky Configuration (and how to set it up)

I have been a huge fan of Conky for some time now. However, I have always found tinkering with the configuration files and scripts too intimidating. So, I had been stuck on using the Clock Rings configuration.


Although it looks quite elegant, I was bored of it because I would rather use the space on my desktop for displaying information I care about. So, I went to work and tried my hand at it again. Making use of the resources I mentioned in my previous post, I finally tweaked the configuration to fit into my scheme of things. The end result looks something like this:

screen.png

Because I put a lot of effort into putting things into place, I think it is worth sharing it. Let me take this moment to point out that this configuration may not be the best for you. Heck, some people may also find it an eyesore. But the beauty of linux lies in that fact that it is customizable. The purpose is not to have a one-configuration-fits-all solution. Rather, it is to have a free knowledge base of ideas so that you can build your own setup that suits your purpose.

OK. Now that I have made my point, let's get back to business. So, what is required?

To make this configuration work as is, the following elements are needed:

1. The Conky Configuration File
2. Scripts for Weather, Google Calendar, External IP
3. Fonts

Let's have a look at each of them one by one:

Conky configuration file (.conkyrc)

#####################################
##     Conky Configuration File    ##
#####################################
alignment top_right
background yes
#border_margin 5
border_width 5
cpu_avg_samples 2
default_color white
default_outline_color 000000  # Black
default_shade_color 000000 # Black
double_buffer yes
draw_borders no
draw_graph_borders no
draw_outline no
draw_shades no
gap_x 10
gap_y 30
max_specials 1024
max_user_text 10000
maximum_width 380
minimum_size 380
net_avg_samples 2
no_buffers yes
override_utf8_locale yes
own_window yes
own_window_colour 000000 # Black
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_transparent yes
own_window_type normal

own_window_argb_visual yes
own_window_argb_value 0

pad_percents 2
short_units yes
stippled_borders 3
text_buffer_size 8000
total_run_times 0
update_interval 1.0
uppercase no
use_spacer right
use_xft yes
xftalpha 0.75
xftfont Trebuchet MS:size=10

TEXT
#######################################
##     Current Day, Time and Date    ##
#######################################
${color white}${font ZegoeLight-U:pixelsize=40}${time %A %I:%M %p}${font}
${hr 1}
#Calendar Current Date Right
${voffset 10}${font Droid Sans:size=15}${alignr}${time %B}
${font Droid Sans:size=35}${alignr}${time %d}${font}
${font Droid Sans:size=10}${voffset 10}${alignr}${tztime Asia/Kolkata %H:%M} ${font Trebuchet MS:size=8}IST${font}
######################################
##      CALENDAR (5-Line)           ##
######################################
${voffset -98}${offset 175}${font DroidSansMono:size=7.55}${color3}${execpi 60 VinDSL_Cal_9=`date +%-d`; cal -h | sed -e 's/\r//g' -e 's/^/ /g' -e '1d' -e 's/\<'"$VinDSL_Cal_9"'\>/${color4}&${color3}/'}${font}
######################################
##      Weather - Now               ##
######################################
${texeci 500 bash ~/.conky/accuweather/acc_int_cwfont}${font}${voffset -95}${goto 30}${color ffe595}NOW${color}
${font conkyweather:size=60}${offset -5}${execi 600  sed -n '27p' ~/.conky/accuweather/curr_cond}${font}
${voffset -75}${goto 90}${execpi 600 sed -n '1p' ~/.conky/accuweather/messages}
${goto 90}${color ffe595}T: $color${execpi 600 sed -n '29p' ~/.conky/accuweather/curr_cond}°C (${execpi 600 sed -n '30p' ~/.conky/accuweather/curr_cond}°C)
${goto 90}${color ffe595}W: $color${execpi 600 sed -n '31p' ~/.conky/accuweather/curr_cond} ${execpi 600 sed -n '32p' ~/.conky/accuweather/curr_cond}
${goto 90}${color ffe595}H: $color${execpi 600 sed -n '33p' ~/.conky/accuweather/curr_cond}${voffset 30}
###########################################
##      Weather - Tonight and 2 Day      ##
###########################################
${goto 30}${color ffe595}TONIGHT${goto 145}${execpi 600 sed -n '5p' ~/.conky/accuweather/first_days}${goto 270}${execpi 600 sed -n '10p' ~/.conky/accuweather/first_days}$color${voffset 5}
${goto 10}${font conkyweather:size=30}${execi 600  sed -n '30p' ~/.conky/accuweather/first_days}${goto 140}${execi 600  sed -n '6p' ~/.conky/accuweather/first_days}${goto 265}${execi 600  sed -n '11p' ~/.conky/accuweather/first_days}${font}
${voffset -40}${goto 50}${execpi 600 sed -n '31p' ~/.conky/accuweather/first_days}°C (${execpi 600 sed -n '32p' ~/.conky/accuweather/first_days}°C)${goto 190}${execpi 600 sed -n '8p' ~/.conky/accuweather/first_days}°C (${execpi 600 sed -n '9p' ~/.conky/accuweather/first_days}°C)${goto 315}${execpi 600 sed -n '13p' ~/.conky/accuweather/first_days}°C (${execpi 600 sed -n '14p' ~/.conky/accuweather/first_days}°C)
${goto 50}${execpi 600 sed -n '3p' ~/.conky/accuweather/messages}${goto 190}${execpi 600 sed -n '4p' ~/.conky/accuweather/messages}${goto 315}${execpi 600 sed -n '5p' ~/.conky/accuweather/messages}${voffset 20}
##########################################
##      Music Section for Clementine    ##
##########################################
#${if_running clementine}${if_match "${execi 5 conkyClementine --datatype=ST}" == "Playing"}${goto 18}${if_match "${execi 5 conkyClementine --datatype=FN}" > "http"}${font Buttons and Switches JL:pixelsize=20}i${else}${font Buttons and Switches JL:pixelsize=20}h${endif}${font}${voffset -8}${goto 70}${execi 5 conkyClementine --datatype=TI} - ${execi 5 conkyClementine --datatype=AR}${endif}${if_match "${execi 5 conkyClementine --datatype=ST}" == "Paused"}${goto 18}${font Buttons and Switches JL:pixelsize=20}f${font}${voffset -8}${goto 70}${execi 5 conkyClementine --datatype=TI} - ${execi 5 conkyClementine --datatype=AR}${endif}${endif}
###################################################
##      Google Mail & Calendar Appointments      ##
###################################################
${font  Droid Sans:pixelsize=25}Upcoming${font}${font conkysymbols:size=12}${goto 310}c${font}${voffset -3}  ${execi 600 conkyEmail --servertype=IMAP --servername=imap.googlemail.com --username=USERID --password=PASSWORD --ssl} Unread
${hr 1}
${font Trebuchet MS:size=10}${execpi 1800 conkyGoogleCalendar --username=USERID --password=PASSWORD --daysahead=7 --dateformat="%a %d %b" --requestCalendarNames="Main;Tasks" --template=~/.conky/.conkyGoogleCalendartemplate | fold -w100}

#########################################
##      RSS Feeds                      ##
#########################################
${font  Droid Sans:pixelsize=25}Headlines${font}
${hr 1}
${rss http://feeds.bbci.co.uk/news/rss.xml?edition=int 30 item_titles 1}
${rss http://www.thehindu.com/news/?service=rss 30 item_titles 1}
${rss http://www.aljazeera.com/Services/Rss/?PostingId=2007731105943979989 30 item_titles 1}

########################################
##      System Information            ##
########################################
${font Droid Sans:pixelsize=25}System${font}${alignr}$kernel
${hr 1}
# ${cpugraph 20,210 000000 000000}
Core 1: ${cpu cpu0}% ${alignr}Core 2: ${cpu cpu1}%         
${cpubar 8,100 cpu} ${alignr}${cpubar 8,100 cpu}
${freq_g (1)} GHz/${exec sensors | grep "Core 0" | cut --bytes=14-21} $alignr ${freq_g (2)} GHz/${exec sensors | grep "Core 1" | cut --bytes=14-21}
#RAM Information
${font Trebuchet MS:size=10}RAM: ${mem} / ${memmax}${alignr}${membar 8,100} 
#Section for displaying top processes and their PID and CPU/Memory Usage
#${font Trebuchet MS:size=10}PROCESS ${goto 148}PID${goto 245}CPU% ${goto 350}MEM%
#${goto 9}${top name 1}${goto 140}${top pid 1}${goto 240}${top cpu 1}${goto 345}${top mem 1}
#${goto 9}${top name 2}${goto 140}${top pid 2}${goto 240}${top cpu 2}${goto 345}${top mem 2}
#${goto 9}${top name 3}${goto 140}${top pid 3}${goto 240}${top cpu 3}${goto 345}${top mem 3}
#HARD DISK Information
#Use $memperc% for percentage
Home: ${fs_used /home} / ${fs_size /home} ${alignr}${fs_bar 8,100 /home}
Data: ${fs_used /media/Data} / ${fs_size /media/Data} ${alignr}${alignr}${fs_bar 8,100 /media/Data}
Uptime: ${uptime}
Battery: ${battery_short BAT0} ${battery_time} ${alignr}${battery_bar 9,100 BAT0}
#Battery Temperature
#Battery: ${alignr}${battery_percent BAT0}% / ${acpitemp}°C
${execi 1800 vnstat -m -i wlan0 | grep "`date +"'%y"`" | tail -1 | awk '{print $1}'}: ${execi 1800 vnstat -m -i wlan0 | grep "`date +"'%y"`" | tail -1 | awk '{print $9 $10}'}${alignr}Average: ${execi 1800 vnstat -m -i wlan0 | grep "`date +"'%y"`" | tail -1 | awk '{print $12 " " $13}'}
#########################################
##      Network Information            ##
#########################################
#${font Droid Sans:pixelsize=25}Network${font}$alignr${wireless_essid wlan0}
#${hr 1}
#gateway IP: ${alignr}${gw_ip}
#Local IP: ${addr wlan0}${alignr}Public IP: ${execi 1800 ~/.conky/scripts/ip.sh}
#Today: ${totaldown wlan0} / ${totalup wlan0} ${alignr}Speed: ${downspeed wlan0}/${upspeed wlan0}
#${execi 1800 vnstat -m -i wlan0 | grep "`date +"'%y"`" | tail -1 | awk '{print $1}'}: ${execi 1800 vnstat -m -i wlan0 | grep "`date +"'%y"`" | tail -1 | awk '{print $9 $10}'}${alignr}Average: ${execi 1800 vnstat -m -i wlan0 | grep "`date +"'%y"`" | tail -1 | awk '{print $12 " " $13}'}

Scripts


Weather
The weather scripts are supposed to download the weather-related information from sites such as AccuWeather/WUnderground and extract useful information out of it. This information is then stored in text format to be utilized by the .conkyrc file. My configuration makes use of Teo's 1d2 accuweather script (acc_int_cwfont). While it is possible to use some of his other scripts, it will also require a lot of changes in the conky configuration file.

Google Calendar Template (.conkyGoogleCalendartemplate)
This script is just a template to present the appointment information in a specific way. I have written it to display the Event title, starting time and location. You could change it to display other variables like end time, etc.
${font Droid Sans:pixelsize=16}[title]
${font Droid Sans:pixelsize=14}[starttime]
${font Droid Sans:pixelsize=14}[location]

Script to find External IP (ip.sh)
This scripts uses the wget command to get your external IP from the dyndns website. You could a different website, with a little change in the latter half of the script if you know what the output looks like.
#!/bin/bash
# Script to Find External IP

wget http://checkip.dyndns.org/ -q -O - |
grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'  

 Additional Fonts

The fonts I have used can be divided on the basis of Text and Symbols. The text fonts are easily replaced by a substitute of your choice. The symbols, however, cannot be. They are meant to display specific information like weather (Sunny/Cloudy/Rain) or Email.

Text Fonts
ZegoeLight-U, Droid Sans, Droid Sans Mono, Trebuchet MS

Symbol Fonts
Conkyweather (Weather Section), conkysymbols (Unread Emails Section), Buttons and Switches JL (Conky Clementine Section)

That pretty much concludes the configuration. With all of these elements, you can easily recreate the above configuration. :)

PS: Note that the paths in the Weather script(s)/configuration file need to be reconfigured for a different setup.

 

Credits

Figman (for Preliminary Design/Fonts Idea)
Didi79 (for Layout Idea)
Teo (for Weather)
VinDSL (for Calendar)

Sunday, March 24, 2013

Conky Configuration Guide


There have been tremendously detailed guides on configuring conky all over the internet. However, so much information can be confusing at times. And this universe of information can be especially intimidating for the people new to conky/linux. I felt the need to make a collection of useful and regularly updated resources to make the daunting task of configuring your conky a little easier.

From knowing nothing about conky, I have made use of some of these online resources to make my conky look like this:


Let's take it step-by-step.

1. Installation


The installation for various distros are well documented on the official conky webpage.

Debian/Ubuntu

At a terminal:
$ sudo apt-get install conky

Gentoo

Have no fear, Conky is in portage. You can install it with:
# emerge app-admin/conky
 
or, using Paludis:
# paludis -i app-admin/conky

Arch

Conky is available in pacman:
# pacman -S conky 

 FreeBSD

Conky is avaible in FreeBSD ports, check FreshPorts for details.

Foresight

For Foresight Linux or any other rPath-based distro:
# conary update conky=cookingwithroids.rpath.org@cwr:all

Compiling from source

You'll need the X11 development libraries, version 6.8.2 or later. package name is probably libx11-dev (on Debian/Ubuntu), as well as the development libraries for any additional features.

$ ./configure --prefix=/usr --enable-x11 --enable-mpd # see --help for a full listing of options

$ make 

# make install
The last step is optional, if you don't do this, the conky executable will be in src/.

2. Configuration


So you just installed a shiny new conky on your computer. But nothing seems to work. Why is that so? This is because conky needs a configuration file to tell it what to display. This is usually named as .conkyrc and it contains instructions about what information to display on your desktop and how. Understanding the configuration file may seem difficult at first but you get the hang of it in a couple of hours even if you have never done any programming before.

A good resource to tweak the configuration file according to your needs has been written by VinDSL on ubuntuforums. The link to the guide is:

VinDSL's Conky Configuration Guide


3. Additional Dependencies & Fonts


Most configurations make use of additional scripts/plugins/fonts. Examples of these include certain weather scripts, email checking scripts or scripts that fetch the current track information from your music player.

These scripts have to be downloaded separately, and their paths configured in the conky configuration files that make use of them. Sometimes, the scripts themselves need additional editing - but this is usually very simple and often involves just replacing certain fields like your email id & password or the link to your local weather conditions.

4. Weather


Okay, why do I need to mention weather separately? Because configuring this part may be trickier than others. It used to be easy before weather.com made drastic changes to their website. Most scripts made use of weather.com until almost an year back, when the website made it mandatory to register to fetch weather updates.

One of the best resources I have come across for this is by Teo. The complete thread is at the following link:

Teo's weather scripts using Accuweather/WUnderground/NWS/Weather.com

5. Additional Information/References


If you are already familiar with a little programming and do not wish to go through the lengthy guides mentioned above the Arch Linux Wiki on conky is a good place to start. It details a lot of things from fetching RSS feeds to configuring GMail in conky.

Arch Linux Wiki

Another useful and concise option is the conky variable list at the official webpage on sourceforge. This list is presented in the form of a table, with a short description of how each command works. A little familiarity with conky may be required before you jump to this one.

Conky variables list on Sourceforge

Happy Conky-ing!

Thursday, March 21, 2013

16 Awesome Conky Configurations

I have been a huge fan of Conky. For those of you who have no idea about it, here is what the "Setting up Conky" webpage has to say about it:
Conky is a system monitor for X originally based on the torsmo code. Conky can display just about anything, either on your root desktop or in its own window. Conky has many built-in objects, as well as the ability to execute programs and scripts, then display the output from stdout. 
Conky is available for various Linux distros. The beauty of Conky lies in the fact that it can put just about anything - emails, appointments, disk usage, processor speed, temperatures - on your Desktop and make it look awesome. There are tons of customized scripts and configurations available online. In this post, I present some of the best ones that I have come across.

Infinity by harshit1990

 
notifyOSD Conky by bigRZA


Cowon Conky by bigRZA


Conky, Conky, Conky by YesThisIsMe


Conky Config by didi79

 

Conky Lua by despot77


Conky Config by ashokgelal


Gotham Conky by psyjunta


"Rings" Meters for Conky by londonali1010

 




My Conky Config by londonali1010


Crunchbag Conky by quickdraw


Ballon conky by iacoporosso


Helix Conky by figman




Conky Launchpad by freeazy




Sunday, February 24, 2013

How to Solve the Ubuntu Webcam Problem

I currently use Ubuntu 12.04 as my primary OS and every now and then I need to use Skype/GTalk for a video chat with my friends and family. Recently I made some major changes to my OS installation - including removing a lot of unused packages. This subsequently led to my webcam not working in either Cheese or Skype/Pidgin.  Because I did not remove any related packages intentionally, my guess is that Ubuntu does it when I use autoremove.

To troubleshoot such problems, the first and most obvious step is to find out where the problem lies - hardware (faulty webcam) or the drivers. I opened up a terminal (Ctrl + Alt + T) and typed in lsusb.

user@pc: ~$ lsusb

The lsusb command lists all the USB devices connected to the computer. I got the following output:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 0bc2:5021 Seagate RSS LLC FreeAgent GoFlex USB 2.0
Bus 002 Device 004: ID 05a9:2640 OmniVision Technologies, Inc. OV2640 Webcam
Bus 003 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
Bus 006 Device 002: ID 046d:c05b Logitech, Inc. M-U0004 810-001317 [B110 Optical USB Mouse]
Bus 003 Device 003: ID 413c:8126 Dell Computer Corp. Wireless 355 Bluetooth
Bus 003 Device 004: ID 0a5c:4502 Broadcom Corp. Keyboard (Boot Interface Subclass)
Bus 003 Device 005: ID 0a5c:4503 Broadcom Corp. Mouse (Boot Interface Subclass)

This output clearly shows that my webcam is alive and kicking (on Bus 002 Device 004 - OmniVision Technologies Webcam). So this certainly means that it is not configured correctly or certain drivers are missing. I searched online for similar problems, and most of the answers relate to the infamous Skype problem. But my problem was different because even Cheese would not recognize my webcam. So I just checked for the packages libv4l and v4l-utils. They were missing! autoremove had fucked up. So I reinstalled these packages by using the following command in the terminal.

user@pc: ~$ sudo apt-get install libv4l* && sudo apt-get install v4l*

I used the wildcards(*) because I do not know which ones are required. I know Ubuntu has a way of installing the required dependencies but then again, relying on it had led to this problem in the first place. After installing the above mentioned packages, I restarted my laptop and voila - my webcam was up and running. So for all of you folks who have had a similar problem after an update or other changes to your system, try this method out.

EDIT : Sometimes the problem occurs because the webcam is mounted as video1 instead of the default video0. To be sure that this is the problem , open up a terminal and type in the following command to display the output of your webcam:

user@pc: ~$ vlc v4l2:///dev/video0

Alternatively, you can use mplayer to do the same job:
user@pc: ~$ mplayer -tv driver=v4l2:gain=1:width=640:height=480:device=/dev/video0:fps=10:outfmt=rgb16 tv://

Replace the video0 to video1 in the above commands if you receive an error message like this one (for vlc):
Your input can't be opened:
VLC is unable to open the MRL 'v4l2:///dev/video0'. Check the log for details.
This method is quite powerful and can be used as a sureshot method of finding out if there is a driver issue or not.

However, my problem is that the webcam freezes a few seconds after I launch it using Cheese/Skype/VLC/MPlayer. This seems to be a recurring bug with many users, and a kernel upgrade has been reported to fix this problem.

Wednesday, February 13, 2013

Create an All-in-One Boot USB Disk

Recently, A friend of mine was locked out of his Windows laptop due to a certain virus. While I have always found that the best anti-virus solution has been Microsoft Security Essentials, we are talking about the "cure" here rather than "prevention". I knew what was in store - I had to use a rescue disk and check the drive. And then (possibly) perform a repair of the Windows installation. If the above two processes didn't work,  I would have to use a Live CD to extract the important data and then format the HDD. The problem - I had only one USB drive! If I had to go through all of these steps, I would waste a tremendous amount of time just making different disks. Not to mention, I would require access to a running computer throughout.

Enter YUMI.With this brilliant tool, you can install multiple distributions on your USB drive. Moreover, it supports a huge list of anti-virus tools and system tools apart from the popular Windows and Linux distributions. It is extremely use this tool in Windows and it can run (without the format drive feature) in Linux through Wine. A detailed documentation along with a list of known issues has been provided on their  web page. Of course, a large USB disk is also required. I would suggest keeping at least the following on your All-in-One Boot Disk:

1. Operating System
Because I have a dual boot on my laptop with Windows 7 and Ubuntu 12.04, I have kept copies of both of these. The advantage of keeping Ubuntu is that it comes with a Live CD that will help you recover data in case of a major Windows meltdown. If you do not have any version of Linux installed and do not have enough space for Ubuntu on your USB disk, you can make use of the extremely small Linux distributions like Damn Small Linux (~50 MB) or TinyCore (~12 MB).

2. Antivirus Tools
These are a must-have because of all the vulnerabilities your Windows is prone to. Even with a fully functional antivirus on your computer, the importance of a rescue disk cannot be emphasized enough. For this the ISOs offered by Kaspersky, AVIRA and BitDefender are good options. Some people have complained about problems with using Kaspersky's Rescue Disk, though.

3. System Tools
These are good to have in case you want to partition hard disks, diagnose for certain hardware failures or to simply crack your computer's password for the forgetful ones. There are a lot of tools available for this purpose, the most popular ones being GParted, Ultimate Boot CD and OPhcrack. The number of tools offered for this purpose is so vast that it could be a separate blog post in itself.

There is also an ISO available called Hiren's Boot CD. It has a lot of tools included onto a Windows XP boot disk. Even though there have been certain references to it being illegal, I will not recommended it for completely different reasons. In my experience, this particular ISO comes with so many needless tools that it actually makes the recovery process more painful than a plain format and reinstall. Use this only if you don't have any clue about what is wrong with your computer.

Lessons learnt:
1. Always have an anti-virus installed on your Windows PC
2. Always keep a regular backup of your important data, either on an external drive or using a service like Dropbox/Ubuntu One/Google Drive
3. Always keep your OS partition separate from your data partition
4. An all-in-one USB disk makes a quick-fix repair easy and painless