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

Monday, August 15, 2011

Dual Boot Windows and Ubuntu (with Ubuntu installed first)

I use my laptop for a number of purposes, and gaming is not one of them, and it works just fine with Ubuntu 11.04 as the sole OS. However, I recently decided to let go of my desktop and realized my laptop was not ready as a complete replacement yet. Now, I had two options : installing Windows on a virtual machine using VirtualBox or setting up a dual boot. The first is a very good option, especially if you have enough RAM and a decent processor; and it also has the advantage of switching between the OS a breeze. However, with my limited resources, I settled on the second option.

The easiest way to set up a dual boot on a computer with Windows already installed is by Wubi. Setting up a dual boot on computer with Ubuntu installed is a little more complicated than that.


Here is what you will need:
1. Windows ISO OR Windows Installation CD/USB
2. Ubuntu ISO OR Ubuntu Live CD/USB
3. USB Drive
4. UNetbootin
Note: If you wish to install Windows 7, you can also use A Bootable USB to burn the ISO. It needs a Windows host, though.

Step1. Download the Ubuntu ISO and UNetbootin. The installation instructions for UNetbootin for both Windows and Linux are here. You may skip the manual download of the Ubuntu ISO as UNetbootin can also do the same for you. It is simply a matter of choice.

Step2. Run UNetbootin. Select Diskimage>ISO and enter the path for the Ubuntu ISO file. Alternatively, you may download the distribution of your choice directly from the internet. Then Select USB Drive as the Type and sdbX (where X is usually 1) as the Drive. Click OK.



Step3. Now, you need to have your partitions in place. With Ubuntu as the sole OS, there would typically be two partitions - Ubuntu Installation Partition and Swap. You would need to resize the Ubuntu partition using GParted to make space for a Windows installation - you can only do this using a Ubuntu Live CD/USB. Select the Try Ubuntu option and go to System>Administration>GParted to make the partitions.


The Ubuntu partitions are typically in ext3 or ext4. Windows and other shared partitions should be NTFS. For my computer, I have set up two 30 GB partitions for Ubuntu and Windows installations, and another 80 GB for the common data - Dropbox, Music, Documents, etc. The other 5 GB is in Swap.

Step4. Repeat the steps 1 and 2, with the Windows ISO instead of Ubuntu ISO. The size of the USB drive used in this step should be at least 4 GB.

Important: If you are just overwriting the same USB drive used in Step2, remember to copy the Ubuntu ISO in a common drive before proceeding. Windows CANNOT access the Ubuntu filesystem and you may have to re-download the Ubuntu ISO if you do not have a backup.

Step5. Now, restart your computer and ensure that the USB drive is given the highest preference in your boot sequence in the BIOS settings. Boot your computer using the USB drive and install Windows.

Step6. After Windows has been installed, you will realize that you are unable to access the Ubuntu partition. This is because Windows overwrites the MBR. At this point of time,you would require UNetbootin and the Ubuntu ISO again. Repeat steps 1 and 2.

Step7. To restore the MBR, we will make use of a free software called Boot-Repair. Boot your computer using the Ubuntu Live USB. Select the Try Ubuntu option and run the terminal. Type in the following commands in the terminal:

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update && sudo apt-get install -y boot-repair

Step8. Finally, fire up Boot-Repair and select First Repair and click Apply.


Bingo! The dual boot has been set up successfully on your computer. Now, you can merge your Dropbox, Firefox, Pidgin and Thunderbird profiles between Ubuntu and Windows so that your settings for chat and internet are always synced. The simplest way to do it is to set it up in Windows or relocating the profile from Ubuntu to Windows folder, as Windows cannot access the Ubuntu filesystem.

For Firefox, you can always use Firefox Sync or XMarks to sync all settings between different computers and also the different OS on the same computer. But, sharing a single profile is more convenient and logical for the same computer.

Monday, August 8, 2011

Log into your remote computer (even with a dynamic IP!)

Every now and then, I need to access my remote desktop at home for a variety of reasons - the file I wanted to access is not in my Dropbox folder, the torrent queue needs to be prioritized or just logging in just for the fun of it! Thankfully, there exist a myriad of solutions for this very problem - VNC clients and Microsoft's very own "Remote Desktop". However, we forget a very basic requirement for either of these to work - we need to know the external IP of our remote desktop.

Now, there are a number of options available - most ISPs provide an option for a static IP Internet connection, albeit for monthly premium. It is also possible to do it by registering for DNS services. These services work by installing a client on your remote computer that keeps mapping your IP to a more friendly name like mycomputer.myvnc.com. Although this is quite useful, I personally find it quite tedious because of the hassle of constantly logging into their site and enabling my account - some of the free ones require you to do that periodically. Not to mention, I could never get it to work like it should.

Here is an alternate, simpler and free solution to the problem and it makes good use of Dropbox! Here is what we will need:
- Dropbox
- VNC Server
- Windows Task Scheduler
- wget
- VNC Client


Step1. Install Dropbox your remote computer if you haven't already done that.
http://www.dropbox.com

Step2. Install a VNC Server on you remote computer. You can choose from Tight VNC, Real VNC, and the like.


Step3. Download wget from the link below and save the wget executable file in a Dropbox folder (for e.g. \Dropbox\IP Updater)
http://users.ugent.be/~bpuype/wget/wget.exe

Step4. Create a batch file in your Dropbox folder that runs the following command.
wget -q -O - http://whatismyip.com/automation/n09230945.asp > IP.txt

Step5. Now, open the Task Scheduler and create a task that executes the above batch file every hour.

Step6. Presto! Simply log into your Dropbox account from anywhere in the world and you will be able to keep a tab on the most recent IP of your remote computer.  Use this IP (in the IP.txt file) to log in remotely using Tight VNC/Real VNC client!

Although the above solution works for a Windows machine, it can be tweaked slightly to work for Linux/Mac as well.

Friday, April 15, 2011

Installing Ubuntu 10.10 Maverick Meerkat

Courtesy: Ubuntu Official Website

For all of you whose blood begins to boil at the very mention of Windows, its time for a change. And the most user-friendly alternative out there is Ubuntu. I would even go the extent of saying that Ubuntu is, in fact, better than Windows in terms of stability, security and cost. The Ubuntu community is vast, helpful, and constantly developing better alternatives. If you really cannot let go of Windows, you can always try a dual boot, which is made easier by installing Windows first and then using wubi.
For first timers, the Ubuntu website and the Ubuntu wiki, together form a great way to get started. The installation process is trivial, and most of it has already been documented. At this point I would just like to add that Ubuntu Desktop should be the one you should be aiming to install. Go for the Ubuntu Netbook version ONLY IF you don't have a decently powerful laptop or are really looking for that extra juice out of your battery.

What I intend to discuss here is the installation of Ubuntu using a pen drive, for which you should follow the steps below:

1. Download the version of Ubuntu you want to install. Get it from the official website or download via torrents. I prefer to download torrents as the chances of downloading a corrupt ISO are minimal.
For Ubuntu Desktop Edition:
http://www.ubuntu.com/desktop/get-ubuntu/download
http://www.ubuntu.com/desktop/get-ubuntu/alternative-download
For Ubuntu Netbook Edition:
http://www.ubuntu.com/netbook/get-ubuntu/download
http://www.ubuntu.com/netbook/get-ubuntu/alternative-download

2. Check the md5 sum of the downloaded file. The md5 checksum is a sure way of verifying if the downloaded file is error free.
More information and utilities to check md5sum:
https://help.ubuntu.com/community/HowToMD5SUM

3. If your pen drive is larger than 1 GB, you would want to partition it first. When I tried installing Ubuntu on my Dell Inspiron 1420, it would get stuck on "Preparing to install". It took me a while (a whole night, in fact ;)) to figure out that it was because of the pen drive itself. After making a primary partition of about 700 MB, the installer worked just fine.
An excellent guide to partitioning your USB drive:
http://www.uwe-sieber.de/usbtrouble_e.html#partitioning

4. Now download a suitable software to write the downloaded ISO to the primary partition of the USB drive. I used the Universal USB Installer from my Windows 7 machine.
More information on writing ISO to USB:
http://www.ubuntu.com/desktop/get-ubuntu/download


5. Now fire up your computer and enter the BIOS setup. Change the boot order to increase the priority of the USB drive to highest.
Guide to changing the boot sequence in your BIOS:
http://pcsupport.about.com/od/fixtheproblem/ss/bootorderchange.htm

6. And you're done! Reboot with the USB drive plugged in and choose Install Ubuntu. You can also try Ubuntu as a Live OS, before installing it on your computer. The best part of this is that you use your computer and browse the internet normally during the install. Now, that is cool!