Systems


2
Nov 09

Running older (pre-etch) Debian releases

This post is quick public information service for everyone using, or having to deal with old Debian releases. This includes all releases prior to Etch: Woody, Sarge, Potato…

You have probably noticed that you cannot longer use APT to install packages in your system.
The package repositories have been moved over to archive.debian.org, so you will need to change your /etc/apt/sources.list accordingly. For Sarge, you would use:

deb http://archive.debian.org/debian sarge main contrib non-free
deb http://archive.debian.org/debian-security sarge/updates main contrib non-free

You may even use archived repository of backports.org of Sarge, adding a line like this:

deb http://archive.debian.org/backports.org sarge-backports main contrib non-free

This way one can inject some fresh air into an existing Debian setup if making a full system upgrading is not an option for you.

Have a lot of fun…


19
Oct 09

Factor out your Apache-fu with mod_macro

For nearly all HTTP-serving related work, our software of choice is the Apache web server. Lately, we have been moving some old setups which were still running Apache 1.3 to the latest version in the 2.x series. This may be a lot of work when the number of virtual hosts you are serving is far from low, or if you have some lengthy, repetitive configuration blocks which must be modified everytime you want introduce some change. One may be tempted to auto-generate configuration snippets from something else using some quick Bash/Perl/Python/Whatever script, but there is a more elegant solution: meet mod_macro.

As the name suggests, it is an Apache 2.x module which allows for defining snippets with customizable optional parameters. Take this real-world example from /etc/apache2/mods-available/macro.conf:

<Macro AuthLDAPSetup $group>
  AuthType basic
  AuthBasicProvider ldap
  AuthLDAPUrl ldap://ldap.local/dc=yoursite,dc=com?uid
  AuthLDAPGroupAttribute uniqueMember
  AuthLDAPGroupAttributeIsDN On
  Require ldap-group cn=$group,ou=Group,dc=yoursite,dc=com
</Macro>

This is a common setup in most of our services, so now everytime one wants to add autentication against the LDAP server, it is only a matter of adding an Use clause in the proper place:

<VirtualHost *:443>
  # Virtual host configuration cruft skipped from example!
  <Location />
    Use AuthLDAPSetup wwwusers
  </Location>
</VirtualHost>

Ta-da! This is 5 lines shorter, and less error-prone. Also, if some day some extra configuration is needed to authenticate using LDAP, it is enough to change the macro definition, and changes will be automatically propagated to all places where it is used.

Wrapping up, you may consider installing mod_macro in your Apache installs for the following reasons:

  • Greatly simplifies repeated code snippets in configuration files.
  • It is integrated with the web server: no external tools are needed.
  • Is especially useful to make changes to big sites in a single shot.
  • Does not add overhead to request processing, only to initial configuration file parsing at server startup.
  • It is simple enough to learn and use in a couple of minutes.

:-)


25
Sep 09

Two months after…

Two months have passed after my last post, and things here have been quieter than usual in this blog, but the world kept moving in the meanwhile so there are some things to tell, and some other that have already been told. Probably the most exciting thing for me and my work mates was the announcement of the shiny Nokia N900. I have resisted the temptation then, because a lot of things have already been said about it. We systems administrators are usually in the shadows, but even so it is a delight working as backing support for people who does big things.

There were a couple of releases this week what are a great example of why Igalia reached its eighth year, and we are still rockin’ in the free world:

  • Hildon 2.2.0, the user interface toolkit used in Maemo. No words are needed to explain how awesome is this!
  • Also, some of my work mates are fine-tuning MAFW after bringing it to life in order to provide multimedia coolness to Maemo, and (who knows!) maybe the desktop as well. Of course all built on top of the lovely GStreamer libraries.
  • GNOME 2.28, which includes the hard work from a lot of work in form all around the world, and a revamped Epiphany web browser which uses WebKitGTK+ as the rendering engine. This means that some of my colleguaes have been killing kitties and their hard work will be deployed in every GNOME install!
  • Frogr 0.1, a tool which carries out out the simple (but important) task of uploading pictures to Flickr, and it is doing a fine task for me right now.
  • In the operating systems ground, Haiku R1 Alpha 1 has been released. This may sound like “some other hobbyist operating system”, but it is a lot more than that: it is a new life for the mighty BeOS R5, which  took eight years to to bring from the dead. I have played a bit with the live CD: the experience is great, although somw rough edges still exist, but I would say that Haiku contains lots of superb work and I am eager to install it in some real hardware.

But more changes apart from software releases happened: in a more personal note, I am now using Fedora 11 in a daily basis at my laptop. Initially I wanted to try out Foresight, because the Conary package manager looks like an interesting piece of software, but unfortunately the installer does not have support for LUKS-encrypted volumes in the installer, and I did not want to bootstrap it manually. Interestingly enough, Fedora does have such support using the same Anaconda installer. I did not like Fedora back in version 6, but I must admit that the community did an impressive improvement (at least comparing version 6 to version 11!) and I am very happy with my current setup. I am even considering Fedora 11 for installing it on my brand new PlayStation 3: I bought one of the old “fat” models, because the new “slim” ones do not officially support installing third-party operating systems.

Finally, a quick note to finish this “I am alive” post: I am glad that we have decided to push Linux-vServer in our servers, because we are getting some interesting benefits thanks to it, being the main one the ability to easily clone a running machine and use the clone for testing purposes before applying changes in the production environment. Also, we are now able of easily provide sandboxed environments in which users have almost-full administrative privileges without having to worry about other services being affected in case something goes wrong. And we are getting those niceties with a minimal overhead (~1.5%) in terms of kernel CPU usage. As we are moving services which were previously run on physical machines into virtual machines, we are saving power and contributing to the environment while providing a better service and support to our staff :-D


17
Feb 09

“Keep it up and running”

Yesterday I found The Admin Zen. Recommended reading for all the systems administrators out there. I liked the fact that some of the principles are loosely based on The Zen of Python, which you can read by just typing the following in a console:

python -c 'import this'

Enjoy… and keep your stuff up and running ;-)


17
Oct 08

Intrepid upgrade

So I am right now running Ubuntu 8.10 “Intrepid” in my workstation. In general, the update was smooth, but I have a word of warning: if you use OpenBox as window manager in the GNOME desktop environment, it will stop working. If you try to log in from GDM using the “GNOME/OpenBox” session kind, you will be kicked back to the login screen. As a workaround you can execute openbox --replace from the “Execute” dialog from a regular session as a workaround.


15
Jul 08

Quick reminder: Resize snapshotted LVM volumes

Just in case you did not know about that, I spent some minutes today figuring out how to resize a LVM logical volume there are snapshots of it: the volume cannot be active. This is a pity if your root filesystem is inside a logical volume. Fortunately, you can stop the bootup process of recent Debian installations in the initial RAM disk by passing break=mount; unfortunately this minimal system has the vgchange tool (needed to start/stop volumes) but it does not have lvresize (guess what it is needed for?).

Finally I ended up firing up the bootup process from a Debian “netinstall” CD, entered rescue in the bootloader prompt and switched to the second console just after the installer detects hardware and before it mounts disks. Then it was only a matter of typing:

 # vgchange -an vg
 # lvresize -L +300M vg/base

Then reboot the installed system and make the XFS filesystem grow with:

 # xfs_growfs /

…and you are done :)


4
Jul 08

Maintaining your LVM snapshots clean

As I have written before snapshots is a extremely fast and convenient way of perfoming live backups which can be mounted and handled like any other filesystem. But I also told you that LVM snaphots could render themselves as unusable when they run out of free blocks. Today I hacked up a quick script which automagically increments sizes of snapshots logical volumes. Just drop the following snippet into /etc/cron.hourly and relax:

#! /bin/bash

THRESHOLD="80"
INCREMENT="15"

set -e
IFS=':'

/sbin/lvs --noheadings --units M --separator : | \\
while read lv vg attr lsize origin snapp move log copyp
do
  # Check whether this is a snapshot or not
  [ "${snapp}" ] || continue

  snapp=${snapp%.*}
  lv=${lv// /}

  # Check whether the thing needs resizing
  [ "${snapp}" -ge "${THRESHOLD}" ] || continue

  lsize=${lsize%.*}
  isize=$(( INCREMENT * lsize / 100 ))
  echo "lvresize -L +${isize}M ${vg}/${lv}"
  /sbin/lvresize -L "+${isize}M" "${vg}/${lv}"
done

You can change the following settings:

  • THRESHOLD is the percent of usage which triggers resizing. When actual usage is greater than this value snapshots will grow.
  • INCREMENT is used to calculate how much size is added to the volume, it is a percent of the current volume size.

Of course the script could be improved (i.e. it could check whether there are space for growing in the volume group), but this naïve implementation is enough to make me happy and not to worry about checking status of my snapshots periodically :D


3
Jul 08

Taking snapshots with LVM

Let us suppose we have a volume group named vg. Let us suppose we have a logical volume named base which holds our precious data in a 800 MB file system which has support for freezing (e.g. XFS). So we can take snapshots at any time with a single command:

# lvcreate --size 200M --snapshot --name snappy /dev/vg/base

Now we can mount it whenever we want to recover from the saved status:

# mount -o nouuid,ro /dev/vg/snappy /mnt

The nouuid option is needed for XFS filesystems, otherwise the driver will think it is mounting the same filesystem and will refuse to mount the snapshot. Take into account that:

  • Blocks in the source volume are stored on-demand in the snapshot volume when they are changed.
  • If mounting the snapshot in write mode, written blocks will be stored in the snapshot volume.
  • You can make the original filesystem grow, but it cannot be shrunk.
  • Snapshots can be grown and shrunk.
  • If a snapshot runs out of free blocks, it will render itself unusable: make sure you check its status periodically with lvdisplay and grow it as needed.

Currently I am using snapshots as a quick-come-on-let’s-go backup method for the root filesystem of a Debian installation I am using for a project. If somethings goes wrong one can mount the snapshot and restore files from the snapshot… or one can even boot up from a snapshot by setting root=/dev/mapper/vg-snappy in the kernel command line… :D


26
Jun 08

More btrfs goodness: snapshots

As I am currently working with KVM KVM and I will have some big disk image files hanging around, I thought it could be a good opportunity to give a try to the btrfs snapshot and subvolume support. You can take a look at my previous post

First of all: snapshots and subvolumes are the same to btrfs. To be fair: snapshots are subvolumes with initial content. The nice thing about btrfs is the Copy-On-Write (COW) semantics: snapshots do not take physical space until blocks are overwritten, and only new versions of overwritten blocks are allocated from free space. This is a lot similar to KVM/Qemu snapshots when dealing with images in the qcow2 format. The difference is that you can mount a btrfs volume: you get features designed for virtualization right on the filesystem level! Once again old technology is applied in a novel way :-)

I have a btrfs volume mounted at /mnt/misc, and a 1GB Debian “Etch” image and a file with some notes about the image:

# ls -l /mnt/misc
-rw-r--r-- 1 root root 1000000000 2008-06-24 20:44 etch-base.img
-rw-r--r-- 1 root root         60 2008-06-24 18:35 etch-base.txt

Now let us create a snapshot named snappy:

# btrfsctl -s snappy /mnt/misc
# ls -l /mnt/misc
-rw-r--r-- 1 root root 1000000000 2008-06-24 20:44 etch-base.img
-rw-r--r-- 1 root root         60 2008-06-24 18:35 etch-base.txt

Hey! Wait a second! Nothing seems to happen!… This is due to all subvolumes and snapshots hanging from the filesystem root, and the default subvolume is mounted (you guessed it) by default. Let’s remount another subvolume:

# umount /mnt/misc
# mount -o subvol=snappy /dev/hda1 /mnt/misc
# ls -l /mnt/misc
-rw-r--r-- 1 root root 1000000000 2008-06-24 20:44 etch-base.img
-rw-r--r-- 1 root root         60 2008-06-24 18:35 etch-base.txt

Nothing impressive… now for the fun part we will add some garbage, and mount all the subvolumes at once:

# touch /mnt/misc/hello-btrfs.txt
# echo 'btrfs rocks' >> /mnt/misc/etch-base.txt
# umount /mnt/misc
# mount -o subvol=. /dev/hda1 /mnt/misc
# ls /mnt/misc
default  snappy

Now the mount point shows a directory for each subvolume, and the files are really there:

# ls /mnt/misc/*
/mnt/misc/default:
etch-base.img  etch-base.txt

/mnt/misc/snappy:
etch-base.img  etch-base.txt  hello-btrfs.txt

Now please run df -h /mnt/misc by yourself and get surprised: only about 1GB of physical space is really in use. In fact that can even be less than 1GB, as btrfs supports sparse files as well (if there are “gaps” they do not take physical space). Final remark: you can also make snapshots of snapshots.


24
Jun 08

Simple XFS and btrfs timings

Last weekend I was able of emptying a partition and had the opportunity of testing btrfs for first time. I made some simple timings using the Bash time builtin. The test was building a Linux kernel with the default configuration (make defconfig). I timed the time needed for unpacking kernel sources, building and removing the tree afterwards. The results against XFS are as follows:

Phase XFS (usr/sys) btrfs (usr/sys)
Unpack 115.2 / 6.3 38.6 / 10.3
Build 758.6 / 90.4 667.5 / 110.1
Remove 0.07 / 3.6 0.07 / 6.3

All measurements are shown in seconds, so smaller numbers means better performance. I was surprised with how fast was unpacking kernel sources on btrfs, so I was expecting a slightly better build time. The reason for the similar build times can be the fact that the tools (compiler, linker, etc) were running from a XFS partition, and that it was a CPU-bound. Both test over XFS and btrfs were done after a clean system boot and freshly created filesystems.

What I loved about btrfs was the ability of growing and shrinking the filesystem while mounted and being accessed, which makes it a perfect candidade for its use over LVM. I still have to try out subvolumes, live writable snapshots, and making some serious testing. Even so, btrfs looks like a Good Thing™ to me.