Ubuntu Live CD with FOG 1.1.2

TL;DR: To do what the title says, get FOG working and then go to its admin page (http://MY-SERVER-IP/fog/management/index.php). Click the question-mark menu item (mouseover text “FOG Configuration”), then select “PXE Boot Menu” from the links on the left, and finally select “Advanced Configuration Options”. This produces a text box where a standalone iPXE script can be pasted in, which will be available from a magically appearing “Advanced” option at the end of the default list presented when your client system netboots. The script that did the trick for me is:

set arch i386
item fog.precise Run Ubuntu 12.04 LTS LiveCD (32 bit)
choose target && goto ${target}
# The kernel's path is relative to /var/www/fog/service/ipxe.
# The files at the nfsroot are a copy of the mounted contents of
# the ubuntu-12.04.4-desktop-i386.iso. Note that this 'kernel'
# line is one long line. ('nfsroot' is an argument to 'kernel'.)
kernel howtogeek/linux/ubuntu/precise/casper/vmlinuz boot=casper netboot=nfs nfsroot=MY-SERVER-IP:/tftpboot/howtogeek/linux/ubuntu/precise
# initrd should be on its own line so iPXE grabs it via HTTP,
# instead of requiring the kernel to grab via NFS
initrd howtogeek/linux/ubuntu/precise/casper/initrd.lz
boot || goto MENU

Mount an ISO persistently with a line like this in /etc/fstab:
/tftpboot/howtogeek/linux/ubuntu-12.04.4-desktop-i386.iso /tftpboot/howtogeek/linux/ubuntu/precise udf,iso9660 user,loop 0 0

The full version:

FOG is a really quick-and-easy way to setup a DHCP/TFTP/HTTP/NFS server which can be a lifesaver when doing low-level experiments using hardware that might not have a CD/DVD drive, bootable USB, etc. I’ve set this stuff up manually in the past and it is always very tedious. I feel compelled to mention that PXE is a completely insecure protocol. It downloads arbitrarily bytes from a cleartext network connection and executes them in CPU ring 0. Configurations like this are unsuitable for anything other than lab-style environments.

I stumbled upon all of this when I basically wanted to do exactly what this link suggests: http://www.howtogeek.com/61263/how-to-network-boot-pxe-the-ubuntu-livecd/, but unfortunately it’s for an earlier version of FOG, and rather than use the old version I thought I would see what I could do. This HOWTO suggests editing /tftpboot/howtogeek/menus/linux.cfg from a previous HOWTO http://www.howtogeek.com/57601/what-is-network-booting-pxe-and-how-can-you-use-it/, which all comes down to file /tftpboot/pxelinux.cfg/default, which no longer exists in FOG v1.1.2. The reason for this is that the PXE boot menu is dynamically generated on the server using PHP code and a database backend.

With the help of WireShark, I fairly quickly was able to figure out how FOG was working. The TFTP/PXE part was working just fine. The trick is to figure out how it gets the kernel, initrd, and root filesystem for the option it does end up booting. Basically all of the problems I had were with specifying the right access method and path to the kernel, initrd, and root filesystem.

One can pretend to be a client using curl (with its awesome-sauce support to trivially stick in POST arguments):

curl --data "mac0=aa%3Abb%3Acc%3Add%3Aee%3Aff&arch=i386" http://MY-SERVER-IP/fog/service/ipxe/boot.php##params

My apologies for forcing you to probably read the FOG wiki, two howtogeek articles with painfully low information density, and then this, but perhaps it will show up as a search result that can help people frustrated with instructions that apply to stale FOG versions.

How to get rid of Alt-Tab and Alt-` in Ubuntu 12.04 Unity

I was happy with the Alt-Tab behavior before Unity. I tend to switch windows very rapidly and the attempt to animate things, and I find the distinction between Alt-Tab and Alt-` to be very annoying, especially under certain circumstances when Alt-Tab actually does behave as Alt-` does.

Here are some instructions to fix this. I selected the Static Application Switcher. I have not tried the Shift Application Switcher.

OSXFuse + MacFUSE Compatibility Layer + Fuse-ext2 = ext[23] on OS X (ro)

I was hoping to be able to at least read (though writing is always nice) ext3 filesystems on external drives from OS X, without having to start up a virtual machine. This page suggested I use OSXFuse and Fuse-ext2.

It turns out OSXFuse is the actually-maintained descendent of MacFUSE, but that it includes a “MacFUSE Compatibility Layer” (just a checkbox during install; no need for a separate download) that can handle the Fuse-ext2 module (which apparently hasn’t been updated in several years). Nonetheless, these things worked pretty seamlessly for me. I installed OSXFuse, then installed Fuse-ext2, then rebooted. The next external USB storage device I connected with an ext3 filesystem was successfully mounted read-only. Various other places on the web suggest that really slow writing should be possible, but I have not explored that option.

OS X Mountain Lion does not include X11

Just spent way too long thinking it was something wrong with my SSH configuration. Ugh. The former X11.app is now an open source project that needs to be independently installed. Once installed things Just Worked the way they used to. An example error message that is resolved, that I encountered when trying to run gitk:

$ gitk
Application initialization failed: no display name and no $DISPLAY environment variable
Error in startup script: no display name and no $DISPLAY environment variable
while executing
"load /usr/lib/libtk8.5.so.0 Tk"
("package ifneeded Tk 8.5.11" script)
invoked from within
"package require Tk"
(file "/usr/bin/gitk" line 10)

Locales problems on Debian or Ubuntu

I use debootstrap to install a lot of Debian or Ubuntu systems. This often leads to “locales” problems. Examples of the errors you might see include (from aptitude or apt-get):

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

…or from gparted:

(process:16644): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
libparted : 2.3
(gpartedbin:16644): glibmm-ERROR **:
unhandled exception (type std::exception) in signal handler:
what: locale::facet::_S_create_c_locale name not valid

This fix has been the most reliable that I have found:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

In particular, just running dpkg-reconfigure locales rarely accomplishes anything useful for me. If it doesn’t produce output, it probably didn’t fix your problem.

Exporting Redmine issues and then importing them to a SourceForge project

I had 60-something Issues in a Redmine installation that I managed myself that I wanted to import into a new SourceForge project. Redmine has native support to export these issues into a CSV file. It turns out that CSV is mildly richer than I had previously thought, and cleanly supports things like a single “cell” in the resulting spreadsheet containing a large, multi-line description full of quotes and commas.

The SourceForge API v2.0 Beta is scriptable. Awesome. The example at that page uses Python, and I like Python, so we’re good. The steps are roughly as follows:

  • Create an “oauth application” in your SourceForge account here. You will end up with a key and a secret from the registration process, which you will need to paste into the relevant scripts.
  • Thanks to the existing SourceForge example, the scripting related to Oauth login was already done for me. Note that webbrowser.open() is used to allow you (the human) to manually copy/paste a per-session PIN. Your OS needs to support the launch of a web browser. Mine (Ubuntu 10.04) did without issue.
  • Use the Python CSV package to parse the Redmine-exported CSV file into a Python data structure (roughly an array of dict objects, but see DictReader.fieldnames to understand how it is more than that).
  • Add some custom scripting to map Redmine fields to supported SourceForge fields. A few fields map in a sensible way. The rest I just inserted with a descriptive prefix at the beginning of the primary Ticket Description.

I placed the scripts on github (no, the irony is not lost on me, but my current preference is for long-lived things to be on SourceForge and quick-and-dirty things to be on github).