Inspirated

 
 

March 15, 2009

HOWTO: Use USB devices in Virtual Machine Manager with QEMU

Filed under: Blog — krkhan @ 3:09 pm

Every once a while, I need to take the backup of my Nokia N72 using PC Suite. Since the task had to be performed on Windows, I expected my virtualized machine to be able to do so. Unfortunately, Virtual Machine Manager does not provide any option in its interface which would allow me to use my USB devices in virtualized machines. Going through the documentation though, here’s the method through which I was able to solve my issue.

First of all, you should have the vendor and product ID’s of the USB device you want to use. Sounds alien? Use the command:

[user@host ~]$ lsusb

Which will show you something like:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 003: ID 0421:04c4 Nokia Mobile Phones
Bus 003 Device 002: ID 09da:000a A4 Tech Co., Ltd Port Mouse
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

The bold numbers in the line containing “Nokia Mobile Phones” are the vendor and product IDs respectively. Once you’ve noted them down for your required device (in my case: 0x421 and 0x4c4), list the virtual machines’ configuration files:

[user@host ~]$ sudo ls /etc/libvirt/qemu

networks windoze.xml

My virtual machine was named “windoze”, so windoze.xml is the file that I need to edit:

[user@host ~]$ sudo gedit /etc/libvirt/qemu/windoze.xml

In the editor, add the highlighted hostdev lines under the devices section (replacing the vendor and product IDs with the ones noted down from lsusb output):

<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<hostdev mode='subsystem' type='usb'>
<source>
<vendor id='0x0421' />
<product id='0x04c4' />
</source>
</hostdev>

Save and close the file. Restart the service:

[user@host ~]$ sudo service libvirtd restart

If everything went smoothly, the USB device should now be accessible from within the virtual machine:

Screenshot of Nokia PC Suite connected to a USB device in virtualized Windows
(Click on the thumbnail for larger version.)

Tags: , , , , , , , , , , , ,

March 9, 2009

HOWTO: Access Windows machines by their names on Eee PC

Filed under: Blog — krkhan @ 8:25 pm

More often than not, Linux users will end up in a situation where they’d need to access their Windows neighbors on LAN. This can easily be accomplished using IP addresses, but using NetBIOS names is just too convenient to be overlooked.

The Xandros distro on Asus’ Eee PC does not resolve NetBIOS names by default. To make it perform that, you can do the following:

[user@host ~]$ sudo apt-get install samba samba-common smbclient winbind
[user@host ~]$ sudo kwrite /etc/nsswitch.conf

Once the editor opens, spot the line:

hosts: files dns

And append “wins” at its end, making it:

hosts: files dns wins

Save the file, exit the text-editor, back on command-line:

[user@host ~]$ sudo /etc/init.d/samba start
[user@host ~]$ sudo /etc/init.d/networking restart

Reconnect your network, and viola — easy peasy, Eee PC!

Screenshot of Eee PC accessing a Windows PC on LAN by name
(Click on the thumbnail for larger version.)

Tags: , , , , , , , , , , ,

March 6, 2009

Using Cisco Packet Tracer on Linux

Filed under: Blog — krkhan @ 6:15 pm

(Or: Using Wine where plain-water should have been more than enough.)

Packet Tracer is a network simulator for Cisco devices. Caveat: It runs only on Windoze. Hence, there are three possible solutions for someone in need of using Cisco simulation on Linux:

  • Wine: Wine’s setup varies from distribution to distribution. If you’re using Ubuntu, following commands should do the trick:
    [user@host ~]$ sudo apt-get install wine
    [user@host ~]$ winecfg

    Alternatively, for Fedora/RHEL/CentOS, use:

    [user@host ~]$ sudo yum install wine
    [user@host ~]$ winecfg

    Followed by:

    [user@host ~]$ wine /path/to/PacketTracerSetup.exe

    Once installed, you end up with:

    Screenshot of Packet Tracer running in Wine
    (Click on the thumbnail for larger version.)

    Pretty much usable. Although, fonts appear hideously ugly on default settings. Fortunately, you can change their sizes by going to Options >> Preferences >> Fonts from the Main Menu.

  • GNS3: Setting up this particular piece of software is considerably difficult and definitely an overkill for newbies. This blog attempts to bridge the difficulty by providing video tutorials for installation, but that does not make GNS3 any lesser intimidating for users not already familiar with Cisco terminology or network simulation. For example, you’ll have to scavenge the Internet for IOS images you want to use, something you’d never have to think about in Packet Tracer for its supported devices.
  • Pursue Cisco to release Packet Tracer on Linux: I was a bit surprised when I spotted that Packet Tracer is actually based on the cross-platform Qt GUI toolkit which would make porting it to Linux a trivial task for developers. Regrettably, knocking some sense in Cisco execs’ head is likely to be a far more laborious task than either of the solutions before.

“Sparrows who emulate peacocks are likely to break a thigh.” — Burmese Proverb Some geek Buddha annoyed at the trend of software developers relying on emulation for portability

Update: Cisco had after all started providing a native Linux version of Packet Tracer since last summer which I somehow missed because of its lack of appearances in my initial Google search. Here are the download links:

Fedora RPM: Rapidshare Part 1, Rapidshare Part 2
Debian/Ubuntu Installer: Rapidshare Part 1, Rapidshare Part 2
Linux Addons: Rapidshare

Tags: , , , , , , , , , , ,

March 1, 2009

Top Five Improved Open-Source Projects

Filed under: Blog — krkhan @ 3:55 pm

“Evolution is God’s way of issuing upgrades.”

It’s a wonderful age to live in as an open-source enthusiast. The warm feeling is especially accentuated in one’s mind after recalling countless hours of hair-pulling trying to make that goddamned VGA monitor work with Red Hat Linux 6. Software for GNU/Linux has improved at an exponential rate. There are still plenty which lack the user-friendliness and all, but technologically the overall rate of improvement has been nothing short of astounding.

Ask any newcomer to the GNU/Linux world about their favorite open-source projects, and there’s a strong likelihood that the answer will be one of the “prominent big-guns”; the likes of Compiz Fusion, Firefox, KDE or Gnome. Ask any veteran the same question and you’re much more likely to get a diverse stock of answers ranging from Vim to Anjuta or probably even some obscure Window Manager like Fluxbox. The opinion about the most “improved” projects would thus be highly polarizing. Still and all, there are few projects which have eased my life substantially with their progress. To compliment the ones that have almost made me kiss virtual bits of code at one point or other, I’ve decided to choose the top five:

  1. recordMyDesktop
    The Dark Ages: Recording a video of an X session was nothing less than a nightmare. With sound, all the more so. The popular method was to run a VNC server and then use a tool such as vnc2swf to capture the footage.
    The Messiah: Once you install recordMyDesktop and one of its GUI frontends, recording becomes as easy as launching it and selecting “Record”. Really, you don’t have to use multiple software now for doing something as simple as that.

  2. NetworkManager
    The Dark Ages: You went to your workplace, geared up your Linux distribution and tried get some connectivity and to your utter horror, the Wireless network used WPA encryption for passphrase. wpa_supplicant was the command-line utility you could’ve used for connecting to such networks after hours of tinkering around, but it sadly wouldn’t have prevented you from getting fired because the execs weren’t that much amicable with open-source evangelism in the first place.
    The Messiah: Red Hat, for all the criticisms it receives for RHEL, is still the caring patron figure for desperate Linux users crying out for help. Hence, it’s no co-incidence that this project as well as next two on the list were initiated by the same company. NetworkManager makes mobile connectivity as peachy as it could’ve been. You spend a few days with NM on your notebook and it starts choosing the best network for you wherever you go, that too with least possible intrusion in your workflow.

  3. SELinux Troubleshooter
    The Dark Ages: In this particular case, the dark ages don’t belong to that much a distant past since the cause of all the mess was also a recent innovation. Security Enhanced Linux, while obstinately preached by Red Hat and enabled by default on its shipped operating systems, was unanimously loathed by all system administrators who had at one point or other given up their hopes and had disabled it completely on their networks. The error messages it churned out on regular bases were not only cryptic, but also critically hampered regular everyday usage of their host operating systems.
    The Messiah: With improved default policies, the situation was somewhat resolved for general user. Nevertheless, irregularities still kept popping up occasionally and hence came SELinux Troubleshooter to the rescue. For every cryptic denial that SELinux now pops up, the Troubleshooter will analyze it and even suggest workarounds for them so that you don’t have to manually mess with policy modules every time something perfectly legitimate starts getting labeled as “unauthorized” access.

  4. PulseAudio
    The Dark Ages: The music player was playing a song and you tried having a voice-call or playing another video = epic fail. The audio device was usable by only one application at a time. In fact, sound was the Achilles’ heel for default setups of pretty much every Linux distribution that existed.
    The Messiah: Playing a soundtrack in one application with volume tuned to max and having a video run in another with volume at half is no longer a fantasy. And no, ESD doesn’t even come close to PulseAudio in “seamless” multiplexing of such sounds. If you want more, Pulse can combine multiple soundcards into one and also — hold your breath — redirect audio streams to different hardware on the fly.

  5. TrueCrypt
    The Dark Ages: Disk encryption had been an ultra-geek thing for quite a while, especially on Linux. Software that provided such features needed to have modules compiled manually and loaded into the running kernel which opened up a whole plethora of compatibility issues which almost always made newcomers decide against the whole idea per se.
    The Messiah: God bless the developer who had the idea of using FUSE in TrueCrypt for mounting encrypted containers. As a consequence, once a user has installed TrueCrypt, the whole thing doesn’t need to be recompiled again from time to time with updated kernels. Also, thanks to wxWidgets, the GUI has drastically improved too; making it easier for even Linux newbies to utilize disk encryption.

Fortunately, unlike commercial operating systems, GNU/Linux users don’t have to wait for decades before seeing actual new “innovations” in action. Who knows, maybe next year we’ll have LOLPython topping my list. Anything’s probable.

Tags: , , , , , , , , , , ,

November 29, 2008

Next Generation Intelligent Networks Research Center

Filed under: Blog — krkhan @ 7:27 pm

“Research is what I’m doing when I don’t know what I’m doing.” — Wernher von Braun

As soon as the next semester rolls over, I will be joining nexGIN RC as a research student. My task will be to participate in developmental efforts on the National ICT R&D funded project “An Intelligent Secure Kernel for Next Generation Mobile Computing Devices”. Here’s an excerpt from the project’s executive summary:

The project aims to develop secure kernel framework that enable self-monitoring, and consequently self-healing operation for an operating system of mobile devices. This is expected to produce a fully functional Secure Linux Kernel that will be run on tablet PCs / smartphones. The developed framework will be fully aware of system conditions and resource usage and will schedule different threads intelligently based on each thread/process’ behavior, thus providing a truly secure computing experience in which malware that manages to escape detection by intrusion detection systems gets thwarted in the scheduler.

From the looks of it, there will be substantial poking around Linux involved in this one. So even though my research area primarily revolved around back-heeled through balls, spoon-chip goals, splendid crosses, powerful curlers, Totti, De Rossi, Batistuta, Montella, Ibrahimovic and Cruyff until now, I’ll be trying to redirect the efforts towards kernel development. What could possibly be more fun? Oh yes, watching Roma top the Champions League Group A ahead of Chelsea, but digressing that much isn’t suitable for a single post ;) .

Tags: , , , , , ,

September 7, 2008

Flash-back

Filed under: Blog — krkhan @ 1:04 am

Once upon a time (or, “in before times, long long ago” according to South Park speak), I used to be a Flash developer. I even developed a half-useful extension called “External Text MX” circa 2003, which got a little bit popular too. I loved Flash and even found ActionScript to be an intriguing language for a learning programmer.

And then, slowly and gradually, I realized that Flash isn’t worth 10% of the hype it usually gets. I’m in no way trying to debunk the wonderful art produced by Flash developers. It’s wonderful. My realization was a direct consequence of the troubles I had with Flash as a user rather than as a developer. Flash, for all the great things it embodies on a particular version on a particular platform, is still a proprietary technology steered by an enterprise giant. I started using different architectures and operating systems than simply 32-bit Windozes and most of the time I felt like the efforts needed to get Flash running aren’t worth all the animations and sounds. The mere idea of something as vendor-specific as Flash “driving” the “next-generation” of something as general as Web was enough to make me scowl.

Flash fans usually try to argue that it did become a driving force behind Web 2.0 afterall, and come up with YouTube as the example supporting their claim. Actually though, I had been using major Web 2.0 sites (YouTube, Facebook, Slashdot) for about 2 years now without any Flash support. YouTube videos can easily be viewed without Flash plugin and other websites are careful enough not to rely on Flash for their business. During this period, I treated Flash plugin with contempt simply because Adobe have been epically unsuccessful for providing a working version for 64-bit Linux. I was aware of a method which allowed usage of the 32-bit plugin to work with the 64-bit platforms, but it turned out to be highly unstable and resource intensive with my initial efforts. This method involved installing a “wrapper” plugin named NSpluginwrapper in Firefox. My verdict: “totally not worth it”; up until just a few weeks ago, when I retried the NSpluginwrapper with Firefox 3 and the official Adobe Flash Player 9.0 r124 plugin. The result? Finally the PITA vs. worth ratio has been reduced significantly enough to guarantee its continued existence on my laptop. YouTube works wonders and even the sound gets played through PulseAudio like a charm. Too many animations do tend to crash my X.org server every once a while but I’m willing to spare this much for now.

Not to mention, I still immediately close any website which starts with a Flash-y intro ;-) .

Tags: , , , , , , , , , , ,

January 24, 2008

Finally, we’re two!

Filed under: Blog — krkhan @ 7:51 pm

“Two heads are better than one.”

Not everything is going perfect (I’ll get to that later), but it is an awesome feeling to be able to manage different windows on a 2048-pixels wide workspace.

Dual-Head Setup Photo #1 Dual-Head Setup Photo #2
Dual-Head Screenshot

(Click on the thumbnails for larger versions.)

The laptop is providing the VGA output using the Intel driver that’s included in X.org. However, to get the thing working, I had to edit my xorg.conf by hand. Here’s a list of things that work:

  • The workspace “stretches” across the two displays by using xrandr commands outlined on this page.
  • Applications get sliced across the display using Xinerama and as seen in the first two screenshots, even MPlayer’s x11 video output is perfectly happy with it.

And a list of things that don’t:

  • For some unknown reason (which I’m too chuffed right now to be bothered about), if I specify the display modes explicitly for my laptop LCD screen on line 49 of the xorg.conf linked above, my VGA stops getting a display. Nevertheless, even without specifying display modes, the LCD resolution gets set as expected (1280×800 and 1024×768 for single and dual heads respectively).
  • Xfce’s panel insists on sitting in the right-hand VGA only. Other people are reporting the same behavior for Gnome’s panel and AFAIK, there’s no workaround available at the time being.

I have yet to try a 2560×800 (1280×800+1280×800) configuration but the current resolution is still more than sufficient for some kickass photo/video editing. Also, debugging on one display while vim-ing in the other is a programmer’s paradise. Size does matter, after all.

Tags: , , , , , , , ,

April 6, 2007

‘Proof of concept’ virus for iPods running Linux

Filed under: Blog — krkhan @ 2:19 pm

Kaspersky Labs has ‘discovered’ that it is theoretically possible to infect Linux iPods with a virus. The amusing fact about the discovery is:

Podlosco cannot be launched without user involvement.

Once launched, the Podlosco virus scans the device’s hard disk and infects all executable .elf format files. Any attempt to launch these files will result in the virus to display a message on the screen, which reads “You are infected with Oslo the first iPodLinux Virus”.

What I fail to fathom is how on earth does creating an executable which infects other executable to display a message classify as a ‘discovery’? If that can be called a virus, here’s a much simpler one:

echo "You're being infected with the Idiotisco, the second most stupid Linux virus"
rm -rf ~

The Idiotisco virus is a ‘proof of concept’ that any moron running Linux can set executable bit on a file and run it to damage his system.

Disclaimer: The source code of Idiotisco virus is disclosed only for educational purposes. I will not be held responsible if it makes your system bleed or gets you fired from your job.

Tags: , , , , , , , , ,

April 5, 2007

HOWTO: ALSA line-in capture with MPlayer

Filed under: Blog — krkhan @ 5:34 pm

I had an MSI TV @nywhere Plus card, and although it worked perfectly under Windows, I never got its sound working on my Linux box. The main reason for it was that the TV-Tuner card outputted sound through a separate cable to ALSA-line in. One way of getting around the mess was to launch MPlayer for video, and then capture audio through this separate command:

arecord -D hw:0 -r 44100 -c 2 -f S16_LE | aplay -

The solution wasn’t only ugly per se, but was also quite annoying because of a second’s lag in audio. After some searching in the mailing list archives of MPlayer, I combined various tricks in the following command which did the magic (relevant switches are highlighted):

mplayer -tv driver=v4l2:width=640:height=480:outfmt=i420:alsa:adevice=hw.0:
amode=2:audiorate=44100:forceaudio:immediatemode=0
:norm=PAL tv://

The adevice, amode and audiorate are dependent on your tuner card, whereas the alsa, forceaudio and immediatemode=0 are mandatory if you’re trying to capture sound from line-in.

That’s it. Now I don’t have to boot to Windows every time I want to do some video-recording. The profusion of capturing options in mencoder compared to MSI’s bundled software comes as an additional bonus for me.

Tags: , , , , , , , , , ,

March 29, 2007

Dell promises pre-installed Linux PCs

Filed under: Blog — krkhan @ 4:50 pm

Although there were lots of rumors going around about Dell pre-installing Linux on their laptops ever since their survey had 70% voters voting in favor of the action, the masses weren’t given a definite response until now. Details of the pre-install are still unknown, but most probably they’ll go with either SUSE or Ubuntu (the former being blessed by Microsoft whereas the latter being more user-friendly).

So, will Linux finally start claiming some serious share in the desktop market? Not really. Or at least, not until other hardware manufactures e.g. HP and IBM start following Dell’s footsteps. The optimism meter of penguin fans will nevertheless be seeing a major boost.

Tags: , ,
« Previous PageNext Page »