June, 2008


26
Jun 08

Tip: Faster remote shells with multiplexed SSH

Edit ~/.ssh/config (or /etc/ssh/ssh_config for sitewide configuration) and add the following snippet:

Host *
   ControlMaster auto
   ControlPath ~/.ssh/socket-%r@%h:%p

This will create a socket for each set (user, machine, port) when the first SSH session is opened. Further sessions will see the socket and use it instead of opening a new connection, multiplexing all concurrent connections via the same connection. The same goes for scp and sftp.

Nice side-effects of this:

  • No functionality is lost at all.
  • SSH sessions will open faster, as there is no need to establish a connection.
  • You will not need to enter you password everytime (but note that maybe you should be using public-key authentication).
  • You can open several sessions to servers which put a limit on the number of simultaneous connections.
  • If you are a sysadmin, you can limit the number of SSH connections to exactly one per user :-)

Hope you find this tip useful :-P


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.


18
Jun 08

Oh Yeah! Consoles everywhere

Cannot live without a terminal at hand? Maybe you already know about other drop-down terminals, and I have been using Tilda myself for a long time. But let us forget about them and enter yeahconsole:

  • Animation is so smoooooth~~ :)
  • Has full-screen mode. Also, full-screen status is remembered when you close and re-open it.
  • Binary is only 15kB (on AMD64).
  • Only depends on libX11 and an installed xterm (works with rxvt, too.)

I tuned up yeahconsole to fit nicely with the Gnome desktop by adding the following entries in my ~/.Xdefaults file:

yeahconsole*toggleKey: Control+Escape
yeahconsole*keySmaller: Control+minus
yeahconsole*keyBigger: Control+plus
yeahconsole*keyFull: None+F11
yeahconsole*restart: 1
yeahconsole*handleColor: orange

Favourite colors for the terminal can also be specified, but if you already have configuration entries for xterm (as I do) they will be reused. The only feature I miss is support for consoles on multiple tabs; even so I hardly use tabs in my drop-down terminals, so I can live without them.


16
Jun 08

Hello world!

So… brand new Igalia worker: brand new work mates, brand new office, brand new experiences at Arbo, brand new coffee machine… and brand new weblog. Here I will be blogging about my experience while ensuring all works at the systems area, but maybe some code kicks in, as I also enjoy programming. As this is just a presentation post, let me say «Hello, world!» in a multi-language fashion:

C=0;/*Hello_World 2>/dev/null
#! /bin/bash
*/
#define echo main() { printf(
#define exit "\\n"); }
echo "Hello, world!"
exit
/*
#! perl
print "Hello, world!\\n";
__END__
_*/

This snippet works as C, Perl and Bash programs, just save it to a file and try to run it:

$ perl -x source.c
Hello, world!
$ bash source.c
Hello, world!
$ gcc -o hello hello.c && ./hello
Hello, world!
$

Do not try too hard to understand it… your brain could melt as mine did while trying to add support for AWK ;-)