More Disk Space With LVM

Man holding two floppy disks
I’m starting to really like LVM.

See, the other day I had a problem with a virtual machine I was using, starting to run out of space. I’d only given it 10GB (well it wasn’t very demanding), and the OS auto-installer decided to divide this into ~6.5GB data and ~3GB swap. Sadly, it was a VMDK virtual disk rather than a VDI; VDIs are resizeable on the fly. I was faced the with thought of either cloning it to a larger virtual disk, or worse, rebuilding the whole image from scratch. Not having several hours to spare, I discovered that the OS had installed itself on LVM, and lo, I was saved.

First, I reduced the amount of swap used:

swapoff /dev/vg_clusterhost/lv_swap
lvreduce -L1.5G /dev/vg_clusterhost/lv_swap
lvextend -L+1.42G /dev/vg_clusterhost/lv_root
resize2fs -p /dev/vg_clusterhost/lv_root
mkswap /dev/vg_clusterhost/lv_swap
swapon /dev/vg_clusterhost/lv_swap

swapoff /dev/vg_boxhost/lv_swap

lvreduce -L1.5G /dev/vg_boxhost/lv_swap

mkswap /dev/vg_boxhost/lv_swap

swapon /dev/vg_boxhost/lv_swap

That little bundle of code turns off swap on my LVM partition, shrinks it to 1.5GB, and sets it up as a swap partition again.

Now with all that newfound free space in my volume group, I can stretch out my data volume:

lvextend -l +100%PVS /dev/vg_boxhost/lv_root

resize2fs -p /dev/vg_boxhost/lv_root

First, add 100% of the remaining free space in the physical volume to the logical volume, then stretch out the filesystem to fill the volume.

The whole thing took seconds rather than the hours I’d have needed to clone or rebuild. LVM, eh?

Image courtesy of nhoj leunamme, licensed under CC BY-NC-ND 2.0

Screen scraping and Web Real Estate

Man cleaning a window with a squeegee
As mentioned previously, I’ve started a new blog elsewhere. Still in its infancy, so there are only a handful of posts up yet.

I noticed early on that I was getting quite a bit of traffic though, even though I hadn’t pushed articles to social media; a blog with only one or two posts isn’t that attractive, so I figured I’d settle in and get the furniture arranged, so to speak, before seeing what sort of audience gravitated there. But the numbers were odd.

Continue reading

MySQL Blogging

I’ve taken up residence at for all my MySQL bloggy goodness. I’ll still blog about all of the wide and varied other things here, because it’s entirely possible that the world of MySQL users out there don’t really care about Perl or how to configure Portugese Model M keyboards in Linux.

In the meantime, expect to see a bunch of different questions and answers over there that have cropped up over the last while in my MySQL course writing, questions from students and instructors, and interesting issues that pop up when challenges and conundrums face someone who isn’t a MySQL expert but has to work with it (hey, that describes about 95% of MySQL’s userbase, right?).

Remapping \ and | on US Keyboards in UK Layout

IBM Model M, US Layout

Lately I’ve started a small collection of IBM Model-M keyboards. Well, two. And a modern Unicomp Model-M that I somehow managed to murder. The problem with the original ones is that they’re not the usual layout, for me. One is a Portuguese layout, and the other is a US layout. Both have the problem that one of the keys I need isn’t available. The key in question is the one I’d ordinarily get “\” and “|” from. This key is at the bottom left of the Irish keyboard layout (and the UK layout, which is very similar), next to Z. The key does not exist on US layout keyboards. There is a key with those two symbols on it, but that key serves the purpose of the Irish “#” and “~” key, both of which are found elsewhere on the US keyboard layout. In short, we have an extra key here that US keyboards simply do not have.

Sorry about the long pre-amble. Here’s the meat: on my main computer (a laptop that travels around with me from desk to desk, where I have my various Models-M), I run both Linux and Windows. And, being a bit of a techie, I need both “\” and “|” to work for me, so I put them under the key to the left of the digit “1”, the one that usually does “`” and “¬” and “¦“. Here’s how I did it.

Short version.

In Linux:

 xmodmap -e 'keycode 49 = grave bar grave bar backslash brokenbar'

In Windows:

Download and run the Microsoft Keyboard Layout Creator, and create a new Layout.

Continue reading

Privacy and Encryption: Lose one, lose 'em all

Privacy: a photo by alancleaver_2000

Let me start with a little imagination. An analogy, if you will.

Imagine, if you will, that you are on holiday. You want to send a “wish you were here” type message to your friend back home. You have two choices: a cheapish picture postcard, or a more expensive sealed envelope. What do you choose? If you’re like the vast majority of us, you will likely choose the postcard, for both picturesque and cost reasons.

On the other hand, let’s assume you want to send your credit card number and salary details to an insurance agency. Again, do you choose the postcard, or the sealed envelope? I will not insult your intelligence by saying what the “right answer” is. I will however allow someone else to continue this analogy on my behalf, with a slight piece of satire:

the government has announced that it will soon be mandatory to use state-approved envelopes to send all mail. these new envelopes will be entirely transparent when viewed under a federally produced lightbulb, but there is no need to worry about these lamps getting out to bad people, since it is time-tested proof that all government employees are completely honest and lack all self-serving traits present in every other human being. besides, it’s for your own good and protection! and if you have something to write that you don’t want everyone to read, maybe it’s time for that all-important self-examination to reveal your underlying paranoia complex…

(quote taken from a Slashdot comment, written by someone called CrudPuppy)

How does that make you feel? If you honestly sat down and thought about that eventuality, would you be happy about the idea of someone, anyone, being able to read your most private thoughts and words? Is it fair to expect that once it’s written down, “The Government” — whoever that may be at the time — has a right to view it? The fact is, some governments are currently attempting to change their laws to curtail the individual’s right to this sort of privacy, whether you want to believe it or not. For example, the American Wiretap Bill prohibits using emails as evidence without a warrant, but this article shows that the authorities want to read parts of such communcations without a warrant. Continue reading

CGI Trailing Path Information

Another one I couldn’t search up information on, so putting it here for posterity.

I was playing with an elderly blogging platform called Blosxom. It’s really simple to use, although that, combined with its age, means it’s not up to the current status quo. Regardless, I found it fun to play with. Plus, it’s written in Perl, and everything else is PHP these days, so it was a nice novelty.

Now, one of the things it expects (as does the rest of the internet, apparently), is that the CGI file may be treated as an application, folder, or directory on the web. Like this:

Now, the script itself is the cgi file, a file called blosxom.cgi in the root of my server. As you can see, it looks like a directory in that location, and according to the Internet, that feature should work, passing any “trailing pathname information” (as Apache calls it) to the script via the PATH_INFO environment variable.

Apache didn’t think so.

Now, attempts to google for “apache trailing slashes” or “apache cgi trailing slashes” or anything like that ended up fruitless. It shames me to say I spent over an hour investigating things like ExecCGI, mod-rewrite stuff, and all manner of other things to try to find out why that feature wasn’t working for me.

Eventually, I did what I probably should’ve done an hour before, and looked at the server error logs. Yes, they existed and were visible. I didn’t think that particular host would let me see them — it’s a free host — but I was wrong, and they surprised me yet again.

So, here’s the key: the host had switched off the AcceptPathInfo directive. Ordinarily, that’s left to the handler concerned (CGI, PHP etc.) to decide, which explains the ubiquity of the “on” setting, and the lack of anyone complaining when it’s switched off in various places I looked.

So there you have it, folks. If your CGI scripts don’t work when you have trailing slashes or trailing path info after the script’s name, don’t get lost in RewriteRules – have a look for AcceptPathInfo.