At previous article, we have discussed about how to install Slackware on GPT. In this article we will attempt on installing FreeBSD to GPT disk with or without EFI support.
Unlike previous article, for this article I use generic desktop PC. Thus, you can do it either on notebook or desktop PC. Obviously we constraint ourself to use GPT-based disk :). This article aim to guide you to Fresh Installing FreeBSD.
Step 1: Partitioning
Boot your FreeBSD (I use 8.3). Once you are at sysinstall menu, choose Fixit option. Later you will be brought to a terminal.
Now we will initialize the drive to support GPT partitions.
gpart create -s GPT ad0
Where ad0 is our disk. If you have more than one disk and want to also initialize them, do the similar command and replace ad0 with your device.
Then we will proceed for creating partitions. Our partition have specific purpose but all partition we want to create are a standard one. Do the followings:
gpart add -s 128 -t freebsd-boot -l boot ad0 gpart add -s 5G -t freebsd-ufs -l root ad0 gpart add -s 4G -t freebsd-ufs -l tmp ad0 gpart add -s 4G -t freebsd-swap -l swap ad0 gpart add -s 10G -t freebsd-ufs -l var ad0 gpart add -s 200G -t freebsd-ufs -l usr ad0
On above commands, we have create 6 partitions. The general syntax we use has following pattern:
gpart add -s size -t partition_type -l label disk
Where size is numeric value for size of partition. It also accept suffix K,M,G for Kilo, Mega, and Gigabyte. If no suffix is specified, the default value will be on Kilobytes.
For this article, the partition type can be freebsd-boot, freebsd-ufs, freebsd-swap.
The first partition are partitioned with freebsd-boot for type. It is equivalent to MBR of older disk type. Others are partition with freebsd-ufs (except 4th partition) for regular file system. The label is used for differentiate one partition with other partition.
To see partitions we have create we can invoke this command:
gpart show ad0
Unlike using gdisk, the change using gpart is automatically written on disk.
note: To see partition by label use this command
gpart show -l ad0
If you want to delete a partition, use following command:
gpart delete -i3 ad0
The i3 (generally -in where n is a number) is for pointing out what partition we want to delete. In this case we want to delete 3rd partition from disk ad0. So if your want to delete 5th partition, use gpart delete -i5 ad0.
In extreme condition, if you want to destroy GPT table from ad0 you can use following command:
gpart destroy ad0
The main reason might be you want to erase old disk scheme and create a new one later.
Now format the partition:
newfs -U /dev/ad0p2 newfs -U /dev/ad0p3 newfs -U /dev/ad0p5 newfs -U /dev/ad0p6
Hey, why we skip /dev/ad0p1 and /dev/ad0p4? Take look at their type 😀
Now put MBR (Master Boot Record) code in our first partition (boot partition):
gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptboot -i1 ad0
Then we mount all the partitions to install FreeBSD:
mkdir boot var usr mount /dev/ad0p2 /mnt mount /dev/ad0p3 /mnt/tmp mount /dev/ad0p5 /mnt/var mount /dev/ad0p6 /mnt/usr
Step 2: Installing FreeBSD
Now we reach the stage for FreeBSD installation itself. Do following:
export DESTDIR=/mnt cd /dist/8.3-RELEASE for dir in base catpages dict doc info lib32 manpages; do (cd $dir; ./install.sh); done
If you attempt to install x86 (or i386) version of FreeBSD then exclude lib32 in the for loop (you won’t need it.
Next we install the kernel. The kernel we want to install are GENERIC version so do following:
cd kernels ./install.sh GENERIC
And then the sources:
cd ../src ./install.sh
And copy the kernel in /mnt/boot/kernel directory:
cd /mnt/boot rmdir kernel cp -Rp GENERIC kernel
Step 3: Configuring
Last step! Configure the FreeBSD. Create /etc/fstab, /etc/resolv.conf and /etc/rc.conf files.
# Device Mountpoint FStype Options Dump Pass# /dev/ad0p4 none swap sw 0 0 /dev/ad0p2 / ufs rw 1 1 /dev/ad0p3 /tmp ufs rw 1 1 /dev/ad0p5 /var ufs rw 1 1 /dev/ad0p6 /usr ufs rw 1 1
nameserver 18.104.22.168 # or your ISP's DNS
defaultrouter="<your router IP>" hostname="VedaCore" ifconfig_em0="inet <your IP> netmask <your netmask>" sshd_enable="YES"
Reboot and enjoy the FreeBSD >:)
- If you get error “Device Busy” when you try to delete GPT from drive with gpart delete ad0, then turn off the safety with sysctl variable: sysctl kern.geom.debugflags=16
- If you want to destroy GPT table from drive, make sure all partitions have been deleted.