# Programming with GEOM



## Twister (Aug 21, 2012)

Hello!

Please tell me where I can find info about working with GEOM.
I write program and I have to get info about storage devices. I need information about present devices, partitioning schemes, partitions, FS of partitions.
Can I get this information through geom subsystem?

Later I want to make some work with storage - delete or create partitions or filesystems. Can geom do it for me?

Thank you for your answers.


----------



## SirDice (Aug 21, 2012)

Twister said:
			
		

> Please tell me where I can find info about working with GEOM.


I'd start with the man pages: geom(4) and libgeom(3).


----------



## wblock@ (Aug 21, 2012)

Actually, you can do this from a higher level.  gpart(8) can be used for getting the list of devices and partitioning schemes, then file(1) can be used to check filesystem types.


```
% gpart list
% gpart show
% gpart show ada0
% gpart show ada0s1
% file -s /dev/ada0s1a
% file -s /dev/ada0p4
```


----------



## Twister (Aug 22, 2012)

Thank you for your answers.
But "gpart" or "geom" shows information only if there is already configured partitions/filesystems.
What if I have booted to LiveCD/DVD and I need to find any storage devices (to partition it and install system for example). This storage devices may not contain any partitions/filesystems and will not be shown with geom/gpart.
What is _right_ way to find _any_ connected storage devices?


----------



## SirDice (Aug 22, 2012)

Is it from a higher level (shell scripting for example) or a lower level (C/C++ for example)?


----------



## Twister (Aug 22, 2012)

SirDice said:
			
		

> Is it from a higher level (shell scripting for example) or a lower level (C/C++ for example)?



Lower level, C


----------



## Crest (Aug 22, 2012)

The detected disks are listed in the kern.disks MIB.

```
sysctl -n kern.disks
```


----------

