How to Get Attached Disk Size on FreeBSD

freebsdhard drive

When I attach a disk to FreeBSD I can list any attached disks by doing:

[root@freenas] ~# sysctl kern.disks
kern.disks: xbd2 xbd1 ada0
[root@freenas] ~#

How can I then find out the size of each attached disk?

Best Answer

diskinfo -v ada0 if you just want to see disk size.

If you want to use this info in some script, you can parse sysctl -n kern.geom.confxml output.