Interphero Miscellany

Hopefully something good will come of this…

Interphero Miscellany RSS Feed
 
 
 
 

libvirtd: Gracefully Shutting Down VMs

libvirtd – part of libvirt – is a daemon that manages virtual machines in Linux – including those running under KVM.  I recently made the move from controlling my virtual machines with scripts in /etc/init.d to libvirtd.  libvirt has a number of advantages over using KVM directly, including:

  • Definition of VMs via an XML file (easier to read than the lengthy kvm command line commands)
  • Supporting scripts that ease creating VMs (although for this task, I still prefer kvm command line)
  • Ability to control VMs remotely via Virtual Machine Manager
  • Cleaner network configuration
  • Ability to gracefully shutdown VMs

Issuing a shutdown command to a VM under libvirt is essentially like pushing the power button on a regular PC.  ACPI capability within your guest OS can then process the button press accordingly, for instance, shutting down or suspending the VM.  I’ve used this successfully on several OSs, including:

  • Ubuntu 9.10 Server – you must install ACPI support – apt-get install acpid
  • Ubuntu 9.10 Desktop – ACPI support is already installed, but you must set the behavior, i.e., shutdown on button press.  The default is to ask the user what they want to do.
  • Windows 7 – Everything works out of the box.  I suspect that this is standard for the more recent Windows releases

To ensure that your VM can process ACPI, make sure that you include the following lines in the configuration XML file:

<features>
<acpi/>
</features>

Resolution: Slow Printing of PDFs on Brother HL-2170w

I have been using a Brother HL-2170w as my printer for approximately a year now.  I have it setup as a shared printer, on my Linux server, through CUPS.  I print to it from an Ubuntu laptop.  I initially had it installed using the OpenPrinting driver on both my server and my laptop.  This setup worked well for everything but PDFs.  PDFs would take an abnormally long amount of time to print, in some instances 15 minutes per page.  During this time gs would not be consuming any CPU resources, so I was perplexed as to why it would take so long.

However, I recently changed by setup and now PDF printing takes a few seconds of processing per page.  On the server side, I changed the driver to the raw driver.  On my laptop, I switched to using Brother’s LPR driver with CUPS Wrapper.  It now behaves as one would expect, gs cranks at near 100% CPU utilization for a few seconds and then the job starts printing.  I have not gone back to determine what was causing the issue: not using the RAW driver on the server, or Brother’s driver.  Either way, leaving the queue raw is probably good in mixed environments, where you have both Linux and Windows clients using the printer.

How to Set XBMC to Auto Update the Library

It should come as no surprise that XBMC has great library functionality.  And its skinning ability has allowed third-party developers to display the myriad of information contained within the library with great effect.  Library management is fairly easy with one HTPC running XBMC, but it can become more time-consuming as that number increases.  XBMC used to have an option to essentially constantly update the library.  Even with enabling this functionality in the settings file, I was unable to get it to work (I keep my media on Samba share, so this may have to do with it).

But, you can also schedule updates to occur using cron.  This method offers an additional benefit if you are running XBMC on a limited-resource machine, such as an Acer Aspire Revo, in that you can schedule the library update to occur when you are not using the machine.  I accomplished this by dumping a script into the /etc/cron.daily/ folder, however, you can make an actual cron tab entry if you prefer to customize when the library update runs, or if you would like it to run more or less than once per day.  But, to get this working, you will need to install the xbmc-eventclients-xbmc-send package:

sudo apt-get install xbmc-eventclients-xbmc-send

After installing, the following command will cause XBMC to update the video library:

/usr/bin/xbmc-send -a “UpdateLibrary(video)” >> /dev/null 2>&1

Note, that you can also update the audio library by replacing “video” with “audio.”  As noted, this command can either be added to your crontab, or as a script in one of the /etc/cron. directories.  Enjoy!

Google Now Offers DNS Service

Google has just added DNS to its public (free) services.  I was previously using OpenDNS, but I’ve decided to give Google’s service a try:

http://code.google.com/speed/public-dns/docs/using.html

Fixing “Lock Screen” in Ubuntu 9.10 (Karmic)

So far my experience with Ubuntu 9.10 (Karmic) has been great.  I find it noticeably quicker as well as more attractive visually.  That’s not to say that it is without issues.  For example, after the upgrade the “lock screen” function was broken.  After digging around a bit and trying to lock the screen from the command line I found the following:

user@interphero:~$ gnome-screensaver-command –lock
** Message: Screensaver is not running!
user@interphero:~$

The “lock screen” functionality is part of gnome-screensaver, and for some reason, gnome-screensaver was no longer being started with Gnome.  I fixed this by adding gnome-screensaver as a startup application by going to Main Menu->System->Preferences->Startup Applications.

Linux KVM and VNC: Keep Your Pointer Straight

KVM allows you to run virtual machines on a Linux machine.  One of the great features is provided by the ‘-vnc’ flag, which allows you to run a virtual machine headless, i.e., without a graphics adapter, while still being able to connect to it through VNC.  One issue that I have encountered, especially on Windows virtual machines, is that the mouse pointer in the VM does not always line up with your actual mouse pointer.  Luckily, this is easily correctable.  To fix it, add the following flag to your kvm command when starting the virtual machine: ‘-usbdevice tablet’.

Seagate Barracuda Hard Drives: Upgrading to the SD1A Firmware

I am a bit behind on this issue, but essentially, Seagate Barracuda 7200.11 hard drives had some issues with certain firmwares bricking the drive.  When the error appeared, the drive would no longer be recognized by the BIOS, making subsequent firmware upgrades impossible.  Although I have been running a RAID-5 array of five of these drives for over a year, I was finally caught by the bug after a reboot, when my RAID-5 array came up in degraded mode.  Seagate’s warranty process was relatively straight forward; I paid the $20 fee to have a new drive sent via 2-Day UPS, in a hard drive shipping container with a return-postage label.  I was a bit ticked about paying the fee, but it saved me a lot of headaches regarding finding a suitable shipping container.  I also avoided having to wait for them to receive the defective drive, after which they would mail out the new drive.  My goal was to have the array in degraded mode for as short of a period as possible, to avoid having a second drive fail before it was repaired.

As I noted above, this issue occurs when the computer is rebooted, the drives won’t just drop off of your SATA controller.  As such I wanted to repair the array without rebooting the machine.  First, I had to determine which drive was actually down/damaged.  To do so, I used the following command on each of the drives in the RAID array:

dd if=/dev/sdX of=/dev/null

I ran this command for each drive, while watching the hard drive activity lights on my RAID enclosure.  Alternatively, I could have run a similar command for the RAID array itself:

dd if=/dev/mdX of=/dev/null

The drive that doesn’t show activity is the one that needs to be replaced.  After pulling the drive and replacing it with the replacement from Seagate I hot-added it to the system, once again, to avoid rebooting the machine and potentially having another drive fail.  To do so, I used the scsiadd command, for which you can find an article here.  I stepped through each channel, trying to add the drive; note that selecting an empty channel won’t break anything.  To verify that the drive has been added back in, you can run:

ls /dev/sd*

If the drive was added by scsiadd, you should have a new entry.  After this I was able to format the drive and add it back into the array.  As for the other drives, I needed to upgrade the firmware from SD15 to SD1A, with the exception of the replacement drive, which already had SD1A installed.  I used the following guide, which explains everything much better than I could.  Once again, I used the tricks above to figure out which drive was which prior to using scsiadd to remove it from the system.  At this point, all of my drive have been updated to SD1A and I am **hopefully** safe.

I was late to update the BIOS on these drives and in many ways, I was lucky.  I didn’t do it sooner because I had been running them for more than a year without issue.  I believe that I got by for so long because I use the drives in my server, which is not rebooted often, at least relative to your standard desktop.  Moral of the story: if you haven’t done so yet, update your firmware to SD1A.

If you are uncertain about which firmware you are running, various tools will display it:

scsiadd -p

smartctl –all /dev/sdX

New to the blog: Commentary

I have decided to broaden the scope of my blog to include my commentary/humor related to current events, as well as long-standing issues.  In addition, I will be revamping the site to separate out “commentary” from the core “technology” content.

DVD Playback Issues with XBMC

I typically archive my DVDs to MPEG files prior to playing them back in XBMC, so that they are displayed in my library.  And for some reason, I would use the DVD player on my surround receiver to playback DVD rentals, as opposed to using XBMC.  Last night I finally decided to use XBMC to play a rental, when to my surprise, it wouldn’t play the disc!

For background, I installed XBMC over a minimal Ubuntu install, done with the server edition.  As such, I don’t think that some of the multimedia related files were installed.  A quick review of the XBMC log file (~/.xbmc/temp/xbmc.log) showed errors relating to a UDF library.  UDF is the disc format used for DVDs.  To resolve the issue, I installed two packages:

sudo apt-get install udftools libudf0

Note, I believe that udftools would have been sufficient to resolve the problem.  From then on, XBMC automatically starts playing a DVD upon insertion.

Check your Server’s Pulse with Twitter

I had a problem – a remote server that I couldn’t check the status of.  It is located a friend’s house and I would occasionally lose contact with it.  Sometimes it would be down (he apparently doesn’t have reliable electricity) and I wouldn’t notice it for a week or two.  This server acts as my remote backup server, so I didn’t want to potentially miss an important backup run.

While others view Twitter as a great social networking, Web 2.0, whatever, I see it as a free update/status server.  Several folks have talked about updating Twitter from the command line:

http://lightlinux.blogspot.com/2009/06/twitter-updates-from-linux-cli.html

http://www.junauza.com/2009/03/follow-me-twitting-from-linux-command.html

I decided to use curl (as described in the blogs above) to setup a heartbeat from my remote server.  Essentially, every half hour, the remote server sends out a tweet with its full hostname and the local time to Twitter.  If I am ever curious about whether the remote server is up, I can check Twitter, and also figure out approximately when it went down, based upon the time of the last update.  I have been using the following bash script:

#!/bin/bash
curl –basic -u  “username:password” -d “status=$(hostname -f) is alive at $(date) local time.” http://www.twitter.com/statuses/update.xml >/dev/null

I have cron setup to run the script every half hour, although you can change the update interval to suit your own needs.  I also created a separate Twitter account strictly for this purpose and made it private.

In the future, I may utilize Twitter’s RSS feature to send me an email if a server misses an update.

 

March 2010
M T W T F S S
« Feb    
1234567
891011121314
15161718192021
22232425262728
293031