FreeBSD Cheat Sheet
FreeBSD Cheat Sheet
geom <disk/label/part/raid> list Display detailed information for the given GEOM
class disk - physical disk, label - device labels,
part - partitions. Other classes are available, but
not mentioned for irrelevance here.
swapoff <device name> Turn off temporarily the swap file, e.g. to move
its partition to the end of the increased virtual
disk: swapoff /dev/da0p3
gpart delete -i <n> <device name> Delete partition number n (as shown by gpart
show) on the device device name. E.g. If the swap
partition was number 3 on disk /dev/da0, to
delete it: gpart delete -i 3 /dev/da0.
gpart create -s <partition scheme> <device Set type of partition to be added on device
name> device name. E.g. to set up device da1 for GPT
partitioning: gpart create -s gpt da1.
1
Command Description
gpart resize -i <n> [ -s <new size K/M/G>] [-a Resize existing partition number n to new size,
<alignment size>] <device name> optionally setting alighnment, on device device
name. If -s size is not given, use up all available
free space. E.g. to increase the 2nd partition on
device da0 to 47 Gigabyte with 4k alignment:
gpart resize -i 2 -s 47G -a 4k da0.
growfs <partition name> After resizing a partition, grow the existing file
system on it to encompass the new free space.
E.g.growfs /dev/da0p2.
gpart add -t <partition type> [-a <alignment>] Add a new partition to the disk dev name, setting
[-l <label name>] <dev name> its type and optionally alignment and label. E.g.
to add freebsd-ufs type partition to disk da1
aligned on 4k border setting the label to data:
gpart add -t freebsd-ufs -a 4k -l data da1 .
After that, this partition will be available as
/dev/gpt/data
newfs [-U] [-j] <partition name/label> Add filesystem to the named partition. Switches
depend on the filesystem type, here -U is for
freebsd-ufs with soft updates but without
journaling, while -j adds journaling. E.g. to
create UFS filesystem with soft updates but
without the journaling on partition labeled /data
of type GPT: newfs -U /dev/gpt/data.