0% found this document useful (0 votes)
206 views

FreeBSD Cheat Sheet

This document provides a cheat sheet for working with disks, partitions, and file systems in FreeBSD. It lists common commands used for viewing disk and partition information, managing partitions, resizing partitions and file systems, and creating new file systems. The cheat sheet acts as a quick reference guide for tasks like deleting and adding partitions, resizing existing partitions to use newly available space, and setting up new file systems.

Uploaded by

cemerlang satu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
206 views

FreeBSD Cheat Sheet

This document provides a cheat sheet for working with disks, partitions, and file systems in FreeBSD. It lists common commands used for viewing disk and partition information, managing partitions, resizing partitions and file systems, and creating new file systems. The cheat sheet acts as a quick reference guide for tasks like deleting and adding partitions, resizing existing partitions to use newly available space, and setting up new file systems.

Uploaded by

cemerlang satu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

FreeBSD cheat sheet

Author: Yuri Slobodyanyuk, https://www.linkedin.com/in/yurislobodyanyuk/

Working with disks and partitions


Command Description

camcontrol devlist Show list of attached storage devices

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.

mount Show mounted in fact partitions and their


properties (journaled or not, type).

glabel list Show labels, same as geom label list.

gpart show Show partitions, similar to geom part list minus


labels information, so is shorter. Add -r to show
GPT partition types, see for the complete list at
https://en.wikipedia.org/wiki/
GUID_Partition_Table .

gpart recover <device name> Recover partition information, e.g. when


increasing the size of already partitioned disk in
Virtual Machine, the last sector holding the
partition info is lost, so to put the needed info in
the last sector of now increased disk: gpart
recover da0.

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.

sysctl kern.geom.debugflags=16 Resizing a live partition may require turning off


this protection.

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.

2 https://www.linkedin.com/in/yurislobodyanyuk/ FreeBSD cheat sheet

You might also like