Extending (Resizing) LVM/XFS Xen images

Documentation on this procedure out on the interwebs seems rather sparse, so I thought I'd post the procedure I use to expand Xen images that use LVM and XFS. The same procedure should work fine if you use EXT3, you probably will just have to substitute the proper e2/3fs command for xfs_growfs.

## FROM THE VM HOST:
### Shutdown VM
xm shutdown VMName

## Backup the image
## (Optional, though highly suggested until you get this procedure tested in your deployment
cp -rp /var/lib/xen/images/VMName.img /var/lib/xen/images/VMName.img.bak

## Add 5GB to the image (takes approximately 4 seconds per Gig)
dd if=/dev/zero bs=1M count=5000 >> /var/lib/xen/images/VMName.img

## Loop the image
kpartx -av /var/lib/xen/images/VMName.img

## Run "fdisk /dev/loop2"
## Enter these commands
## (double check to make sure the partition numbers apply in your case)
#p-rint
#d-elete
#2-(partition 2)
#n-ew
#p-rimary
#2-(partition 2)
#<enter>-(Defaults to first available cylinder)
#<enter>-(Defaults to last available cylinder)
#t-ype
#2-(partition 2)
#8e-(Linux LVM)
#p-print
#w-rite

# Delete the loop and re-add it (to reload partiton table)
kpartx -dv /var/lib/xen/images/VMName.img
kpartx -av /var/lib/xen/images/VMName.img

# Check the Physical Volume size
pvdisplay

#  --- Physical volume ---
#  PV Name               /dev/dm-3
#  VG Name               VolGroup00
PV Size               3.71 GB / not usable 20.42 MB
#  Allocatable           yes
#  PE Size (KByte)       32768
#  Total PE              118
Free PE               1
#  Allocated PE          117
#  PV UUID               OjLnup-7iYu-ErtB-WMvN-gY0v-FbLw-gW6cEB

## Resize the Physical Volume
pvresize /dev/mapper/loop2p2

# Check the PV size again
# Take note of the Free PE (physical extents), 158 in this case
pvdisplay

#  --- Physical volume ---
#  PV Name               /dev/dm-3
#  VG Name               VolGroup00
PV Size               8.59 GB / not usable 1.05 MB
#  Allocatable           yes
#  PE Size (KByte)       32768
#  Total PE              275
Free PE               158
#  Allocated PE          117
#  PV UUID               OjLnup-7iYu-ErtB-WMvN-gY0v-FbLw-gW6cEB

## Delete the loop
kpartx -dv /var/lib/xen/images/VMName.img

## Boot the VM
xm start VMName

### FROM WITHIN THE VM
## Check the LV size of LogVol00
lvdisplay

## Resize the logical volume using the free extents from above (158).
lvresize -l +158 /dev/VolGroup00/LogVol00

## Check the LV size again to confirm the increased space
lvdisplay

## Resize the filesystem (in this case, XFS)
xfs_growfs /dev/mapper/VolGroup00-LogVol00

# Check for the increased space
df -h

## Finally, delete the backup FROM THE VM HOST:
/var/lib/xen/images/VMName.img.bak

### You're Done!

I always enjoy knowing that documentation like this helped someone. Post a comment and let me know if this helped you.

Good luck!

Rant: Linux vs Windows Expertise Availablility

Recently at work, we've been being "audited" by a firm to help us determine the cost of operations in our department, and how we measure up to other organizations of similar structure and size. One of the comments that came back to us is that we could potentially be saving on cost of ownership if we were running a Windows shop on the server side. The argument put forth is that Windows Server expertise is more prevalent, and therefore less expensive, whereas Linux is exotic, and therefore less expertise is available, and therefore the cost of Linux expertise is higher. The argument assumes of course that the cost of ownership would drop with Windows to the point of making it more affordable as a whole over time.

Personally, I don't buy it. I think this theory is based upon this idea that everyone runs Windows desktops (I admit that I do as well, for desktop support reasons), and Windows Server is just like Windows, therefore it's easier to administer a Windows Server over a Linux server because (and I know I'm exaggerating here) any old Joe can work Windows. Usually, when this assumption is made, it's false. I've seen guys mess around with Windows Server because they "just want to set up a server". Next thing they know, they've got broken pile of crap for a network. Setting up a server properly, whether it's Windows or Linux, requires expertise. Not that I discourage experimenting with either, I'm just saying that a person needs experience with the Server environment and paradigms in order to understand how to properly set up a server, and knowing Windows does not better qualify a person for that.

I would argue that Linux actually offers a lower cost of ownership in addition to the obvious up front cost (free) for one simple reason (though there are many): Scriptability. Take for example the need to create a new VPN tunnel from 100 different servers back to a secondary site (something I'm working on this very moment actually). On Windows Server with the builtin PPTP VPN clients, you would have to either connect to each system individually, create the connection, and set up the proper routing, if applicable, by hand. At best you could create a macro with something like AutoHotKey to help you do this, or even purchase some uber expensive tool for doing these sorts of replications. But even in those cases, I would challenge anyone to do it as quickly as I could with a handful of free command line tools in Linux. With one system that's been granted passwordless SSH to all of our branch servers, I can script pretty much any change to happen with a minimal of fuss, and more importantly, I can proceed to other tasks while this executes. Writing a change on 5 servers takes literally as long as writing a change for 50, or 500, all without a single mouse click.

Now that's scalability. I'd like to see that happen on Windows Server.

I've administered an organization with multiple Windows Servers. I know what a pain it is. It's a mess. Word to the wise: GUI's are for the desktop, not for the server. We're currently looking at switching from CommuniGate to Exchange at work, and I cringe at the thought. Administration will be a headache. I know this because I've admined Exchange. Everything is a kludge, and you can blame Microsoft for that. God forbid they follow an established industry standard once in a while.

</RANT>

Overcoming ODBC "Invalid character value" Error in UPS WorldShip

If you ever run into this error when trying to export data from UPS WorldShip:

ODBC ERROR: State = 22005 Error = [Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification

...here's the solution. The "defout.mdb" file that exists on your source installation is corrupt. I'm assuming this, as what proceeds seems to solve the issue. In order to get a clean copy of this file, you need to create a address book on a new installation of UPS WorldShip (possibly on the machine you will be importing to) and export that address book on there. Then take the defout.mdb file from the new system, copy it to the old system, and retry the export on the old system. This time it should complete without failure.

Good luck!

Disabling the Shutdown Event Tracker (via Regedit)

Just quick post to help those of you out there who seem to be having problems finding the Shutdown Event Tracker setting in gpedit (as I did). To disable the shutdown event tracker, you need to add/edit these two keys:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Reliability]
"ShutdownReasonUI"=dword:00000000
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Reliability]
"ShutdownReasonOn"=dword:00000000

Or, if you prefer, here's a ready-to-use regedit file.

Squid: The request or reply is too large.

Today at work we had a complaint that one of our remote offices couldn't  make a new job posting to Monster.com. Many of our offices have transparent squid implemented, and this is one of them.

Then error that the user would see was:

The following error was encountered: The request or reply is too large.

According to a few places, the problem potentially lied with the reply_body_max_size setting. However, in most recent versions of Squid, this is set to unlimited by default. After some poking around in the Squid docs, I noticed that upping the reply_header_max_size setting from the default of 20 KB to 40 KB seems to resolve the issue. The applicable setting is:

reply_header_max_size 40 KB

If this setting does not work for you, try upping the request_header_max_size as well, which would cause failure for similar reasons. Good luck!

And my vote goes to...

I've been thinking about what I'm going to do this coming election. The presidential election is lost for conservatives. Now the question is: What is our best course of action when dealing with two poor choices for President? The way I see it, McCain is just as bad if not worse for this nation in the long run as Obama is. Why is that? One word: Carter.

Jimmy Carter is probably one of the worst Presidents this country has ever seen. His policies dragged this country closer to economic collapse, and his doom-and-gloom speculation regarding the environment and oil have been roundly disproved. According to Carter, we'd be living in the age of Mad Max right about now, and if we'd actually done what he had prescribed, we'd be experiencing mass poverty in our nation, and probably be either speaking Russian or pushing up daisies. Carter was a horrible president, as history has shown, and he persists in trying to destroy our nation even to this day.

But, there was a bright silver lining on that cloud. His name was Ronnie. Ronald Reagan was the result of that terrible presidency. He renewed the conservative movement in such as way that the positive effects of his policies have lasted to this day. He brought down our nation's greatest enemy without firing a shot. He showed us the real meaning of "Peace though superior firepower". The victory of the cold war should be a lesson to all gun control supporters: Freedom has been for some time, and probably will be for the foreseeable future, won and lost at the end of a gun. The question is: Which end would you rather be on?

But back to the point of this rant: The 2008 Presidency.

There's a parallel here, and admittedly it's an unoriginal one at that. However it's still worth repeating. Obama is the Carter of our time. The candidates we have are the result of the steady decline of conservatism since Reagan left office. There have been some revivals, however the momentum has waned to the point of total dissapointment with our chosen nominee. And Obama, much like Carter, is seeing a rock-star like rise in popularity, without any real qualification or experience. Top that off with a repeat of history (attempts at price controls, calls to conserve our way out of an oil shortage, artificial pushes for alternative enery sources, and straight from the words of Carter himself "windfall profits taxes"), and we're headed for the early 80's all over again. It's as if someone dug up Carter's old speeches and handed them to Barack without even changing a single word.

McCain, on the other hand, may actually do a few things right during his presidency: stay the course in Iraq, continue to pursue Al Queda, open up (some) oil drilling, and push for a resurgence of nuclear power. However, beyond these few things, he's either iffy or downright wrong on the issues. Is he pro-life or isn't he. Will he appoint conservative judges, or will he fold just like he has in the past? Will he stop furthering environmentalist rhetoric or well he continue to capitulate? His record isn't very good. The question then becomes: Can we really risk four more years of slipping standards in the conservative movement in the name of the party?

Back to the silver lining. As you can tell by now I'm hoping McCain loses. I'm not saying I'm voting for Obama, that would also be immoral as a Catholic voter. I'd considered it, but after some careful thought about it, and discussion with my wife, I'd decided that it's best I withhold my vote from both Obama, and McCain. However, I'm still going to vote. You see, I think that the goal of this election needs to be re-focused for conservatives like myself. The message needs to be sent out, loud and clear, that the people of the Republican party should not be seen as servants to the party, as the Democrats see their people. We expect and demand that the liberals in the Republican party move on to their rightful home: the Democrat party. They need to take back thier party from the Socialists that control it. We are not your subjects. We will not follow the party blindly. We, unlike you, have principles. Our motive is not to keep our party in office, in power. Our motive is to bring about the return of Freedom. Freedom from the Federal government. Economic freedom. Religious freedom. True freedom. We will not follow you, because our leader is not the Republican party, it is God himself, the one who gives us true freedom.

Thanks to the hubris of the establishment Republicans, we have no candidate to vote for. To make it clear to the Republican party just who is in control here, we need to send a message that their chosen candidate is not acceptable to us, and that we know who embodies the qualities of a great President, not them. We must vote for the man who was the only true conservative in this race. With enough votes, the message will be clear. I don't expect him to win. I only hope that he will do for this party what Goldwater did for us back in the 60's

If you can't tell by now, "I'm With Fred".  Or rather, I'm back with Fred. Fred Thompson has always been the only true conservative in this election. I'll be writing his name in on my ballot. I know he doesn't have a chance, but as I stated, that's not really the point. The point is: I want my party back. I want my country back.

Windows Desktop Essentials

In my travels between KDE/Linux and Windows, I've found that Windows is lacking in many features that make my move(s) back to Windows relatively painful. That and often times I'll be thinking "Gee. It would be nice if there were a utility to do this or that that would make my life easier.", which often times do exist in Linux, or are easy enough to reproduce with some scripting.

So here's a small list of some of the tools that I've found that help make life on Windows a little bit more bearable.

AutoHotKey
By far my #1 pick. Think of it as an easy-to-use scripting language and GUI macro system in one. Have a program that you need to start on login, and THEN go though a complicated process to actually start it up? AutoHotKey can enable you to script mouse clicks and keyboard operations with great flexibility. Not only that, but you can script for certain conditions (such as a failure condition) and code alternate procedures to handle them. I liken it to having the power of Bash on windows, though that's probably an understatement. I find new uses for this program almost weekly. Best of all, it's small and free.

Clipboard Recorder
In KDE, you've got klipper. I missed this greatly years ago when I had to start doing desktop support as a one-man IT department. Then, I found Clipboard Recorder. Just think of it as a clipboard history for Windows. It supports any textual format (HTML, etc), so when you copy from Word into another app, the formatting will stick even when you call it up out of the history. When you rely on copy/paste as much as I do (I find it to be a huge timesaver and helps improve accuracy of data-reentry), you find that this is a must-have.


PdaReach

This is more windows-centric, but nonetheless very useful. Just think of it as VNC for your PalmOS PDA. It's so much easier to operate your PDA when sitting at a PC when you can use the full-size screen and keyboard in front of you. My only gripe with it is that it seems to interfere with my PocketTunes streaming on the PDA, so I have to close it when I'm done using it if I want the stream to continue seamlessly.

AllSnap
Windows snapping for Windows. This works like the windows snapping in KDE or for you windows users, WinAMP. For a neat-freak, this is a godsend. It helps you keep your windows nicely organized on your screen and quickly make full use of your screen real-estate.

John's Background Switcher
This is a recent discovery. This allows me to take all of my photos on my PC and randomly use them as backgrounds. Added bonus: it handles dual-screen PCs with versatility. And although I haven't yet checked out this feature, it apparently will tie into popular photo sites such as flickr and facebook so you can use your online photo store as a source of images. Sweet.

So there you have it. I'm sure I'm missing a few items here and there. They'll have to wait for part 2.

UPDATE 8/15/08: One more addition that I think should be placed on the list.

InstallWatch
How many times have you thought when changing a setting in a program "I wonder where that setting gets saved." Most of the time programs store setting in the registry, however occasionally they are stored in a file somewhere. With InstallWatch, you can take a snapshot of your system before a change is made, make the change, and then analyze the changes, revealing exactly where your setting resides. I use it all the time to make .reg files that make changing a setting as simple as 2-3 clicks (instead of searching for the setting in the applicable program). This of it as "diff for regedit", only better.

The Cost of Green

From xkcd:

Granted, funny, however...

From WSJ (http://online.wsj.com/public/article/SB119335110403372123.html):

I'll probably be sticking with my SUV for some time, and in fact, we'll probably buy another after we outgrow this one. Honestly, I can't physically fit in one of those compact economy/hybrid cars. Even if I could fit, the comfort of a SUV makes it's increased sticker price worth it.

The funny thing about it is, these hybrids are only fractionally more efficient than regular cars or SUVs, so it's like being all high-and-mighty and saying "I only pollute the earth 9/10ths as much as you do, so there!". Give me a break. Besides the fact, we'll see how much you're not polluting the earth when those LiIon batteries need replacing.

My Official John McCain Outreach Blog

http://www.johnmccain.com/ActionCenter/BlogInteract/BlogInteract.aspx

John McCain's campaign wants us to blog for him to help spread his message. Here's my attempt:

Vote for John McCain, the spineless global warming movement pacifist.
Vote for John McCain, the pseudo-Republican who's all talk and no substance when it comes to conservative ideals.
Vote for John McCain, the candidate of the new Liberal Republican movement.
Vote for John McCain, he supports the war. Kinda. Except when it's not politically expedient.
Vote for John McCain, he's Pro-Life. Wait, what's that? He's not really? Oh.  Forget that then.
Vote for John McCain, he'll stand for nothing of importance, and destroy the Republican party in the process.
Vote for John McCain, if you are one of those mythical post-Hillary swing voters that will supposedly save his campaign. But as for all of you conservative Republicans, screw you. He doesn't want or need your vote.
Vote for John McCain, because hey, what other choice do you have.

There you have it John. There's my blog to counter all of your marketing fluff. Good luck to you, because you'll need it without the votes of your base. Personally, I think I may be voting Obama to save the Republican party from the anti-Reagan interests that have control of it. Perhaps they'll finally abandon my party if they realize that no true Republican will vote for Democrat lite.

Welcome to the rest of your week...

Where the hell is this global warming I've been hearing so much about.

Changing /dev permissions on Fedora

It's infrequent enough that I have to do this that I forget how. So to help me remember, I'm posting it here:

To make your permissions changes to devices in /dev/ survive reboots and become permanent, you need to alter the device permissions in

    /etc/security/console.perms.d/50-default.perms

So for example, say I have a created a group that holds all users on the system that are to have RW access to the video capture hardware (such as mythtv and zoneminder), open the perms file and look for this line:

    0600 0600 root

This v4l class covers all /dev/video* devices. To make them RW by the group "video", change the line to look like this:

    0660 0660 root.video

You can reboot to see the effect.

I'm Gonna Be A Dad!

Due date: September 6, 2008

Whoo hoo!

Gear Head Quick WebCam Basic (WC330I) Review

While at my local MicroCenter, I noticed this cheap ($15) webcam being sold. It said nothing of Linux support, but I had read that in the past couple years there were alot of cheap Chinese-made webcams that gained support in Linux. I figured I'd give it a shot, and if it worked out, I'd pick up a handfull more for my ZoneMinder system at home.

Now, I should say that I run Windows XP on my work workstation, and I just wanted to get a feel for the quality of the cam before I did anything more with it, so I plugged it in and installed the drivers. I have to say before I go any further: The pictures speak for themselves...

Horrible. Muddy. Overcompressed. Dark.

The poor quality of this cam really just defies words. I guess what expect I'd hear after making these statements is "What did you expect for $15?". Something other than absolute crap I suppose.

Just in case you have further interest in this product and it's support in linux, the USB device ID is 093A:2460 and appears to have some sort of support in linux (http://www.qbik.ch/usb/devices/showdev.php?id=3144). If you choose to buy one of these, good luck with it.

I'll be returning mine as soon as possible.

The MYTH About Oil

http://www.popularmechanics.com/science/earth/4254875.html

The basis of the article "The stark reality is that the supply is finite." is false. How long will it take before people come to grips with the fact that petroleum is NOT a "fossil fuel". Oil is produced by the earth by constant biochemical reactions, whether in the oceans or deep below the surface. Oil is not finite, in the sense of a single pie, it's infinite, in the same sense as any other "renewable resource".

"The Truth About Oil" scarcity is not geophysical, but rather geopolitical. It's about modern socialists (ie, Liberals) trying to gain control over our lives by demonizing capitalists and regulating of every facet of your life.

You want to stop $100/bbl oil? Open ANWR. Allow new refineries to be built. Deregulate oil. Stop perpetuating the lies.

Need more info? http://www.google.com/search?hl=en&q=fossil+fuel+myth

The Amazing, Walking, Talking, Human Vegetable!

To quote my wonderful wife, "This is why we don't take 'brain dead' people off life support."

Four months after he was declared brain dead and doctors were about to remove his organs for transplant, Zach Dunlap says he feels "pretty good."

Vegetables never felt so good.

Ben Stein: Expelled

I've been told to shut up a few times myself. That's how these people operate: If you disagree with me, you should be silenced. For more info on this movie and for theatre times and locations, go to http://www.expelledthemovie.com

Greasemonkey: 2002 Ford Explorer - Electrical Issues

I don't really know if this is worth posting about. The solution seems rather obvious, but just in case someone find this useful, I'll post it anyhow.

This weekend, while in the midst of a 6-hour drive to the in-laws, the truck's ABS light started flashing. "Odd" I thought "I guess we'll have to get that fixed when we get back". Minutes later, the red battery indicator started flickering, and then went on solid. Oh crap. The voltage indicator was practically pinned on "L". Minutes after that, the dash went completely dark. No speed, no RPM, no lights, no nothing. But the truck was still running. Thank God we managed to make it a few more minutes to a parts store at the next exit.

After some conversation with the parts store employees and a physical inspection of the battery, it became pretty clear that the battery needed to be replaced. It was, according to the clerk, the original battery for that model. So the battery is/was about 6 years old. Some bulging had started to occur, possibly due to freezing. However, after some testing with the new battery in the truck, he was uncertain if the problem had been resolved, or if the alternator needed replacing. His suggestion was to drive around for an hour and see if the meter continues to drop. As I had quite a few hours ahead of me, and the next parts store was about an hour away, I figured we should just continue on our way.

Sure enough, about an hour out, it became evident that the battery was losing juice. After running around to a few parts stores, and yet again barely making to the final store (dash went black), I had a replacement alternator. Beleive it or not, an alternator is easy enough to replace. Assuming it's not crammed underneath the engine somewhere, or in an impossibly tight space, it's something that can be replaced in under a half hour with the right tools. You may need a metric wrench for some of the bolts involved. In my case, I needed a 13mm metric wrench for the mounting bolts. The socket for the positive connection nut was easy to find in the standard imperial sizes. Finally, and most importantly, you'll need a serpentine belt wrench. This tool has a square socket post on the end of a 2-3' flat-bar. This inserts into a spring-loaded tensioning arm with a pully on it, usually near the alternator. This arm keeps the belt tight, and the spring is quite strong. It's nearly impossible to move it without the serpentine wrench.

Anyhow, as I said, the repair is pretty straightforward. Once I had the proper tools, I was able to replace it in the parking lot of the parts store in about 30 minutes, and back on our way.

Yotta, Kilo, Bits, & Bytes

From XKCD:

Now I just need a table explaining the variances of "gigabarts" and the difference between hertz and bytes :-)

A Simple Uptime Output Method

If you've ever tried to parse the output of "uptime", you know it can be complicated. There's a simpler solution: Use the raw numbers from /proc/uptime. Here's a simple script that spits out the days and remaining time in digital clock format:

    cat /proc/uptime | awk '{printf "%d%s%.2d%s%.2d%s%.2d%s" , $1/86400 , " days, " , $1%86400/3600 , ":" , $1%86400%3600/60 , ":" , $1%86400%3600%60 , "\n"}'

Note that the output can be changed to your needs. See the AWK Tutorial for more info on using modulus (%) in calculations, and string formatting (i.e., %d and %s)