FreeBSD: Creating partitions and file systems

Table of Contents

Introduction
Prepare the drive
Create GPT partitions and filesystems
Create MBR slices/partitions and filesystems

Create GPT partitions and filesystems

by ross at 08:21:21 on November 18, 2012

Create GPT partition table

If the drive is empty:

# gpart create -s gpt ada1
ada1 created

# gpart show ada1
=>       34  976773101  ada1  GPT  (465G)
         34  976773101        - free -  (465G)

Create the partitions

Create UFS partition:
# gpart add -s 20G -t freebsd-ufs -l data0 ada1
ada1p1 added

Create ZFS partition:
# gpart add -s 20G -t freebsd-zfs -l tank0 ada1
ada1p2 added

GPT scheme supports partition labels (flag -l of gpart) so there is no need for glabel. In the example above we have created /dev/gpt/data0 and /dev/gpt/tank0.

Ommit parameter -s (size) if you need a partition covering all the space available.

UFS filesystems

# newfs -U -L data0 /dev/gpt/data0
# mkdir /data
# mount /dev/ufs/data0 /data0

This will create /dev/ufs/data0 using /dev/gpt/data0 with Soft Updates (-U).

Add an entry to /etc/fstab:

# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ufs/data0          /data           ufs     rw              2       2

ZFS filesystems

zpool create tank /dev/gpt/tank0

This filesystem will be mounted as /tank. No need for fstab entries for ZFS.

 

Comments