Wednesday, March 20, 2013

Installing (and optimizing) FreeBSD 9 on SSD drive

I've setup to install FreeBSD on one of the old desktop computers lying around. It has a Pentium D and GB or so of RAM. Am planning to use it for a ZFS file server using SAMBA.

Anyway, to fully optimize the partitioning process, I opted for the "Shell" mode. These are the commands I ran:

My SSD is on /dev/ada0.

Firstly, destroy the current partition table on the disk:
gpart destroy -F /dev/ada0
Next, create a GPT disk and add the partitions. I'm using a Crucial m4 SSD, and it's said to use 2 controllers and have a block size of 1024k, so let's align it to 1024k:
gpart create -s gpt ada0
gpart add -s 64k -t freebsd-boot -a 1024k -l boot0 ada0
gpart add -s 8G -t freebsd-swap -a 1024k -l swap0 ada0
gpart add -s 20G -t freebsd-ufs -a 1024k -l root0 ada0
gpart add -s 10G -t freebsd-ufs -a 1024k -l var0 ada0
gpart add -s 4G -t freebsd-ufs -a 1024k -l tmp0 ada0 
Now, install the bootcode:
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
Next, format the partitions with softupdate (no point journaling for SSD as fsck will already be fast anyway). Also, turn on TRIM (important):
newfs -U -t /dev/ada0p3
newfs -U -t /dev/ada0p4
newfs -U -t /dev/ada0p5
Now that it's all done, let's mount them properly in /mnt for the installer to continue with the installation.
mount /dev/ada0p3 /mnt
mkdir /mnt/var /mnt/tmp
mount /dev/ada0p4 /mnt/var
mount /dev/ada0p5 /mnt/tmp
Don't forget to edit fstab:
vi /tmp/bsdinstall_etc/fstab
This is how my fstab looks like:
# Device     MntPnt  FSType  Options  Dump  Pass#
/dev/ada0p2  none    swap    sw       0     0
/dev/ada0p3  /       ufs     sw       1     1
/dev/ada0p4  /var    ufs     sw       1     2
/dev/ada0p5  /tmp    ufs     sw       0     3
Finally, we can now continue with the installation:
exit

No comments:

Post a Comment