Tuesday, January 29, 2008

From Linux to FreeBSD with Depenguinator 2.0

If you read Colin Percival's blog you will notice he posted a message about Depenguinator 2.0. This is a method to convert a Linux system to FreeBSD remotely. Colin tested the script using Ubuntu 7.10. I have a few Red Hat 8.0 systems and one or more Fedora Core 4 systems that I would like to convert to FreeBSD 7.0.

I tried using Depenguinator 2.0 to convert a test CentOS 5.1 system to FreeBSD 7.0, but I ran into multiple problems. These included difficulty installing Depenguinator dependencies and possible interference from SELinux capabilities.

If someone wants to try testing Depenguinator 2.0 on a Red Hat 8.0 system or a Fedora Core 4 system, please do so and let me know how it goes. Thank you.


Kev said...

I tested the same systems as you last night (CentOS 5.1 -> FBSD 7) and had mixed results.

I managed to get round SElinux (switched it off ;) ) and I managed to solve the dependencies for building :

- uudecode I used from busybox-anaconda

- bsdtar I build from hand from the libarchive source. This require the bzip libs installed to build with the -z compression option

If you have better solutions for the above, I'd be interested to hear.

This, along with a FreeBSD 7 RC2 CD successfully built the disk.img file after running depenguinator.

However...Colin's instructions fall down slightly here as, assuming a stock install, RHEL / CentOS boxes come with swap as part of an LVM partition.

This leaves only /boot as the spare partition to dd the depenguinator image onto. However you do this, and you lose grub.

Whilst Colin's solution is elegant it's not very flexible. I tried the below with mixed results :

- dd'd the image to a seperate drive (sdb1) and told grub to boot from there. Grub returned an error (off the top of my head something aking to an unknown binary type)

- dd'd the image to /dev/hda1 (the /boot partition) which left the grub loader intact on the boot sector. Attempted to manually tell grub to load from there. Grub reported it didn't know what type of partition /dev/hda1 (hd(0,0)) now was and failed.

- dd'd the image directly to /dev/hda. This booted and gave me the FreeBSD bootloader but then error'd trying to boot the FreeBSD kernel (kernel / loader not found).

So mixed results. I'm going to replicate Colin's instructions precisely (using Ubuntu) tonight or tomorrow. It may be slight differences in Ubuntu's built libraries that cause a difference in behaviour? Certainly I seem to have built the image with success - it's just having problems booting!

Hope this helps some, if I can fill in any gaps let me know.

As you were the original 'bounty' requester - is Colin looking to tailor this to RHEL / CentOS / Fedora for you?

Richard Bejtlich said...

Hi Kev,

Thanks for your post!

I plan to use "local hands" and an IP KVM at this point, so anything Colin does is a bonus.

Kev said...

Agreed...the fact the image builds probably means I'm at fault somewhere!

Its a perfect foundation to work on, I can't wait to get it working.

eriko said...

I tried this on an older Slackware install (we're talking Slackware 9, using Lilo and something around a 2.6.8 kernel--very old stuff, here.) It seemed to work perfectly once I got the Lilo configuration right.

The only real gotcha was that I had to change the partition type of the new partition to A5 (FreeBSD) from 82 (Linux Swap) before it would boot.

I was quite pleased that it worked so well on such an older system.

I'm planning on adding a sysinstall script to the image so that I can pretty easily install the new OS.