gpart micro-how-to

Andriy Gapon avg at icyb.net.ua
Thu Apr 2 05:20:40 PDT 2009


When I was a FreeBSD newbie I used sysinstall to partition my disks (now this
subset of sysinstall's functionality can be found in sade(1)); when I became more
knowledgeable and self-confident I started using fdisk and disklabel; and now it's
time for gpart.

Yesterday I marked up a new disk using part and decided to share the commands I
used just in case somebody finds it useful.

The disk is WD5000AAKS, its size in sectors is 976773168.

# the following is fdisk substitute: create mbr partition table
# and populate two entries with FreeBSD slices
gpart create -s mbr ad10
gpart add -b 63 -s 12578832 -t freebsd ad10
gpart add -b 12578895 -s 964194273 -t freebsd ad10

# the following are disklabel substitutes: create empty labels, then add ufs
# partition ad10s1a, swap partition ad10s1b and partition ad10s2d of type
# "unknown"/FS_OTHER/10 for future use by zfs
gpart create -s bsd ad10s1
gpart create -s bsd ad10s2
gpart add -i 1 -b 16 -s 4194304 -t freebsd-ufs ad10s1
gpart add -i 2 -b 4194320 -s 8384512 -t freebsd-swap ad10s1
gpart add -i 4 -b 16 -s 964194257 -t \!10 ad10s2

# the following are substitutes for fdisk/disklabel with -B/-b flags
gpart bootcode -b /boot/boot0 ad10
gpart bootcode -b /boot/boot ad10s1


And "gpart show" is, of course, of great help at intermediate steps to figure out
sizes and offsets.

-- 
Andriy Gapon


More information about the freebsd-geom mailing list