Jun 172009
 

Introduction

I recently switched from using Linux’s KVM to using Sun’s VirtualBox for virtualizing a Windows XP guest on a Gentoo Linux host, and I have been quite pleased. The only feature that I don’t have working is clipboard-sharing, but that’s a problem for another day. Previously, I had major problems with sound using my EchoAudio Mia card. Ultimately, I used ALSA’s dmix plug-in to mix audio streams in software, before feeding it to the card. That worked great! However, VirtualBox was complaining about the new setup, and start-up was defaulting the audio component to “null”. In other words, my VM guest had no audio support!

Two problems, Two Solutions

The primary problem was that I had enabled the “esd” USE flag for my Gentoo system, which enables Enlightenment’s Enlightened Sound Daemon (ESD, or ESounD). Apparently, the latest version of SDL (libsdl) does not function properly in the ALSA environment, if the esd USE flag is set. Well, VirtualBox depends on SDL for audio support; consequently, my VM guest could not produce audio. The solution was to add the “-esd” USE flag to /etc/make.conf and rebuild the dependent packages (emerge -uDN world).

The second problem stems from my use of ALSA’s dmix plug-in. Although this works fine for playback, the dmix plug-in cannot be used for capture. Therefore, an environment variable must be set to specify an alternative capture source, like so:

# Unset any output customizations, use default
$ unset VBOX_ALSA_DAC_DEV
# Specify capture (analog-to-digital converter) device - can also be added to ~/.bashrc
$ export VBOX_ALSA_ADC_DEV="hw:0,0"
# Launch my Windows guest VM
$ VBoxManage startvm "Windows XP SP2"
# wait for it...
$ sleep 3
# check log for results:
$ grep -Pi '(alsa|audio)' VBox.log
VirtualBox Command Line Management Interface Version 2.2.4
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
 
Waiting for the remote session to open...
Remote session has been successfully opened.
00:00:00.808 [/Devices/AudioSniffer/] (level 2)
00:00:00.808 [/Devices/AudioSniffer/0/] (level 3)
00:00:00.808 [/Devices/AudioSniffer/0/Config/] (level 4)
00:00:00.808 [/Devices/AudioSniffer/0/LUN#0/] (level 4)
00:00:00.808   Driver <string>  = "MainAudioSniffer" (cch=17)
00:00:00.808 [/Devices/AudioSniffer/0/LUN#0/Config/] (level 5)
00:00:00.808   Driver </string><string>  = "AUDIO" (cch=6)
00:00:00.808   AudioDriver </string><string>  = "alsa" (cch=5)
00:00:01.090 Audio: Trying driver 'alsa'.
00:00:01.093 Audio: set_record_source ars=0 als=0 (not implemented)
00:00:01.095 ALSA: ADC frequency 44100Hz, period size 1024, buffer size 4096
00:00:01.099 ALSA: DAC frequency 44100Hz, period size 940, buffer size 3763</string>

Now I could hear audio output from my VM guest, simultaneously while listening to audio from host applications, and I could also capture audio!

Incidentally, I extended my default ~/.asoundrc file a little, although it did not seem to make a difference:

pcm.!default {
    type plug
    slave.pcm "dmix"
}
pcm.dsp0 {
    type plug
    slave.pcm "dmix"
}
ctl.mixer0 {
    type hw
    card 0
}

References

  1. http://forums.virtualbox.org/viewtopic.php?f=7&t=18835
  2. http://forums.gentoo.org/viewtopic-p-5714588.html#5714588
  3. http://www.virtualbox.org/ticket/1908
Share
Jun 162009
 

Introduction

Previously I blogged about using Alsa with EchoAudio’s Mia 96-kHz / 24-bit prosumer audio card. However, I have since experienced one nagging problem: Only one application can use the sound card at a given time! It is impossible for two or more applications to share the sound card. For a second application to use the Mia, the first app must be closed before the second is opened; otherwise, the first one will maintain a lock, blocking the second.

Many newer sound cards included integrated mixers, which allow multiple applications to simultaneously produce sound. Older sound cards depended upon software to perform the mixing. ALSA includes the “dmix” plug-in, which performs this very task.

ALSA DMIX Configuration

Typically, dmix is used automatically by ALSA, whenever it detects a sound-card without built-in mixing. Unfortunately, the ALSA driver for the Mia reports the card as having mixing capability, which it does not. Therefore, we must manually direct ALSA to use the dmix plug-in by default. ALSA is generally controlled through the “asoundrc” file, which can exist at the system or user level:

/etc/asound.conf
/home/my_user/.asoundrc

Several tutorials and HOWTO’s exist to set up ASLA’s dmix plug-in; however, these proved overly complicated, as I simply use:

$ cat /home/my_user/.asoundrc
pcm.!default {
    type plug
    slave.pcm "dmix"
}

This directs all applications to use the dmix plug-in by default. Now I can simultaneously play sound from multiple applications and without having to open and close each application in sequence!

System ALSA Configuration

Just for reference, my system’s ALSA configuration seems to use DMIX by default; however, it has never worked for me. I am including it here, just for reference:

$ cat /etc/asound.conf
pcm.swmix {
    type dmix
    # any unique number here
    ipc_key 313
    slave {
        pcm "hw:0,0"
        # these settings may require tweaking for different sound
        # cards; this is for the Powerbook's built-in snd-powermac
        # probably not required at all for well-behaved cards...
        period_time 0
        period_size 1024
        buffer_size 8192
        # mentioning rate fixes wrong speed/pitch in native ALSA stuff
        rate 44100
    }
}

# this makes OSS emulation via aoss default to using dmix, allegedly
pcm.dsp0 {
    type plug
    slave.pcm "swmix"
}

ctl.mixer0 {
    type hw
    card 0
}

# this makes native ALSA apps default to using dmix
pcm.!default {
    type plug
    slave.pcm "swmix"
}

Conversation with Giuliano Pochini

Giuliano Pochini is the author of the ALSA driver for the EchoAudio Mia. Recently, I posed my problem to him, as follows:

I am using your ALSA driver for the EchoAudio Mia PCI card. You have done a fantastic job! I really appreciate it.

One question: I am only able to use one application at a time to produce sound. If I want to produce sound in another application, I must close the first application, and then open the second.

Is it possible to have more than one application simultaneously produce sound through the Mia?

Should I use ALSA’s dmix plug-in, or is there a better solution?

To which, he kindly replied:

That card has 8 voices and 4 outputs. The vmixer controls how the voices are sent to the outputs. If your application uses default: or hw:x.0.0 or plughw:x.0.0 then it can use a single 1 to 8 – channels output. You have to use dmix to make alsa-lib mix the sound coming from differents apps. Otherwise you can manually configure your apps to use plughw:0.0.0, plughw:0.0.2, plughw:0.0.4 and plughw:0.0.6 and use the vmixer to route them to the ouptus as you prefer.

There is another way which requires some non trivial changes to the driver: make it automatically select the first free stereo pair when an application opens a substream. Drawbacks are that apps wouldn’t be able to open non stereo substreams anymore and that changing the volume would become problematic because you couldn’t know what channels have been assigned to each app. And, of course, there are only 4 stereo pairs available, all with the same sample rate, so dmix and resample are likely to be necessary anyway.

References

  1. http://alsa.opensrc.org/index.php/.asoundrc
  2. http://alsa.opensrc.org/index.php/AlsaTips#Share_a_single_card_with_multiple_applications
  3. http://alsa.opensrc.org/index.php/DmixPlugin
  4. http://alsa.opensrc.org/index.php/Hardware_mixing%2C_software_mixing
  5. http://www.alsa-project.org/main/index.php/Matrix:Vendor-Echo_Corporation
  6. http://www.alsa-project.org/main/index.php/Matrix:Module-mia
  7. http://www.webalice.it/g_pochini/ead
  8. http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
Share
Apr 142009
 

Introduction

Some time ago, I blogged on missing, or broken icons in Gnome’s Evolution, when used in the KDE desktop environment, running on a Gentoo box.  Since then, I have migrated to KDE 4.2, and I have once again experienced the same problem.  I tried using each of the icon themes installed on my system, but none of the themes were complete.  Each one was missing icons – some more, others less.  Incidentally, the new “oxygen” theme seemed the most complete.

I submitted a bug report to Gentoo’s bug tracking site and received the following answer.

Solution

Here’s the workaround provided by Timo Gurr:

$ rm ~/.gtkrc-2.0
# emerge gtk-engines
# cp /usr/share/themes/Clearlooks/gtk-2.0/gtkrc /etc/gtk-2.0/gtkrc
# DIY:
     Edit /etc/gtk-2.0/gtkrc
     Add: 'gtk-fallback-icon-theme = "gnome"' as the first line.

Then restart Evolution.

This worked great for me! Hopefully, Gentoo will update portage include this procedure for the evolution, gtk, or gtk-engines packages in the future.

Share
Apr 142009
 

Introduction

For some time, I have casually noticed that Gnome’s Evolution was not spell-checking my email messages.  Most other email clients, text editors, and even modern web-browsers, at least check your spelling as you type, underlining misspelled words with red wavy lines.  Evolution has this capability, but it was not enabled on my system.  Here is how I enabled spell-check on my Gentoo system for Evolution.

Solution

Gnome’s Evolution is dependent upon external spell checkers to perform this function.  Popular open-source checkers include ispell, aspell, and hunspell.  Aspell is newer than ispell, and was designed to replace it, at least according to aspell’s web-siteHunspell is an up and coming spell-checker, based on MySpell and backwards compatible with its dictionaries.  Apparently, Hunspell is used in many popular projects, such as:  OpenOffice, Mozilla Firefox, Mozilla Thunderbird, Opera, and Google Chrome.

All of these above spell-checkers are developed to be language independent; therefore, you also must also install a language specific “library” or “dictionary” to complete the installation.

Evolution appears to use aspell.  However, I installed all 3 spell-checkers and English dictionaries for each checker, plus a few other utilities, like so:

# emerge -pvt app-text/aspell app-text/gnome-spell app-text/ispell \
app-text/spellutils app-vim/vim-spell-en dev-perl/Text-Aspell dev-perl/gtk2-spell \
dev-python/gtkspell-python app-dicts/aspell-en app-dicts/myspell-en

Check to make sure you satisfied with the proposed installations, and then commit:

# emerge app-text/aspell app-text/gnome-spell app-text/ispell \
app-text/spellutils app-vim/vim-spell-en dev-perl/Text-Aspell dev-perl/gtk2-spell \
dev-python/gtkspell-python app-dicts/aspell-en app-dicts/myspell-en

After emerging the above packages and restarting Evolution, I was able to select dictionaries and enable the “Check as you type” feature by navigating here:

Evolution -> Edit -> Preferences -> Composer Preferences -> Spell Checking

Now I had nice red wavy lines everywhere! 🙂

BTW, I did encounter a problem where some of my dictionaries or checkers became corrupted, so I had to re-install (re-emerge) all of the above packages to fix the problem, even though I had previously installed these packages.

Share
Feb 122009
 

Introduction

There are just a few applications that keep me tied to Microsoft Windows.  For work, there is primarily one, and it’s a bigee!  Microsoft Office, especially Outlook.  We have looked at a few other solutions previously that mitigate this problem by running Office on top of either Wine (a Windows emulation layer) or KVM (a Virtual Machine with a Windows installation).  However, I wanted something more complete.  I wanted a native client that could access my corporate email and calendar on a Microsoft Exchange server.  As far as I know, at this point in time, there is only one client that would claim such functionality – Gnome’s Evolution.

Installing Evolution with the Microsoft Exchange Connector plug-in is not so bad.  Under the hood, it’s a bit of kludge, accessing your email through Exchange’s HTTP interface, but hey, it works!  🙂  The big question is, “How do I import all my Outlook data, archived in local PST files?

Unfortunately, PST is a proprietary Microsoft format (I know, you are shocked), and the only way to access it is through a proprietary Microsoft library (mapi32.dll or mapi.dll) that only exists on a Microsoft Windows installation.  (I know, again, you are flabbergasted.)

There are 3 types of solutions that I found to migrate and liberate your email.  None of them are trivial.  Yuck!  😥  All of them are potentially time-consuming, especially if you have lots of data, but here are a few pointers.  🙂

Solution #1:  Migrate Through Mozilla Thunderbird on Windows

Assuming you still have access to your Windows machine that is running Outlook, you can install Mozilla Thunderbird on the same machine.  The advantage being that Thunderbird can use the proprietary library to import your Outlook email!

The importing process if fairly simple.  Roughly, it is:

  1. Install Thunderbird, and uses its import wizard to suck in your Microsoft Outlook email and contacts.
  2. Close Thunderibrid.  Find where it stored the email, usually in a place like:
    C:\Documents And Settings\<USERNAME OR DEFAULT>\Application Data\Mozilla\Profiles\default\XXXX\Mail\imported.mail
    where, XXXX is some random collection of letters and numbers.
  3. In Evolution, import each email folder (named after the email folder, saved as an extensionless file by Thunderbird in the MBOX format) — one at a time!  Yikes!

As you can see, there are a few problems here:

  1. You have to process each folder one at a time!  Very time consuming, tedious, and boring…
  2. You cannot have nested folders, especially with email in a folder with additional folders.  Thunderbird’s storage format (MBOX) is standard, but old.  In fact, it has been “hacked” to support nested folders.  That was not part of the original idea.  Anyway, things can get messy if you have lots of folders, especially nested folders with messages and sub-folders in the same folders.
  3. Furthermore, this does not really address your calendar.
  4. Some people have reported that Thunderbird drops some of their email!!!!

I gave up on this method somewhere between problem #1 and #2.  … This could still work for you, and it does for many people, provided you either don’t have many folders or you don’t mind lots of pointy-clicky.  😉  If you go this route, make sure you count the number of messages in each folder inside Outlook and verify those counts once you import your email into Evolution.  You don’t want to lose any email.

Solution #2:  Migrate Through Outport on Windows

This solution is very similar to the above solution, except it uses an open source tool, Outport, to migrate your email on a Windows machine.  Consequently, I believe it has the same limitations.  It may be able to migrate calendar, but I still don’t like the idea of having to import my email into Evolution one MBOX file at a time.

Plus, Outport seems to have not been updated since 2003.  That’s worrisome, but maybe it’s no big deal…  Anyway, I wanted something easier.

Solution #3:  Migrate via an IMAP server

You may be thinking, “What?  This is easier?”   Well, it was to me.  🙂

An IMAP email server not only supports providing messages, but it also supports uploading them.  In most email clients, you can add an IMAP based email account and then simply “drag-and-drop” your email or folders from your local computer to the IMAP server, or vice-versa.

The basic idea of this method is roughly this:

  1. Setup or procure access to an IMAP server. (You have friends, right?  Gmail provides IMAP support too.  ;-))  You will need to know the machine name, possibly the port number, account id, password, and authentication method (plain text, SSL, TLS, etc.).
  2. Add this server as an IMAP account to Outlook.
  3. Drag and drop all your email to the IMAP account.  (You may not be able to put folders inside the “Inbox”, but you can add them to the “root” of the account.)  I know this is still “pointy-clicky”, but it’s much less than the other methods.
  4. Close Outlook.
  5. Open Evolution.
  6. Add the same IMAP server as an account in Evolution.
  7. Drag and drop all your email from the IMAP account to your local store on Evolution.  Done!  Tada!!!  🙂

If you are worried about setting up an IMAP server, I have some basic instructions listed below.

Migrating Contacts

You can export your contacts in Outlook to CSV files or other formats, which you can read into Evolution.  Thunderbird can also read them and export them into other file formats, if you wish.  No biggee here.

Migrating Calendar Entries

This can be more problematic.  If you are like me, you may not have many entries, so I simply moved my calendar entries back up the Exchange server, using it as a temporary staging area.

Others have suggested exporting the Calendar entries up to Google’s Calendar and then back down to Evolution in iCal format.  Sounds good, but I can’t offer any experience on this method.

Setting Up A Temporary IMAP Server

I did not want to transfer all my email via Gmail’s IMAP server for lots of reasons (bandwidth, privacy, possible sub-folder complications, etc.).  So, I decided to set up my own local IMAP server on my Gentoo Linux box.  Here’s a few quick pointers, if you decide to do the same.

Install dovecot’s IMAP server:

emerge dovecot

Verify the configuration is set up to use the “maildir” format, not MBOX.  The “maildir” format was created by the qmail folks, and it has several advantages over the older MBOX format, including native sub-folder support.  Here are the important configuration changes that I had to make in /etc/dovecot/dovecot.conf. You may want to verify or research these further:

# Config file = /etc/dovecot/dovecot.conf
# This is required to enable network access - otherwise, it may be restricted to localhost only
listen = *, [::]
# This enables plain text passwords.
# This is not good on a public network, but works fine for private LAN's.
# And, it simplifies the login process in Outlook and Evolution.
disable_plaintext_auth = no
# This sets the mailbox format to 'maildir', and it stores the mail
# in your user's homespace on the IMAP server, avoiding
# various file permission problems on the remote box.
mail_location = maildir:~/.maildir

Then you fire up the dovecot server:

# /etc/init.d/dovecot start

And, away you go!

Conclusion

It’s not a pretty process, but if you bang your head on it long enough, you’ll get through it!  🙂  Just remember, freedom awaits all those who persist!  😀  Good luck!

Share
Feb 122009
 

Problem

Recently, I switched to using Gnome’s Evolution for my email and calendar groupware client on my Gentoo Linux workstation.  I encountered multiple problems that had to be worked.  One of the more noticeable and annoying problems was the messed up icons.  All of the button icons were pictures of blank paper with a red X in the middle, similar to a “file not found” icon.

Gnome Evolution with broken icons.

Apparently, this is a fairly common problem on new installs where people primarily use KDE and not Gnome.  Here is a collection of solutions that may help.

Solutions

Do you have any gnome icons installed?  Make sure you have at least gnome-icon-theme and hicolor-icon-theme installed.  For Gentoo, this is performed, like so:

# emerge gnome-icon-theme hicolor-icon-theme

Do you have read access to the installed icons?  For whatever reason, the installed icons occasionally lose their read permission.  As root, or using sudo, you need to ensure the appropriate permissions, like so:

# chmod -Rf a+rX /usr/share/icons

Have you configured all your Gnome-based tools, including Evolution, to use an installed icon theme?  As your standard, desktop user (not root), check for the existence of this file:

$ cat ~/.gtkrc-2.0

If it does not exist, or if it does not specify an icon theme, you need to add one, like so:

$ echo gtk-icon-theme-name=\"gnome\" >> ~/.gtkrc-2.0

Restart your Evolution email client and enjoy your pretty icons!  Red X’s be gone!!!  🙂

References

Gnome Evolution with proper icons

Share
Dec 052008
 

Introduction

Every computer you buy or assemble comes with some decent integrated sound card.  A while back (~2000), I bought a “prosumer” (entry-level professional) sound card, the Mia by EchoAudio.  It was a pain at first, because the Windows drivers for XP were just not mature.  However, after about 6 months of updating drivers every other week, I finally got a rock-solid sound card that blew the doors off any integrated sound card I have used, even up to this day (12-2008).  All the integrated cards sound so “tinny” and “weak”, compared to the rich, full sound of this card.

For some time, I have avoided moving my main workstation to Linux, in some measure, due to the lack of drivers for this sound card.  However, a few weeks ago, I noticed an entry for the EchoAudio Mia in the kernel config!  Here is how I managed to get it working on Gentoo Linux.

Default ALSA Installation

The most modern sound system on Linux at this time is ALSA.  The Gentoo wiki page for installing it is here:

http://www.gentoo.org/doc/en/alsa-guide.xml

One important note:  ALSA can be compiled into the kernel or compiled separately as loadable modules.  Currently, Gentoo has mostly abandoned the in-kernel approach (which uses the alsa-drivers package), and it now uses the loadable module approach.  There’s no reason to buck the system here, so we are going to use the loadable module approach.

When you activate the appropriate ALSA kernel options, make sure you include the driver for the EchoAudio Mia, or whatever Echo Audio product you may be using.  Otherwise, you can follow the above guide up to the point where you are ready to run alsaconf.

Make sure you:  Recompile the kernel.  Copy it into place.  Update grub.conf.  Reboot.  You know the drill.  🙂

Modified ALSA Installation for Mia

The Mia driver depends on alsa-utils, but it also needs other ALSA packages, which are not necessary for other integrated sound cards, like hda-intel.  Furthermore, the default make.conf flags do not include the Mia components.  To include these, and to use the latest version of ALSA ;), let us first add a few keywords and compile flags to the ALSA build configuration:

Now, we are ready to install ALSA, again, in addition to the other necessary packages:

# Use latest version of everything ALSA
$ echo -e "media-sound/alsa-tools ~amd64\nmedia-sound/alsa-utils ~amd64\nmedia-sound/alsa-firmware ~amd64\nmedia-sound/alsa-headers ~amd64\nmedia-libs/alsa-lib ~amd64" >> /etc/portage/package.keywords

# Include Mia during ebuilds
$ echo 'ALSA_CARDS="mia"' >> /etc/make.conf

# Check for weirdness:
$ emerge -pvt alsa-utils alsa-tools alsa-firmware alsa-lib alsa-headers

# Build!
$ emerge alsa-utils alsa-tools alsa-firmware alsa-lib alsa-headers

Now update the ALSA configuration using alsa-conf, and you should be good to go!

$ alsaconf

Other Tips

The best mixer to use is the echomixer, which is made for the EchoAudio products, like the Mia.

In the default configuration, most everything is muted, so you will have to slide up the appropriate sliders.  Just be careful not to overdrive the card.  Stop at “0 dB” or less.  Do not slide it up to “+6 dB”; otherwise, you get a fair amount of distortion.

Other pages that mention the “alsa-drivers” package are based upon the “IN-KERNEL” approach.  Those instructions are not compatible with these.  Be careful if you decide to “mix and match”.

References

  1. ALSA’s EchoAudio development status – http://www.webalice.it/g_pochini/ead
Share
Dec 052008
 

Introduction

Regrettably, there are some software applications that just run better on Windows, specifically, Windows XP.  Of course, Windows runs better on Linux, so I guess we can still hold to our axiom that “All things run better on Linux”. 😯 Ok, not really.  😀

In my case, I would like to run the full Office 2003 suite on Linux.  Using Wine is an option, but it can be a bit buggy.  CrossOver is a better option, but it costs money, and I am cheapskate.  Plus, it’s like “double-taxation”.  I have to pay somebody a tax, so I can pay my Microsoft tax.  That ain’t right!  Well, I am not really a Linux purist – I am just a practical cheapskate.  And, I would like to learn about OS virtualization, and apparently, so do you!  Otherwise, you would not be reading this.  😉

Installing KVM on Gentoo

KVM is just one of many possible virtualization methods, which is a way to run one OS inside of another OS.  (Imagine a “window” that is running Windows XP inside, and it “thinks” it is the entire computer.  It does not realize that it is running inside of another “computer”.)

Note:  These instruction are for:

Host:  Gentoo 2008.0
RAM:  >= 1.5GB
Kernel:  2.6.27
KVM:  v79
Guest:  Windows XP Pro

Of course, there these instructions may have to be varied slightly to accommodate your exact application.

Here are my modified instructions, based on the Gentoo Wiki:

1. Update the kernel with IN-KERNEL KVM (no need for module mayhem):

$ cd /usr/src/linux
$ make menuconfig

[*] Virtualization --->
        --- Virtualization
        <*> Kernel-based Virtual Machine (KVM) support
        <*>   KVM for Intel processors support
        < >   KVM for AMD processors support
        <*>   PCI driver for virtio devices (EXPERIMENTAL)
        <*>   Virtio balloon driver (EXPERIMENTAL)

If you want to be able to do networking, you should also enable VLAN bridging and tapping, while you are here:

Device Drivers --->
    [*] Network device support --->
            <M> Universal TUN/TAP device driver support

Networking --->
    Networking options --->
        <*> 802.1d Ethernet Bridging
        <*> 802.1Q VLAN Support

Copy new kernel into place.  Update grub.conf.  Reboot using new kernel. … You know the drill. 🙂

2. Ensure the latest version of KVM:

$ echo 'app-emulation/kvm ~amd64' >> /etc/portage/package.keywords

3. Activate useful USE flags:

$ echo 'app-emulation/kvm gnutls sdl' >> /etc/portage/package.use

4. Check emerge for weirdness and install:

$ emerge -pvt kvm usbutils bridge-utils usermode-utilities

These are the packages that would be merged, in reverse order:

Calculating dependencies... done!
[ebuild   R   ] sys-apps/usermode-utilities-20040406-r1  0 kB
[ebuild   R   ] net-misc/bridge-utils-1.4  0 kB
[ebuild   R   ] sys-apps/usbutils-0.73  USE="zlib -network-cron" 0 kB
[ebuild   R   ] app-emulation/kvm-79  USE="alsa esd gnutls modules ncurses sdl -havekernel -pulseaudio -test -vde" 0 kB

Looks ok to me.  Does it look ok to you?  Let’s go:

emerge -pvt kvm usbutils bridge-utils usermode-utilities

5. Setup access for non-root users:

For each non-root user, add them to the KVM group:

gpasswd -a <non-root-userid> kvm

Launching Guest for First Time and Installing Windows:

First, you need to create an “image” file, which will contain the entire Windows XP guest OS (think C:\ drive).  Here’s the default way:

kvm-img create winxp_raw.img 30G

This will create a RAW image format that is 30 GB in size.  This is the simplest and most portable image format.  However, it is not the coolest!

kvm-img create -f qcow2 winxp.img 30G

This does the same thing, but it uses the latest QEMU format, which enables additional features, like image overlays.

Second, if you use ALSA for your host’s sound, then you can enable it like so:

export QEMU_AUDIO_DRV=alsa

Third, install Windows XP into image.  Here’s the simplest method:

kvm -hda winxp.img -cdrom /dev/cdrom1 -boot d

This will do the same thing but it will use a local image of the install ISO (faster?), use 1GB of RAM (default is much less), use host’s local clock (helps Windows see the right time), emulate better VGA card (more colors and resolution), and allow access to 2 processors:

kvm -hda winxp.img -cdrom /winxp/ISO/WINXPSP2.ISO -m 1024 -localtime -vga std -smp 2 -boot d

Using The Virtualized Guest Windows XP

The emulated “box” will reboot once as part of the Windows XP installation process.  After it comes back up, you should be good to go!  You can now download programs, install programs, update the install, etc., just like you would with a regular Windows XP installation.  Of course, there will be some limitations, because the emulated hardware is not exactly feature-rich.

At some point, you will “shut down” the emulated Windows XP machine.  To restart it, use the a similar command – with the exception of not booting from the install disk (or ISO):

kvm -hda winxp.img -cdrom /dev/cdrom1 -m 1024 -localtime -vga std -smp 2

Accessing Host Drives

To access a local partition, first ensure that samba is installed – not running – just installed.

Then, simply add the path to the mounted partition, like so:

kvm -hda winxp.img -cdrom /dev/cdrom1 -m 1024 -localtime -vga std -smb /path/to/dir

Otherwise, you can add the share name, if you have samba already running and properly configured, like so:

kvm -hda winxp.img -cdrom /dev/cdrom1 -m 1024 -localtime -vga std -smb <share_name>

Inside the Windows guest OS, the mounted share is available at:

\\10.0.2.4\qemu

Also, from inside the guest OS, you can SSH, SCP, SFTP, FTP, or telnet to the host, depending on running host services, using this IP:

10.0.2.2

Other options are listed on the Arch Linux Wiki.

Using Overlays

I have found that this process is not entirely stable.  Some combinations of host hardware, host OS, emulated hardware, and guest OS, work better than others.  If I tried to emulate too much hardware, the Windows XP installation would crash, so I typically had to install using the most modest, simplest emulation.

Also, I found that this process could be slow during “boot-up” and “installation”.  Maybe disabling ACPI emulation would help?

Anyway, you can quickly make a wrong turn and wreck your “virtual machine”, basically ruining your created image, in which you spent so much time setting up and installing.  Fortunately, there are 2 techniques to help mitigate this annoyance.

One, with the emulator shut-down, simply copy the image file to another location or file name to back it up, like so:

cp -fp winxp.img winxp_orig_install.img

Then you can always copy the good install back over a broken install, like so:

cp -fp winxp_orig_install.img winxp.img

Ta-Da!  Of course, the downside of this approach is rampant disk-usage.  You need double the disk space, possibly more, depending on how many backups you make.

Another technique is using “overlays”.  You can create an “overlay” of a good image like so:

kvm-img create -b winxp.img -f qcow2 winxp_20081225.ovl

Then you can boot from the overlay, just like you would any other image, like so:

kvm -hda winxp.ovl -cdrom /dev/cdrom1 -m 1024 -localtime -vga std -smp 2

The overlay contains a “diff” of the new state and the original image, so it is much smaller, since it only contains what changed. If the overlay gets corrupted, you can simply delete the overlay, create another, and go again!

You can also stack overlays, but I think this can waste diskspace too, and it requires that you keep the whole “stack” in place.  Pull out one overlay in the stack, or just move it, and the whole thing tumbles down!  🙁

Based on a tip from Bryan Murdock’s blog for resizing image files, you can combine an overlay stack into a new, single, independent image file, like so:

# create a new image file, which will be the consolidated image
kvm-img create -f qcow2 winxp_new.img 30G

Download the latest clone-zilla LIve-CD (or DVD) ISO.

http://www.clonezilla.org

In a KVM session, boot from the downloaded ISO, and include your original overlay as HDA and your new image as HDB, like so:

kvm -cdrom clonezilla-live-1.2.1-17.iso -hda winxp.ovl -hdb winxp_new.img -m 1024 -vga std -boot d

Generally, you should accept the defaults, unless you know what you are doing, and of course, you do. 😉  The key is to choose the option for a “device-device disk/partition to disk/partition” clone, or something to that effect.  (I don’t remember the exact wording.)  Make sure you copy the complete contents, including the MBR.  Your source is HDA, and your target is HDB.  … The cloning takes a while.  After it finishes, be sure to halt, and then start up a new KVM session, using the new image file:

kvm -hda winxp_new.img -cdrom /dev/cdrom1 -m 1024 -localtime -vga std

Try hiding the original image and overlay files to see if it works.  It should!

Other Things

The default network setup is good for surfing the web, downloading stuff, and checking email.  However, if you want other devices on your LAN to “see” the guest OS as another machine, you will have to create a bridge and tap.  This gets a little more complicated.  See the references below for more details.

If the installation or something crashes, try restarting the machine – but, don’t boot from the installation disk.  Many times the install process completed “good enough” before crashing.  😮  Yeah, I know.  It smells funny to me too, but it works.  🙄  Just be sure to keep lots of backup copies of your images or overlays.

References

  1. http://en.gentoo-wiki.com/wiki/KVM
  2. http://kvm.qumranet.com/kvmwiki/HOWTO1
  3. https://help.ubuntu.com/community/WindowsXPUnderQemuHowTo
  4. https://help.ubuntu.com/community/KVM
  5. http://bryan-murdock.blogspot.com/2007/12/resize-qemukvm-windows-disk-image.html
  6. http://www.linuxjournal.com/video/run-your-windows-partition-without-rebooting
Share
Oct 302008
 

HOWTO Connect a Linux computer to an HP PhotoSmart C7280 Printer

The HP PhotoSmart C7280 All-In-One printer contains a photo printer, scanner, and fax machine.  It can be setup as a wired Ethernet print server, wireless 802.11g print server, or a local USB printer.  It is very nice, and if you watch the NewEgg specials, you can often find one for a very good price every so often.  I have enjoyed using it from my Windows workstation; however, since I have the C7280 connected to my network through its Ethernet port (a wired print server), I would like to be able to use my Linux laptop to also print to it.

Fortunately, most HP printers are well supported in Linux.  So, I had high hopes!

As mentioned in other posts, my current favorite distribution of Linux is Gentoo, so my directions will be for Gentoo; however, you can probably adapt them to your favorite distro.

CUPS

CUPS is the modern Unix/Linux printing interface.  It provides both a server and client for the common printing tasks (lpr, lpq, lpstat, etc.).  Therefore, CUPS must be installed before you can do anything else.

I added a few extra USE flags to my CUPS install, although I don’t think these are necessary in general:

$ echo 'net-print/cups dbus ppds' >> /etc/portage/package.use

Beyond that, installation is simple:

$ emerge cups

Since we are connecting to the C7280 via the network, no configuration changes are required for CUPS.  However, you will have to fire up the CUPS daemon and add it to your start-up services:

$ /etc/init.d/cupsd start
$ rc-update add cupsd default

You can find more info on configuring CUPS to work on Gentoo with other setups here:

http://www.gentoo.org/doc/en/printing-howto.xml

HPLIP

The HP printer drivers are based on a standard HPLIP package, which is used with all modern HP printers, and a PPD file, which is specific to your printer model.  The latest HPLIP package can be installed in Gentoo, like so:

# For AMD64, Intel Core2, and newer x86 64-bit archs
$ echo 'net-print/hplip ~amd64' >>/etc/portage/package.keywords
# Install HPLIP
$ emerge hplip

The latest PPD file for the C7280 should be downloaded from the Linux Printing repository.  Currently, the C7200 model covers the C7280, and it’s PPD can be downloaded from here:

http://www.openprinting.org/show_printer.cgi?recnum=HP-PhotoSmart_C7200

On a Gentoo box, the PPD file should be saved in a certain location, and only root should have access to it:

mv <path_to_download>/HP-PhotoSmart_C7200-hpijs.ppd /usr/share/ppd/HP/
chown root:root /usr/share/ppd/HP/HP-PhotoSmart_C7200-hpijs.ppd

With that put in place, you are now ready to configure the HPLIP program, like so:

$ hp-setup

The wizard should make everything self-explanatory, except you may have to manually search for the PPD file, if the wizard cannot find it for you.  When I used the wizard, it was able to find the printer automatically and very quickly.  However, I had to locate the PPD file for it.

If everything goes smoothly, you will be done.  All that remains is to restart cups, like so:

$ /etc/init.d/cupsd restart

If things don’t go smoothly, you may have to add the printer manually through the CUPS interface or to the printers.conf file, as I had to do.

Manually Adding the C7280 to CUPS

Unfortunately, the HPLIP setup wizard was not working correctly, and I had to manually add the printer to CUPS.  I used the web interface to CUPS, which can be accessed using a web-browser on the Linux box at:

http://localhost:631

From here, I clicked on “Add Printer”, and manually entered the necessary information.  (You should know the IP address of the C7280 printer on your network.)  Most of it was obvious, except these two bits:  The device connection type was:

AppSocket/HP JetDirect

And, the “Device URI” was:

socket://192.168.0.11:9100

Of course, you will have to change the above IP address to match your needs.  … If you have already configured a Windows box to use the same printer, you can get some clues for the above info in the Windows’ printer’s properties.

The CUPS wizard may request a user id and password.  Any requested userid is referring to root and root’s login password.  These are needed near the end of the CUPS wizard, so it can edit the CUPS configuration files for you.

After entering the necessary info, pointing to the downloaded PPD file, and completing the web install, I was printing my first test page in no time!

If you prefer to work on the command line, and you are comfortable with CUPS, here are the modifications to my CUPS’ files:

/etc/cups/printers.conf

# Printer configuration file for CUPS v1.3.8
# Written by cupsd on 2008-10-30 17:37
<DefaultPrinter HP-PhotoSmart-C7280>
Info HP PhotoSmart C7280
Location My Office
DeviceURI socket://192.168.0.11:9100
State Idle
StateTime 1225405864
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>

That’s it!

And, for good measure, you should always restart CUPS after monkeying around with its files:

$ /etc/init.d/cupsd restart

Conclusion

Well, it took a little longer than I first hoped, but it was not so bad.  Now, I can print, scan, and fax from HP PhotoSmart C7280 using my Gentoo Linux laptop. 🙂

Share