FreeBSD Fundamentals · Module 07 of 14

Disks, GPT, UFS and GEOM

Understand FreeBSD disk naming, partition with gpart, create UFS filesystems and reason about GEOM providers.

Learning objectives

By the end of this module, you should be able to:

  • Inspect disk and partition topology.
  • Create a GPT/UFS data disk in a lab.
  • Explain how GEOM exposes storage providers.

GEOM and device providers

FreeBSD storage utilities work through GEOM providers exposed under /dev. gpart manages partitioning schemes such as GPT.

UFS and persistent mounts

newfs creates UFS filesystems. Mountpoints and /etc/fstab define how filesystems are integrated into the directory tree across reboots.

Worked examples

See the idea in practice.

Inspect storage safely

geom disk list
gpart show
mount
df -h
  • Inventory first. Never run destructive gpart/newfs commands until you positively identify the lab device.
Hands-on lab

Lab — Prepare, verify and clean up a secondary UFS disk

Goal: Safely identify a disposable second disk, create a GPT/UFS filesystem, prove read/write operation, then remove the lab storage state.

Before you start

  • Disposable VM with console access and an empty secondary disk. NEVER use the boot disk.
  • Device names vary by platform (for example vtbd1 under KVM or ada1 elsewhere). Identify the disk from evidence; do not copy an example name.
STEP 1

Identify the disposable disk positively

Inventory disks, partitions, mounts and swap first. Set LABDISK only after proving which device is the empty secondary disk.

sysctl kern.disks
geom disk list
gpart show
mount
swapinfo -h

# Example only after verification; replace with your actual disposable disk:
LABDISK=vtbd1
echo "$LABDISK"
gpart show "$LABDISK" || true
mount | grep "$LABDISK" || true
swapinfo -h | grep "$LABDISK" || true
STEP 2

Create GPT and a labelled UFS partition

gpart create -s GPT "$LABDISK"
gpart add -t freebsd-ufs -a 1M -l academyufs "$LABDISK"
gpart show "$LABDISK"
ls -l /dev/gpt/academyufs
STEP 3

Create and mount UFS

newfs -U /dev/gpt/academyufs
mkdir -p /data
mount /dev/gpt/academyufs /data
df -h /data
mount | grep " /data "
STEP 4

Prove read/write operation

echo "GNU Group FreeBSD UFS validation" > /data/validation.txt
cat /data/validation.txt
STEP 5

Clean up for the next storage lab

umount /data
rmdir /data
mount | grep "$LABDISK" || true
gpart destroy -F "$LABDISK"
gpart show "$LABDISK" || true

Verify

  • The verified disposable disk has GPT with a freebsd-ufs partition labelled academyufs.
  • /data mounts from /dev/gpt/academyufs and the validation file can be written and read.
  • After cleanup, /data is unmounted and the disposable disk partition table has been removed.

Expected outcome

  • gpart, newfs, mount, df and file I/O complete successfully on the secondary disk only.
  • Cleanup returns the lab disk to an unpartitioned state ready for the ZFS lab.

If it fails

  • If the candidate disk appears in mount or swap output, or already contains unexpected data, stop and re-identify the device.
  • Do not use -F to overwrite unknown storage merely to make the lab proceed.
Real-world connection

A storage runbook is trustworthy only when device identity, destructive boundaries, verification and cleanup are all explicit.

Avoid these traps

Common mistakes

  • Copying example device names without checking the actual hardware.
  • Editing fstab before confirming a filesystem mounts correctly.
Knowledge check

Can you explain it without looking back?

Open each answer only after you have tried to answer the question yourself.

1What does gpart manage?

Partitioning schemes and partitions such as GPT layouts.

2Why use labels where practical?

Labels are more stable than controller-dependent device numbering.

3What does newfs create?

A new UFS filesystem on the selected provider.

My Learning

Record your progress for this module.

Progress is saved in this browser immediately. When you sign in to My Learning, it can also sync across devices.

Not started

Attempt the core lab and knowledge checks before marking the module complete.