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 |
mount |
Show mounted in fact partitions and their properties (journaled or not, type). |
glabel list |
Show labels, same as |
gpart show |
Show partitions, similar to |
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: |
swapoff <device name> |
Turn off temporarily the swap file, e.g. to move its partition to the end of the increased virtual disk: |
gpart delete -i <n> <device name> |
Delete partition number |
gpart create -s <partition scheme> <device name> |
Set type of partition to be added on device |
sysctl kern.geom.debugflags=16 |
Resizing a live partition may require turning off this protection. |
gpart resize -i <n> [ -s <new size K/M/G>] [-a <alignment size>] <device name> |
Resize existing partition number |
growfs <partition name> |
After resizing a partition, grow the existing file system on it to encompass the new free space. E.g. |
gpart add -t <partition type> [-a <alignment>] [-l <label name>] <dev name> |
Add a new partition to the disk |
newfs [-U] [-j] <partition name/label> |
Add filesystem to the named partition. Switches depend on the filesystem type, here |