VirtualWoes

I find myself in a position where I have to run Windows on my laptop, and use it on a daily basis. This does not make me a happy moggie, as I have run Ubuntu exclusively (except for gaming) for several years. I finally decided that the best solution would be to run Ubuntu in VirtualBox on top of Windows.

(Yes, I still run Hardy, as I still haven’t recovered from trying out the unmitigated disaster that was Intrepid. I may give Jaunty a spin some day; VirtualBox makes this so much easier… but in the meantime, Hardy it is. Besides, it’s an LTS release.)

Why not the other way around? Three reasons: Windows is a PITA to virtualize (not least from a licensing POV); I never do anything really performance-sensitive in Linux, but I do in Windows; and doing it this way around means I can suspend and hibernate, something Linux still can’t do. (Cue angry comments from Linux fanboys insisting that suspend and hibernate work just fine and I’m an idiot; sorry, but no, it has never worked for me on any of the laptops I have owned or managed—even those manufactured by companies that spend millions of dollars every year on Linux development.)

Running Ubuntu in VirtualBox is not as easy as it sounds, though. You can’t just create a new VM, pop in the CD, and install. There are several issues that took me quite a while to resolve, and the VirtualBox web forum was no help at all: the moderators arrogantly shut down any thread touching on issues covered by the FAQ, even when the answer given in the FAQ is incorrect and / or insufficient. Continue reading “VirtualWoes”

GPG insecure memory

Just a quick note to record the answer to a question that’s been bugging me for quite a while:

% gpg --list-keys 64EBE220  
gpg: WARNING: using insecure memory!
gpg: please see http://www.gnupg.org/faq.html for more information
pub   1024D/64EBE220 2006-11-11 [expires: 2009-11-10]
uid                  Dag-Erling Smørgrav 
uid                  Dag-Erling Smørgrav 
uid                  [jpeg image of size 3315]

The textbook solution is to chmod u+s =gpg, but this doesn’t always work on FreeBSD (especially on amd64). The reason is that the default limit on wired pages (which includes the unified buffer cache) is too low. It is initialized at boot time to approximately one-third of system memory. Increasing it to, say, half your system memory should fix the GnuPG issue:

% sudo sysctl vm.max_wired=524288
vm.max_wired: 333091 -> 524288

Remember that vm.max_wired is in pages, not in bytes. On i386 and amd64, a page is 4096 bytes, so the above allows for up to 2 GB of wired memory.

No, really

In support of my earlier claim that Java enums are subclassable, here is an example inspired by McGraw-Hill’s SCJP 6 study guide:

public enum CoffeeSize {
    REGULAR(4), BIG(8), HUGE(12), OVERWHELMING(16) {
        public void drink() { super.drink(); System.out.println("barf"); } };
    private int oz;
    CoffeeSize(int oz) { this.oz = oz; }
    public void drink() { for (int n = 0; n < oz; ++n) System.out.println("glug"); }
    public static void main(String[] args) { CoffeeSize.OVERWHELMING.drink(); }
}

No, silly! It’s an enum!

Ah, to have been a fly on the wall when they designed Java 5. Imagine a meeting between three unnamed Java language designers:

JLD#1: OK, so, new language features for 5, what’s next on our list? Anyone?
JLD#2: There’s always enums.
JLD#3: Not enums again!
JLD#2: Well, they keep asking for it. It’s getting pretty tiresome. Why don’t we just give them enums, and be done with it? How hard can it be?
JLD#1: OK, let’s consider enums for a minute. How do we do that? Continue reading “No, silly! It’s an enum!”