5.7. Disk Utilities

Use df to find out how much space is being used on each file system:

% df
Filesystem  1K-blocks      Used   Avail Capacity  Mounted on
/dev/ad0s1a    128990     49542   69130    42%    /
/dev/ad0s1f   1007950     51620  875694     6%    /tmp
/dev/ad0s1g 115774244 103971682 2540624    98%    /usr
/dev/ad0s1e    257998     45738  191622    19%    /var
/dev/ad2s1e  59116356  53978992  408056    99%    /data
procfs              4         4       0   100%    /proc

The df(1) manual page states that the values are displayed in 512-byte per block counts. This is usually modified by /etc/login.conf to 1 Kilobyte as such:

BLOCKSIZE=K

This is an ENVIRONMENT variable whose value is set during login. All applications will use this to display values unless otherwise on the command line or by some other means.

Adding additional options to df will allow display in other formats. Many people use df -h for a "human readable" display:

% df -h
Filesystem    Size   Used  Avail Capacity  Mounted on
/dev/ad0s1a   126M    48M    68M    42%    /
/dev/ad0s1f   984M    50M   855M     6%    /tmp
/dev/ad0s1g   110G    99G   2.4G    98%    /usr
/dev/ad0s1e   252M    50M   182M    22%    /var
/dev/ad2s1e    56G    51G   398M    99%    /data
procfs        4.0K   4.0K     0B   100%    /proc

Disk space and inodes are almost completely unrelated concepts. If you look at the df man page, you might notice that if you do a df -i it will report the number of inodes as well as the amount of disk space. Those are under columns labeled iused, ifree and %iused.

% df -i
Filesystem  1K-blocks      Used   Avail Capacity iused    ifree %iused  Mounted on
/dev/ad0s1a    128990     49542   69130    42%    1848    14406   11%   /
/dev/ad0s1f   1007950     51620  875694     6%      92   126626    0%   /tmp
/dev/ad0s1g 115774244 103790272 2722034    97%  307912 14162486    2%   /usr
/dev/ad0s1e    257998     45736  191624    19%    2855    29655    9%   /var
/dev/ad2s1e  59116356  53978992  408056    99%    8372  7383626    0%   /data
procfs              4         4       0   100%     131     3937    3%   /proc

Disk space is just that, the amount of disk storage used and available but inodes are table entries. When you originally newfs a file system it creates a table with a certain number of entries. One of those entries is used for each file, directory and symlink that is created - no matter how big the file is. It is essentially a list of the files on the file system along with a bit of information on how to find the file and dates and such. So, if you create a lot of tiny files, you are likely to run out of inodes long before you run out of space on the disk. On the other hand, if you create even just one huge file, you could use just one inode and still use up all of the disk space.

Use diskinfo to get information about disk devices:

# diskinfo -v ad0
ad0
        512             # sectorsize
        251000193024    # mediasize in bytes (234G)
        490234752       # mediasize in sectors
        7781504         # Cylinders according to firmware.
        1               # Heads according to firmware.
        63              # Sectors according to firmware.

The atacontrol ATA device driver control utility can be used to find out a lot of information about a hard disk:

#: atacontrol cap ad0

Protocol              ATA/ATAPI revision 7
device model          Maxtor 6Y250P0
serial number         Y65BS89E
firmware revision     YAR41BW0
cylinders             16383
heads                 16
sectors/track         63
lba supported         268435455 sectors
lba48 supported       490234752 sectors
dma supported
overlap not supported

Feature                      Support  Enable    Value           Vendor
write cache                    yes      yes
read ahead                     yes      yes
Tagged Command Queuing (TCQ)   no       no      0/0x00
SMART                          yes      no
microcode download             yes      yes
security                       yes      no
power management               yes      yes
advanced power management      yes      no      0/0x00
automatic acoustic management  yes      yes     254/0xFE        192/0xC0