Systems

Have btrfs installed and running

I went ahead and reinstalled wont with FC14 – I probably could have done a:

[root@wont ~]# yum install btrfs-progs
[root@wont ~]# modprobe btrfs
[root@wont ~]# mkfs.btrfs -L VMstordev /dev/sdb /dev/sdc /dev/sdd
[root@wont ~]# mount /dev/sdb /kanigix

The hardest thing was getting the /etc/fstab correct because of the need to probe for devices after boot time:

/dev/sdb /kanigix btrfs defaults,device=/dev/sdb,device=/dev/sdc,device=/dev/sdd 0 1

Guruplug server for Xmas

I got a Guruplug Server for Xmas and right away I noticed the noise – the system is loud.

I bought a 8G thumb drive for the filesystem, so once I upgrade the kernel, I’ll have a hot spare sitting there for my dns, nis, mail, etc.

Disks from zfs pool not letting system boot

I had put some disks in a zfs pool on another system. When that went away, I eventually added the disks to my son’s old system. And it would not boot.

I had issues with the system back when it was running OpenSolaris circa build 42, so rather than suspecting the system, I was wondered whether it might be an issue with the disk format.

So I pulled the drives and Windows 7 did not recognize them (and by the way, I evidently still have several disks from a zfs pool on my desktop, because they were not recognized either). I initialized them and then put them back into the machine now running Fedora Core 14. And boot!

Now I need to figure out how to make them work as a filesystem. I’m thinking btrfs, but I want to keep the root as is and use the three new drives as a different filesystem.

Creating a small zpool for testing

tdh@ultralord:/$ sudo su -
Sun Microsystems Inc.   SunOS 5.11      snv_133 February 2010
You have new mail.
root@ultralord:~# cd /
root@ultralord:/# mkdir ztmp
root@ultralord:/# cd ztmp
root@ultralord:/ztmp# mkfile 100m vdev1
root@ultralord:/ztmp# mkfile 100m vdev2
root@ultralord:/ztmp# zpool create zoo /ztmp/vdev1 /ztmp/vdev2
root@ultralord:/ztmp# zfs list
NAME                     USED  AVAIL  REFER  MOUNTPOINT
rpool                   4.84G  10.8G  77.5K  /rpool
rpool/ROOT              3.72G  10.8G    21K  legacy
rpool/ROOT/opensolaris  3.72G  10.8G  3.60G  /
rpool/dump               511M  10.8G   511M  -
rpool/export            89.9M  10.8G    23K  /export
rpool/export/home       89.8M  10.8G    23K  /export/home
rpool/export/home/tdh   89.8M  10.8G  89.8M  /export/home/tdh
rpool/swap               544M  11.2G   144M  -
zoo                     73.5K   159M    21K  /zoo
You have mail in /var/mail/root
root@ultralord:/ztmp# zfs set sharenfs=rw=10.10.10.20 zoo
root@ultralord:/ztmp# zfs create -o sharenfs=rw=10.10.10.20 zoo/fs1
root@ultralord:/ztmp# zfs create -o sharenfs=rw=10.10.10.200 zoo/fs2
root@ultralord:/ztmp# share
-@zoo           /zoo   sec=sys,rw=10.10.10.20   ""
-@zoo/fs1       /zoo/fs1   sec=sys,rw=10.10.10.20   ""
-@zoo/fs2       /zoo/fs2   sec=sys,rw=10.10.10.200   ""
root@ultralord:/ztmp# touch /zoo/file
root@ultralord:/ztmp# ls -la /zoo
total 7
drwxr-xr-x  4 root root  5 2010-11-03 16:51 .
drwxr-xr-x 29 root root 31 2010-11-03 16:50 ..
-rw-r--r--  1 root root  0 2010-11-03 16:51 file
drwxr-xr-x  2 root root  2 2010-11-03 16:51 fs1
drwxr-xr-x  2 root root  2 2010-11-03 16:51 fs2
root@ultralord:/ztmp#

Thinking control versus command

I’m trying real hard to make that final switch to OS X and the biggest problem I am having is thinking “Control” instead of “Command” when I want to do a meta-operation. In Windows, I’d do a Ctl-C instead of a Cmd-C. So I’ve been letting myself get away with it.

Now that I’m trying to be legit, I find the thought process is impacting the finger process.

A recursive gdb script for Binary Trees

If we have a binary tree, how do we determine if a key is in the tree? Or another way, how do we know it was inserted correctly? We need to visit every node.

This is a recursive problem and hard to do in gdb. The convenience variables are very simple and we can not implement a stack with them. Since they are effectively global, we can not even hide them in stack frames. What we can do is use concatenation and a node-id to generate uniqe names.

Note that you have to do all variable name declarations before you do any recursion. That statement will make sense when you violate it and wonder why your output looks strange.

define indentby
        printf "%*c", $arg0+1, 0
end

define walk_btree
        set $node_$arg0 = ($arg1)
        set $fnum_$arg0 = ($arg2)
        set $branch_$arg0 = ($arg3)
        set $space_$arg0 = ($arg4)
        set $leftid_$arg0 = $arg0 + 1
        set $rightid_$arg0 = $arg0 + 2

        indentby $space_$arg0
        printf "%d %u (btree *)%p\n", $branch_$arg0, $node_$arg0->e_type[$fnum_$arg0].key, $node_$arg0

        set $space_$arg0 = $space_$arg0 + 1
        if $node_$arg0->e_type[$fnum_$arg0].left
                walk_btree $leftid_$arg0 $node_$arg0->e_type[$fnum_$arg0].left $fnum_$arg0 0 $space_$arg0
        end
        if $node_$arg0->e_type[$fnum_$arg0].right
                walk_btree $rightid_$arg0 $node_$arg0->e_type[$fnum_$arg0].right $fnum_$arg0 1 $space_$arg0
        end
end
document walk_btree
        NODE-ID NODE FNUM BRANCH INDENTBY
        Recursively walk the binary tree printing out the key for the fnum'ed entry
end

define start_walk_btree
        walk_btree 0 $arg0 $arg1 3 1
end
document start_walk_btree
        NODE FNUM
        Recursively walk the binary tree printing out the key for the fnum'ed entry
end

Contrast that against a very simple algorithm to find if the key is in the tree (with the assumption the tree is valid).

Recursion is not needed as we lop of a branch with each iteration.

define find_btree
        set $node = $arg0
        set $fnum = $arg1
        set $key = $arg2
        set $process = 1

        while $node && $process
                if $key == $node->e_type[$fnum].key
                        set $process = 0
                else

                        if $key < $node->e_type[$fnum].key
                                $node = $node->e_type[$fnum].left
                        else
                                $node = $node->e_type[$fnum].right
                        end
                end
        end

        if $node
                printf "Found match on (btree *)%p\n", $node
        else
                printf "No matching node in the binary tree\n"
        end
end

Using xargs to apply tshark to many capture files

pktt on a filer can capture for all network interfaces on a head. In order to quickly determine which have relevant data, we can use xargs:

KinMage:csiqa-6080-15 thomas$ ls -1 *021* | xargs -I {} -t tshark -R nfs -r {}
tshark -R nfs -r e0a_20101021_090354.trc
tshark -R nfs -r e0b_20101021_090354.trc
tshark -R nfs -r e0c_20101021_090354.trc
tshark -R nfs -r e0d_20101021_090354.trc
tshark -R nfs -r e0e_20101021_090354.trc
122   0.265844 10.227.74.89 -> 10.227.67.203 NFS V4 COMPOUND Call <EMPTY> PUTFH;CLOSE;GETATTR
123   0.267673 10.227.67.203 -> 10.227.74.89 NFS V4 COMPOUND Reply (Call In 122) <EMPTY> PUTFH;CLOSE
tshark -R nfs -r e0f_20101021_090354.trc
tshark -R nfs -r e4a_20101021_090354.trc
tshark -R nfs -r lo_20101021_090354.trc
tshark -R nfs -r losk_20101021_090354.trc
KinMage:csiqa-6080-15 thomas$ cd ../csiqa-6080-16/
KinMage:csiqa-6080-16 thomas$ ls -1 *021* | xargs -I {} -t tshark -R nfs -r {}
tshark -R nfs -r e0a_20101021_090347.trc
tshark -R nfs -r e0b_20101021_090347.trc
tshark -R nfs -r e0c_20101021_090347.trc
tshark -R nfs -r e0d_20101021_090347.trc
tshark -R nfs -r e4a_20101021_090347.trc
tshark -R nfs -r lo_20101021_090347.trc
tshark -R nfs -r losk_20101021_090347.trc

So we see the first head saw NFS traffic on e0e, but the second saw none.

tshark, my new favorite command line tool

[thomas@godwit ~]> tshark -R nfs -r e4a_20101020_223437.trc
9   1.020806 10.225.212.66 -> 10.225.212.116 NFS V4 NULL Call
10   1.020972 10.225.212.116 -> 10.225.212.66 NFS V4 NULL Reply (Call In 9)

Going KVM

I’ve been cleaning up the clutter in my office and as much as I like having a keyboard for each computer, it isn’t like I can type on both at the same time. So I dug out my iogear GC634U 4-port USB KVM switch. Now I like the form factor and such, but it only does VGA, despite being shown on the box working with Mac Minis.

So I’ve just hooked up the KM and left the V on the roadside. I do use multiple displays at the same time, so this is a plus.

Anyway, the hotkeys are [scroll-lock][scroll-lock] and the Macs do not have that key. You can reprogram that with [clear][-] and once the [caps-lock] starts blinking, [t]. At that point [control][control] will be your hotkey initiator. And to cycle through the attached machines, [control][control][return]. I.e., I don’t care to remember which ports I have hooked up.

I haven’t made the jump to attaching my Win7 box yet.

Oh yeah, on the two interior cable sets, the ones not always attached, the white capped connector goes to the KVM and the blue capped one (which has the USB and audio cables) goes to your computer.