Posts for the month of October 2010

One Way to Support the FreeBSD project

One way to support the FreeBSD project is to donate funds, but a much more interesting way of donating to the FreeBSD project is to run your own freebsd router/appliance/server which joins in on the FreeBSD ISO torrent website.

This a rather simple job. First install file:net-p2p/transmission-daemon and depending on your favorite way go for the web solution file:www/transmission-web --make sure to change the ACLs to match your setup-- or the CLI file:net-p2p/transmission-cli.

Next make sure TCP port 51413 inbound is allowed (or configure your transmission-daemon to use a different one.

Make sure you install at least the most popular ones (the full release versions like (file:8.1-RELEASE-amd64-all and file:8.1-RELEASE-i386-all). By manually adding the torrent links to the queue. Wait... you can also try my hack to automatically use the latest available torrents (useful to quickly get in sync on a new releases). Take a look at source:transmission/rss-sync.sh

As I have FreeBSD installed on CF card readonly, I host the torrents of a mobile USB hard drive mounted at file:/data which makes my config source:transmission/settings.json a bit different than the usual ones.

EFI and GPT two new kinds in town

Introduction

EFI (Extensible Firmware Interface) GPT (GUID Partition Table) have been around for a while. As a matter of fact the have been under my fingers for almost two years, as my MacBookPro4,1 had both available.

So why the sudden interest in them? I got forced re-installing my operating systems when I was playing around with FreeBSD experimental installs (say bye-bye to the partion table, my own fault!). Hence I thought it would be nice to make a QuadBoot+ system of it.

Using the good old MBR way I could in theory host 4 Operating Sytems, but their is a 'hidden' EFI firmware-to-be-installed-and-used-maybe-in-the-future-partion causing this great plan to fail. As this was claiming one of my presious MBR partions. So here is where GPT comes into handy. This partion scheme allows us to use as many partions as we want. And with an hybrid setup the 4 partions are synced back to MBR partions allowing the ooldies in OS world to still boot somehow.

So here is where EFI comes around the corner. As this (in theory) allows booting to other partitions as this is NOT a standard PC-BIOS thing ---and so does not behave like one _really_!--- you will endup in some big pain if things go wrong.

Planned setup

First things first. The Planned Partion layout with type and mount point if needed. Due to the hybrid setup partions can be dual labeled.

  1. EFI firmware
  2. Linux (ext4) (/ mountpoint)
  3. FreeBSD (ufs)
  4. Windows XP (NTFS)
  5. MacOSX (hfs+)
  6. Linux (swap)
  7. Linux (ext4) (/home mountpoint)
  8. FreeBSD (swap)
  9. Windows7 x64

Problems

First thing to wonder, why Windows XP on partion 4, just because, if you don't it simply fail no explanation possible. It also does NOT support any EFI/GPT magic so you will need the good old 'bootcamp'/hybrid way.

Secondly Windows7 x64. Note that the i386 versions does not support EFI at all. Also MacbookPro4,1 has UEFI implementation 1.1 while Windows7 _really_ needs UEFI implementation 2.0. So no luck for the Windows7 as well.

Next Linux (or Ubuntu 10.10 in my case). When you try to run it with a native EFI boot loader by following the guide: http://grub.enbug.org/TestingOnMacbook you will find yourself in a pretty useless situation as the linux kernel (and both nouveau/nvidia kernel modules) makes all kind of assumptions about having a PC-BIOS at all. The provided emulation is not actived when booting with native EFI and grub is (not yet) smart enough to get all going again. So you will end up with a not working system (altough bootable and with some basic screen capacities).

FreeBSD (8.1-RELEASE) does not even support booting natively from EFI yet (motivation found so far: the EFI loaders, provide enough BIOS emulation to get it booting anyways), but does support GPT out-of-the-box. But their gptboot enabled loader thinks as beeing the only one in the world and is not capable of booting any other operating system. So we are going to need GRUB2 to fire off this partion.

Working setup

  1. First of all install MACOSX and create your partions using the 'Disk Utility'. You can format them HFS+, and the windows partion FAT32 as you can savely reconfigure at later stages. But you really only need one FAT32 in your list of first 4, else the windows installer gets confused.
  2. Now intall rEFIt, this GUI EFI loader will save you a lot of keypressing and hoping the embedded bootloader picks the right CD/disk/whatever.
  3. (Optional): Install Windows XP, I have not tried it, but it should work fine.
  4. Have rEFIt 'resync' partions before trying to boot anything.
  5. Install Ubuntu, the GRUB2 bootloader automatically get installed on the MBR bit which we later need to boot all kind of OS fun.
  6. Have rEFIt 'resync' partions before trying to boot anything.
  7. Install FreeBSD, the manual way, don't use the sysinstall and DO NOT install the bootloader/bootmanager as this will have you to restart again.
  8. Point your Grub boot loader to also allow booting to FreeBSD (see my previous blog post).

Conclusion

GPT is a pretty usefull and workable subsistute for MBR, to finally get rid of the pain which comes when installing multiple Operating Systems (or versions of it) and is also nicely supported by all modern operating sytems.

EFI on the other hand really needs working on. GRUB2 and Linux, kind of work. But FreeBSD is not supported/working yet and also does not provide a native loader to start with. Windows7 really needs modern hardware which seems like a resonable choice as mine notebook is older than 2 years and is barely specd to run it anyways.

Will keep you posted as I really like to run native EFI powered OS to finally say goodbye to PC-BIOS. Which is in my option be around for far to long.

How-to boot FreeBSD with Grub2 under Ubuntu 10.10

I recently upgrade to Ubuntu 10.10. Which also caused grub to be updated to version 1.98 (to be exactly {1.98+201000804-5ubuntu3), which used a different syntax to define partitions instead of numbers which where off by one, they now use msdosX style formatting.

My FreeBSD is located at /dev/sda3 on a good old MBR partition table and I want to use the good old FreeBSD boot loader as well (so chainloading is required). To activate within Ubuntu. Put the following contents in file:/etc/grub.d/40_custom:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "FreeBSD (on /dev/sda3)" {
        savedefault
        insmod chain
        set root='(hd0,msdos3)'
        chainloader +1
}

Note: My hd0 is file:/dev/sda under Linux and got named file:/dev/ad6 under FreeBSD If you want to boot of a GPT partion use the following syntax

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "FreeBSD (on /dev/ad6p3)" {
        savedefault
        insmod ufs2
        set root='(hd0,gpt3)'
        kfreebsd /boot/loader
}

Update your grub and use should be done: rick-eee$ sudo update-grub

Image sorting with oneliners

I have many images on my devices, which can become messy after a while. Today I like to have all my images from my (old) Nokia N95 archived in two (year) folders:

Tip: This require installing the exif package. Note: The quotes and -I templating is needed as some files contained spaces within them.

First find me all pictures including the thumbnails and other junk from some old photo editing software program and store them in an folder called dir:/media/RICK_250GB/Pictures/N95/ :

$ find . | grep -i 'jpg$' | grep -v '/\.' | grep -v 'Data\.noindex'  |\
  xargs -n 1 -I % sh -c "exif '%' | grep -q 'N95' && \
  cp '%' /media/RICK_250GB/Pictures/N95/"

Some other raw pictures also got included, I only want the ones from the N95 which have exact 11 digits and have prefix jpg. So get rid of all others:

$ cd /media/RICK_250GB/Pictures/N95/
$ ls | grep -v -E '^[0-9]{11,11}\.jpg*' | xargs -n 1 -I % rm '%'

Now store all in the correct folder:

$ cd /media/RICK_250GB/Pictures/N95/
$ mkdir 2008 2009 2010
$ ls * | xargs -n 1 -I % sh -c 'echo mv % `exif -t 0x9003  -m % | cut -c 1-4`/%' | sh