Booting FreeBSD from GPT (for large disks)

This is how to make freebsd boot from a GPT volume (needed for large RAID arrays etc).  The freebsd installer doesn’t support anything exotic so we have to do this manually.

NOTE: FreeBSD 9.0 installer supports GPT by default now, so these instructions are for 8.x only

First, grab yourself a copy of DVD1 iso or the memory stick image and boot from it.  No other boot image will work – it MUST be the DVD or memory stick image!

Once you’ve booted into the installer and chosen your country and keyboard layouts, go to the Fixit menu and choose either CDROM/DVD or USB depending on the installation media you used.  This will open up a terminal window into a live filesystem booted from the DVD/USB.

Here, I’m going to use an Adaptec RAID disk (/dev/aacd0) which is multi-TB.  I will create a 100GB boot drive, and mount the remaining disk into /data using GPT all the way.

First, we need to remove any existing GPT partition info from the disk – ignore the ‘invalid argument’ message if you get it at this stage:

gpart destroy aacd0

Now we need to initialise the GPT partitions on the disk:

gpart create -s gpt aacd0

We will now make a boot (64KB), swap (4GB) and two UFS (100GB + remaining space) partition on the disk:

gpart add -s 128 -t freebsd-boot aacd0

gpart add -s 4G -t freebsd-swap -l swap aacd0

gpart add -s 100G -t freebsd-ufs -l boot aacd0
gpart add -t freebsd-ufs -l data aacd0

And now we have to install the protected MBR boot code into the drive:

gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptboot -i 1 aacd0

Ok, now we’ve made our UFS partitions, we need to format and mount them:

newfs -O2 -U /dev/gpt/boot
newfs -O2 -U /dev/gpt/data
mount /dev/gpt/boot /mnt

Now we’re ready to install FreeBSD onto the new UFS partition.  We’re going to install the base, manual pages, ports, all sources and a generic kernel – this takes some time so be patient…

cd /dist/8.1-RELEASE/
export DESTDIR=/mnt
for dir in base manpages ports ; do (cd $dir ; ./install.sh) ; done
cd src ; ./install.sh all
cd ../kernels ; ./install.sh generic
cd /mnt/boot ; cp -Rlp GENERIC/* /mnt/boot/kernel/

And now we’re ready to configure the installation.  To make things easier, we will chroot into the environment:

chroot /mnt

Set your root password:

passwd root

And configure your timezone:

tzsetup

And setup a dummy aliases file for sendmail to keep it quiet 😉

cd /etc/mail
make aliases

You can do other configuration here, like adding a user etc – but when you’re done we can exit the environment:

exit

We now add our UFS and swap devices to the /etc/fstab file as follows:

echo ‘/dev/gpt/boot / ufs rw 0 0’ > /mnt/etc/fstab
echo ‘/dev/gpt/data /data ufs rw 1 1’ >> /mnt/etc/fstab
echo ‘/dev/gpt/swap none swap sw 0 0’ >> /mnt/etc/fstab

And finally, create the mountpoint for the data partition:

mkdir /mnt/data

Now we can exit the fixit shell, remove the media and reboot the computer.

Once it’s booted, you can login and run sysinstall to configure other options like networking and startup programs (like SSH!)

Enjoy!

2 thoughts on “Booting FreeBSD from GPT (for large disks)

  1. Doug Strovall

    Do you have any guides or installation methods for freeBSD jails. I have an IBM machine with 300G HD space and 1G of memory.

    Reply
    1. dan Post author

      The man page for jail gives instructions on how to setup jails which is quite easy to follow, so i’ve not done any guide for it. check out ‘man 8 jail’ and go down to the examples section.

      Reply

Leave a Reply

Your e-mail address will not be published. Required fields are marked *