Unix Stuff

This is some random stuff I've done with Unix/Linux that I didn't find on Google. Now you can ;)


A cleaner way to configure Xen bridged networking

Here is a little writeup I did explaining how to configure Xen networking on top of 802.1q VLAN's and bridged networking in a way that won't melt your brain. This works really well in dual-homed dom0's where one interface is used for dom0 traffic only (including NAS!) and the other is only used for 802.1q trunking.


Custom initramfs script:

I've had a ton of trouble with distributions' initramfs/initrd programs failing to produce useful images for systems with / on LVM2. This is made worse when working in a Xen environment, for some reason. Redhat seems to have gotten it right, but Ubuntu and Gentoo still screw it up. Yaird wasn't a whole lot better. They're all too keen on being automatic and hiding the shell stuff. I wanted something simple and hackable.

Here are the results of my desires. Edit it to add your disk and filesystem drivers to $modules. Testing the image and /init script in a chroot is dangerous! Make sure "realroot" is always unmounted before rerunning either script or the rm -rf will walk through your whole system.

The truly beautiful thing about this script is that it builds a single initrd for every kernel in /lib. Just modify your lilo/grub config to point at this initrd for all kernels and you should be good to go.

make_initramfs.sh
test_initramfs.sh


Building free software for multiple platforms:

I imagine every admin has worked out their own way to do this, but these are how I've documented the way I like to do it. I use this style for more packages than are listed here both at work and at home.

One advantage I've had with this over the years, is that as HP and Redhat upgrade their operating system, I can just rsync these components over tho the new OS and worry about rebuilding later. It just works unless there is a major architecture change, but even then it still works in some cases. I carried the same perl-5.6.1 install from Redhat 7.0 through 7.3, 8.0, 9.0, RHEL3, and RHEL4. I even copied it over to other distributions like Debian and Slackware where it also worked just fine. To this day, I rsync my workstation's /opt to one of the Linux servers and get the same components to work with.

Here's the rsync command I use for distribution:

root@destination> rsync -ave username@sourcehost:/opt/perl-5.8 /opt

I'm actually planning on formalizing this into something that can be managed in a subversion repository for Linux, HP-UX, and Win32 with shareable pieces shared. Send me an email if you're interested in this. Since I'm not a full-time sysadmin at the moment, I may not end up having a lot of time to work on this.


pdksh 5.2.14 on HP-UX 11.23 Itanium

If you grab the source for pdksh and try to compile it on Itanium HP-UX, it will tend to dump core with SIGBUS. SIGBUS is a signal sent to processes when they access unaligned memory, usually in C unions or structs. pdksh has a union in it that ends up unaligned on Itanium, which is very particular about such things. HP-UX is also fussy.

Go into the source tree and open up "alloc.c" in your favorite editor. Search for "union Cell", which is the union declaration that is causing the trouble. Change the last member "double djunk; /* alignement */" to "long double djunk; /* alignemnt */." On Itanic, long double is 128 bits and double is 64 bits. Pushing the union out to 128 bits makes it align right all the time, even though it does eat up a bit more memory now.

I also recommend editing the Makefile after configuring and changing the CFLAGS to have "+DD32 +Z" and LDFLAGS to have "-L/usr/lib/hpux32." [still need to check this next time I'm at work].

One of these days I should post the patch that causes all commands executed by root when su(1)'ed to to be syslogged with the username.


Bootprofile

Here is a drop-in replacement for Rajeev Kumar's bootprofile, written in (bourne|korn|posix) shell. Everything required [on my rh9/rawhide laptop] is in /bin or /sbin. It's nice when you like to put everything on separate LVM volumes like I do. Here it is: bootprofile.sh. View now: bootprofile.sh.txt. Last update: December 02, 2003.
Screenshot (46k)


root-tail

I hacked root-tail to work with Nautilus, KDE, and hopefully XFCE4's xfdesktop. I took the toon_root.c file from xpenguins and :r'd it into root-tail.c. A few modifications later and I had a working root-tail for nautilus. Download the tarball: root-tail-xpenguins.tar.gz or just root-tail.c. Here it is in HTML: root-tail.c.html.
Screenshot (40k)


Nagios

I wrote a couple SNMP plugins for Nagios to check disk space and running processes. They are now in the contrib directory in the Nagios Plugins package.
They both should work on Windows 2000 (and up) and Novell. HP-UX, unfortunately, does not ship with the Host-Resource MIB by default, so I'm using the Net-SNMP daemon at work. It's a little flakey, but gets the job done. SNMP Research provides an extended SNMP daemon for HP-UX and other operating systems that includes the host resource MIB.

I'm also author and maintainer of the Nagios::Object and Nagios::Cmd modules on CPAN.