December 16th, 2010

Fiddling with code.

So, I need to make nfs mounts work in an OpenVZ container, which first involves setting up a test environment to demonstrate them _not_ working in a container.

So, build the upstream NFS tree with container support enabled, fire it up under kvm using the busybox/uClibc root filesystem I have lying around (from Aboriginal Linux), and try to build lxc. The invocation for kvm, by the way, is a simple:

kvm -m 1024 -kernel arch/x86/boot/bzImage -nographic -no-reboot -hda ~/play/aboriginal/build/system-image-x86_64/image-x86_64.ext2 -append "root=/dev/hda rw init=/sbin/ panic=1 PATH=/bin:/sbin console=ttyS0" -net nic,model=e1000 -net user

(Once I've glossed over the details of adding squashfs support to the kernel config, noticing that the /bin/sh symlink is wrong to actually build anything serious because hush doesn't even make "./configure --help" work but not wanting to fiddle with jumping through the hoops in this context so rebuilding with ext2, noticing that the kernel has ext3 but not ext2, and running tune2fs -j on the image).

So I wget the lxc source and run configure. It wants libpcap-devl, which isn't a package but this thing is so redhat-centric it's crazy. The libpcap source is on the tcpdump website, and building it wants flex, which wants m4. Build all that. It still complains about lex but you have to read the small print that if bison isn't installed it downgrades flex to lex, which isn't installed. So install bison. Now lxc wants libcap-devel, which again doesn't exist, and when you google for libcap google thinks you mean libpcap (oh yeah, this package gets used a lot). The package is actually called "libcap2", which is apparently for the people who think selinux isn't complicated enough. Linux capabilities, based on an abandoned posix draft! And there's no way to disable it in the lxc build. And lipcap2 requires perl to build.

Right, no embedded user will ever want to get any of this thing on them, it's enterprise all the way, and that means use an existing distro. Time to read a Debian Chroot howto while running "debootstrap lenny /home/landley/lenny".

Meanwhile, openvpn doesn't seem to like me. I got the key files, was told what directory to put them in, and it's not working. My /etc/resolv.conf has nameserver addresses for my wireless, not for the vpn. Poked the support guy who said that /etc/openvpn/update-resolv-conf should be updating this. I ran that, and it succeeded, but nothing happened.

The /etc/openvpn/update-resolv-conf script is there, but the first thing it does is: "[ -x /sbin/resolvconf ] || exit 0", and my Ubuntu system has no /sbin/resolvconf. So it exits silently, with no error, after doing nothing. (Who wrote this?) I ran "sudo aptitude install resolvconf", and then ran update-resolv-conf again... and it again exited silently again after doing nothing. Reading the script, it wants "up" or "down" and does nothing otherwise. So I ran "/etc/openvpn/update-resolv-conf up" and it once again exited silently after doing nothing because it wants additional undocumented arguments... Ok, "/etc/init.d/openvpn stop" (says no vpn is running), "/etc/init.d/openvpn start" says it started a vpn... and /etc/resolv.conf is still unchanged.

Whole lot of doing nothing silently with no error going on with this infrastructure. Yay it being open source and all, but it would be nice if it would either work or tell me why not...

On the phone with UPS to see why they couldn't deliver a package. Android decided me pressing the "stop being speakerphone" button meant I wanted to hang up (the touchpad is hilariously inaccurate sometimes), so I'm on hold again... And I have to go pick it up...

kvm and the art of unicyle maintenance.

So, if you need a debian chroot for some reason, here's whatcha do. (As root, assuming you install all these commands.)

debootstrap lenny ~/lenny
chroot lenny
passwd # set the root password

Now make an ext2 image out of it.

genext2fs -z -d ~/lenny -i 1024 \
-b $((1024*(($(du -m -s ~/lenny | awk '{print $1}')*12)/10))) lenny.ext2
resize2fs lenny.ext2 2048M
tune2fs -c 0 -i 0 -j lenny.ext2

(I have no idea why genext2fs won't calculate the number of blocks it needs, that -b blob calculates is the amount of space it's using plus 20% for various administrative overhead like inode tables and such. It then fluffs it up to 2 gigabytes as a separate step; you could just tell genext2fs to make a big image but for some reason its behavior is nonlinear so that takes over 10 minutes to do that while the two steps separately are a few seconds each. Oh, and genext2fs creates an 11 megabyte _empty_ lost+found directory, you might want to delete that.)

Now you can chown lenny.ext2 back to a non-root user and switch over to there, build a kernel, and boot it up under kvm:

kvm -m 1024 -kernel arch/x86/boot/bzImage -no-reboot -hda ~/lenny.ext2 \
-append "root=/dev/hda rw panic=1" -net nic,model=e1000 -net user

When it boots up, you'll need a bit more configuration (starting with "dhclient eth0", maybe "aptitude update", and lots of aptitude install packages), but that's another post.
  • Current Mood
    contemplative contemplative
  • Tags