Increasing the size of a LUKS cryptfs partition

Warning: This guide assumes that the partition you’re expanding into is adjacent to a pool of free space. Things get a bit trickier if that isn’t the case (re-arranging your partitions is probably necessary).

The system that I performed this on: Fedora 16 KDE install, on a 120GB SSD installation (migrated from an 80GB SSD using Acronis True Image). Fedora doesn’t set encryption up via LVM in the installer, seemingly opting for a plain vanilla container.

Step 0: Boot into a live CD environment. I used a Fedora 16 KDE respin CD which had all these tools. Open a console (in KDE this was `konsole`).

Step 1: Blow away the partition itself. You’ll need to do this with `fdisk`. Make a new partition, with the cluster of free space included. Select Linux for type when prompted (usually 82 OR 83). Write changes to disk.

Step 2: Open your crypted filesystem:

# Replace /dev/sda2 with your own filesystem

# cryptsetup luksOpen /dev/sda2 root 

Step 3: Expand the crypted FS

# cryptsetup resize root

# e2fsck -f /dev/mapper/root

# resize2fs -p /dev/mapper/root

Step 4: Safety hat

# cryptsetup luksClose root

# sync; sync; reboot

opsview and notifications

To send a notification to an external party in opsview (3.13.1) there are a few things to do:

1. Attach keywords in the host configuration to that particular host (unique no, spaces, special characters, underscores are okay).
2. Setup a new role (with the NOTIFYSOME permission, which is vaguely documented) + check off the ‘all’ box in the keywords permission section.
3. Add a contact with an e-mail address.
4. Add a notification profile attached to that e-mail address, with specific keywords to notify on checked off.
5. In the keywords section, click to flag all services with the specified keyword (otherwise no notifications will appear).

For the lazies (which means pretty much every systems administrator out there) there is, (thankfully) a *full* REST API with JSON built into opsview (unlike some of the other Nagios derivatives). More on that later hopefully.

Notes on KVM

Sharing sound with the host:
export QEMU_AUDIO_DRV=alsa; kvm -hda $image_name.img -m 1024 -soundhw all

-hda = Hard disk image
-m = Memory
-soundhw = Sound Hardware

Git Hooks: GIT_DIR and changing directories

If you’re doing something that needs to change its directory to another place (like say, you have the unfortunate need to call an external repository to perform a subtree merge after your repository has been updated), the variable GIT_DIR needs to be unset for things to work properly.

Do:
unset GIT_DIR
in your bash script to make this happen.

References:
http://www.kernel.org/pub/software/scm/git/docs/howto/rebuild-from-update-hook.txt

Adding an IP address to Debian/Ubuntu Linux

# sudo vi /etc/network/interfaces

Your original will look something like this:

# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.

auto lo eth0

iface lo inet loopback

iface eth0 inet static
address XXX.XXX.XXX.XXX
netmask 255.255.255.255
broadcast 0.0.0.0

Add the following below it to add another address to the same interface:

auto eth0:1
iface eth0:1 inet static
address XXX.XXX.XXX.XXX
netmask 255.255.255.255
broadcast 0.0.0.0

Exit.

# sudo /etc/init.d/networking restart

Ping the interface and check to see if the IP is up.

Installing mod_rails on CentOS

First, you should follow this guide: http://wiki.rubyonrails.org/rails/pages/RailsOnCentos to install Rails and Ruby in general.

After you install RubyGems, install passenger by issuing gem install passenger.
After the installation completes, issue: passenger-install-apache2-module at the command prompt.
The installation steps should be straightforward, and it’ll tell you how to work through everything.

If you get the following error: cannot open /httpd/build/config_vars.mk: No such file or directory at /usr/sbin/apxs line 201 (this may appear at the beginning of running passenger-install-apache2-module), you need to install apr-devel. Issue yum install apr-devel to take care of that.

Irssi with IRC Proxy on OpenWRT

Irssi has this nifty feature that allows you to proxy through the client. This isn’t installed by default, and is not configured in the Makefile.

This will be a sparse walkthrough, until I can flesh it out more later. I did modify the Makefile using –with-proxy, but this didn’t seem to work (the ipkg contained only the binary irssi and other sparse files).

In any case, requirements:
OpenWRT SDK, with Irssi package
Copy the following from the SDK directory:

cd openwrt/build_dir/mipsel/irssi-0.8.10/src/irc/proxy/.libs
scp * root@openwrt:/usr/lib/irssi/modules/

Starting irssi and performing /LOAD proxy showed the following:
Warning: Warning!! Password not specified, everyone can use this proxy! Use
/set irssiproxy_password to set it
Warning: No proxy ports specified. Use /SET irssiproxy_ports =
= … to set them.
03:08 -!- Irssi: Loaded module proxy/irc

Resources:
http://www.irssi.org/documentation/proxy
http://wiki.openwrt.org/BuildingPackagesHowTo

Asking a question, on the Internet

Here are four steps to get your question answered:
Step 1: Ask your question.
Step 2: Disguise yourself as another person (taking all the necessary precautions to ensure you’re another person).
Step 3: Respond with the most off-beat, crazy, put-your-knife-in-that-live-electrical-outlet-its-ok answer possible.
Step 4: Watch as people scramble to go “NO! DON’T DO THAT! DO IT THIS WAY (the correct way)”

If that fails, well… search ze web?

Logitech G9 on Linux

A new Logitech G9 mouse arrived on my doorstep today. What was first pure glee and joy (it better inspire glee and joy for its cost), turned into a sheer headache. The following is the right way to set things up:

To get it all configured, you actually need to fetch a copy of Logitech’s SetPoint software at http://logitech.com/setpoint/. The reason for this is actually quite interesting — the default profiles change what xev and X register as clicks (the button numbers change, some are duplicated, etc).

Once you have it downloaded and installed (probably to a friendly Windows computer nearby), you’ll want to make a profile with the buttons defined as follows:

1 – Left Click
2 – Right click
3 – Unassigned
4 – Unassigned
5 – Unassigned
6 – Unassigned
7 – Unassigned
8 – DPI Increase
9 – DPI Increase

Save it, assign it a pretty color and disconnect it. Plug it into your Linux machine.

As it turns out, the Logitech G9 appears as both a keyboard and a mouse device, so configuration is not as straightforward as it should be. One clever soul on the Gentoo wiki specified the Dev Phys precisely, along with the handler name.

While this works, on my system the handler varies across reboots. Adding udev rules, to make everything persistent across reboots was not working either, so I did the following in /etc/X11/xorg.conf.


Section "InputDevice"
Identifier "Configured Mouse"
Driver "evdev"
Option "Phys" "*/input0"
Option "Name" "Logitech G9 Laser Mouse" # from /proc/bus/input/devices
Option "HWHEELRelativeAxisButtons" "11 12" # I haven't gotten the tilt wheel working yet, sadly
Option "WHEELRelativeAxisButtons" "4 5"
Option "Emulate3Buttons" "false"
Option "Buttons" "9"
EndSection

Reboot (or if you’re concerned about uptime, hit the magic CTRL+ALT+BACKSPACE combo to restart X after saving and quitting your edit of xorg.conf).

Hopefully this helps somebody out there save some time.

Update: Because the g9 can actually store settings on the mouse, you can bind the “unused” left and right tilt to obtuse keystrokes, making it useful for swapping through tabs in Firefox, or for games like World of Warcraft (where you need every random trigger you can get to make use of your two hands).

Update 2: After a fresh install, i’ve discovered that you’ll need .Xmodmap with the following present in your user’s home directory:
pointer = 1 2 3 4 5 8 9 6 7

The following command will do it for you:
echo “pointer = 1 2 3 4 5 8 9 6 7” > ~/.Xmodmap

To get it going without a restart, type in:
xmodmap ~/.Xmodmap

Formac Studio TVR on Linux

I have a Formac Studio TVR. Its probably a few years old but I used it a long time ago to painstakingly record TV episodes to a Powerbook G4 12″.

As a firewire device on Linux, it works as a DV capture device. So if you have one of these lying around, it works. Just make sure to do the following:

  • The raw1394 module (`modprobe raw1394` on the command prompt as root).
  • Change the permissions on /dev/raw1394 so that regular users can read it, or open your DV capture application with privileges high enough to read/write to it. (There are also other methods around this I believe).
  • Grab a DV capture application, such as Kino, go into the capture prompt and use it there (its fairly simple). You can even use VLC to grab DV video.

    While there is an analog TV tuner on the Formac, there is no mention of how it is operated, nor is there any documentation about how to control it.