DRIVEINFO(8)              BSD System Manager’s Manual             DRIVEINFO(8)


NAME

     driveinfo -- provide partition information for GPT drives


SYNOPSIS

     driveinfo [-A] [-R options-to-reset] [-a byte-alignment] [-b]

               [-c column-list] [-defhimprs] [-t maximum-entries] [-vx]

               [-z file-list] [--] [device]


DESCRIPTION

     The driveinfo command gets detailed information about a specific drive.

     The script parses property lists emitted by the diskutil(8) command to

     compile the information. If the drive contains a GUID Partition Table

     (GPT), then detailed information about each partition is also included in

     a tabular form. This also allows free space on a drive, using a GPT, to

     be identified.


     The gpt(8) command can be used to view the actual stored GPT values in in

     a tabular form. Starting with macOS, the gpt(8) command can no longer

     read the GPT on an operating system boot drive, unless System Integrity

     Protection (SIP) is disabled. The driveinfo command does not require dis-

     abling SIP and can produce the same basic tabular output as the gpt(8)

     command.


     The options are applied as read from left to right and are as follows:


     -A   Reset to the default all options. This option is the same as enter-

          ing the -R abcdefimrstx option.


     -R options-to-reset

          Reset to the default value any options given as the argument.


     -a byte-alignment

          Set the byte alignment value used to determine if the "A" and "S"

          error codes should be issued. The default is to never issue either

          code. Normally, the byte alignment value should be a power of 2

          greater than the logical sector size.


     -b   Display blocks instead of bytes. Each block is equal to the logical

          sector size in bytes.


     -c column-list

          Specify which columns to display. Each character in the argument

          represents a column type. The list of possible column types is given

          in the COLUMNS section. The default is to display the "cstimn" col-

          umn types.


     -d   Omit the header.


     -e   Omit the table.


     -f   Force use of color. Color sequences are normally disabled if the

          output is not directed to a terminal. This can be overridden by set-

          ting this flag.


     -h   Display this man page with overstriking suppressed, then quit. All

          previous options are ignored.


     -i   Do not validate the source script. This option must occur before any

          other options both on the command line and in the DRIVEINFO_OPTIONS

          environment variable, otherwise this option will be ignored.


     -m   Omit thousands separator.


     -p   Pipe this man page to the less command, then quit. All previous

          options are ignored. This allows the man page to be viewed interac-

          tively.


     -r   Enable colorized output. ANSI escape codes are used to highlight

          free space and entries with error codes. No attempt is made to

          determine if the ANSI escape codes are compatible with the current

          terminal.


     -s   Display execution times. This option is for diagnostic purposes.


     -t maximum-entries

          Set the maximum number of partition entries allowed in GPT. This

          option should not be used unless the user knows the GPT was created

          with more than the default of 128 possible entries.


     -v   Display the version, then quit.  All previous options are ignored.


     -x   Add a metric prefix to the values in the "Size" column.


     -z file-list

          Install the files associated with this command, then quit. All pre-

          vious options are ignored. Each character in the argument represents

          a file type. The list of possible file types is given in the FILES

          section.


     --   Signals the end of options and disables further option processing.


DEVICES

     A device parameter can usually be any of the following:


       The disk identifier (see below) of a drive with a GPT. Any entry of

         the form of diskU, where U is zero or a positive decimal integer,

         e.g.  disk0.


       The device node entry containing the disk identifier of a drive with

         a GPT.  Any entry of the form of /dev/[r]diskU, where U is zero or a

         positive decimal integer, e.g.  /dev/disk0.


     Further information about devices can be found on the man page for

     diskutil(8).


DISK IDENTIFIER

     The (BSD) disk identifier string variously identifies a physical or logi-

     cal device unit, a session (if any) upon that device, a slice (partition)

     upon that session (if any), or a virtual logical volume. In the context

     of this command, a disk identifier may take the form of diskU or diskUsS,

     where:


       U is the device unit represented by zero or a positive decimal inte-

         ger (possibly multi-digit). It may refer to hardware (e.g. a hard

         drive, optical drive, or memory card) or a virtual "drive" con-

         structed by software (e.g. an AppleRAID Set, disk image, CoreStorage

         LV, etc.).


       S is the slice (partition) represented by a positive decimal integer

         (possibly multi-digit). Upon this partition, the raw data that under-

         lies a user-visible file system is usually present, but it may also

         contain specialized data for certain 3rd-party database programs, or

         data required for the system software (e.g. EFI partitions, booter

         partitions, APM partition map data, etc.), or, notably, it might con-

         tain backing-store physical volumes for AppleRAID, CoreStorage, APFS,

         or 3rd-party Storage Systems.


     Further information about disk identifiers can be found on the man page

     for diskutil(8).


COLUMNS

     Below is a list of information column types that can be output.  The let-

     ters may appear as the argument to the c option.


     b   Begin:        Base zero beginning offset.

     c   Code:         Error codes (see below).

     e   End:          Base zero ending offset.

     f   Format:       Known or last known file system (user visible) name.

     i   Identifier:   Disk identifier of the partition (slice).

     m   Mounted:      Either "Yes" for a mounted partition, otherwise "No".

     n   Name:         Known or last known volume label.

     p   Personality:  Known or last known file system personality name.

     s   Size:         If Ending < Beginning, then wrapping is assumed.

     t   Type:         Entry type (see below).


ENTRY TYPES

     Below is a list of entry types that reserve storage for partitioning

     information.


     PMBR                Protective Master Boot Record

     Pri GPT header      Primary GUID Partition Table header

     Pri GPT table       Primary GUID Partition Table array

     Sec GPT header      Secondary (Backup) GUID Partition Table header

     Sec GPT table       Secondary (Backup) GUID Partition Table array


     Below is a list of entry types and GUIDs for common partitions. This is

     not a complete list.


     Apple_APFS                7C3457EF-0000-11AA-AA11-00306543ECAC

     Apple_Boot                426F6F74-0000-11AA-AA11-00306543ECAC

     Apple_CoreStorage         53746F72-6167-11AA-AA11-00306543ECAC

     Apple_HFS                 48465300-0000-11AA-AA11-00306543ECAC

     Bios Boot Partition       21686148-6449-6E6F-744E-656564454649

     EFI                       C12A7328-F81F-11D2-BA4B-00A0C93EC93B

     Linux Filesystem          0FC63DAF-8483-4772-8E79-3D69D8477DE4

     Linux LVM                 E6D6D379-F507-44C2-A23C-238F2A3DF928

     Linux Swap                0657FD6D-A4AB-43C4-84E5-0933C84B4F4F

     Microsoft Basic Data      EBD0A0A2-B9E5-4433-87C0-68B6B72699C7

     Microsoft Reserved        E3C9E316-0B5C-4DB8-817D-F92DF00215AE

     Windows Recovery          DE94BBA4-06D1-4D40-A16A-BFD50179D6AC


ERROR CODES

     These letters may appear in the "Code" column.


     A   The "Begin" value is not a multiple of the byte-alignment value. This

         check only performed on partition entries.

     I   One or more values are invalid. A value is invalid, if at least one

         of the three following conditions occurs. First, the "Begin" value is

         greater than the "End" value. Second, the "Begin" block value is

         greater than or equal to the number of sectors. Third, the "End"

         block value is greater than or equal to the number of sectors.

     O   The entry overlaps another entry. There is overlap, if at least one

         of the two following conditions occurs. First, the "End" value is

         greater than or equal to the "Begin" value of the next entry. Second,

         the entry is not last and the "Begin" value greater than the "End"

         value.

     S   The "Size" value is not a multiple of the byte-alignment value. This

         check only performed on partition entries.


COLORS

     Red     The entry contains one or more error codes.

     Green   The entry represents free space on the drive.


ENVIRONMENT

     The following environment variable affects the execution of driveinfo:


     DRIVEINFO_OPTIONS


     If the DRIVEINFO_OPTIONS variable exists in the environment, then the

     options are read from this variable, before reading any additional

     options from the command line.


     DRIVEINFO_INCLUDE


     The DRIVEINFO_INCLUDE variable is only used during code development.

     Under normal usage, this variable is not accessed and can therefore be

     ignored. If the DRIVEINFO_INCLUDE variable exists in the environment dur-

     ing code development, then the directory stored in this variable may be

     searched for include files.


FILES

     The letters given below may appear as the argument to the z option. This

     option installs the driveinfo command into macOS. Note: Any existing

     files will be replaced.


     c   Copy the bash script to the /usr/local/bin/driveinfo file.

     p   Write the man page to the /usr/local/share/man/man8/driveinfo.8 file.


EXAMPLES

           driveinfo disk0

     If the DRIVEINFO_OPTIONS variable is defined, then the options are read

     from this variable before displaying the information for disk0.


           driveinfo -A disk0

     Ignore the DRIVEINFO_OPTIONS variable and display the default information

     for disk0.


           driveinfo -Abdmc bsit /dev/disk0

     Replacement for the "sudo gpt -r show /dev/disk0" command.


           driveinfo -a 4096 -r disk0

     Determine if the "A" and "S" error codes should be issued for partition

     entries. The argument value of 4096 bytes is the alignment requirement

     for proper operation of Apple_APFS, Apple_Boot, Apple_CoreStorage and

     Apple_HFS partitions.


           driveinfo -r disk0

     Use color to highlight free space and entries with error codes.


           driveinfo -R bd disk0

     Reset b and d options, if specified in the DRIVEINFO_OPTIONS variable.


           driveinfo -z cp

     Install this command. See the FILES section for more information.


DIAGNOSTICS

     Problems found with entries in (GPT) are flagged by letters appearing in

     the "Code" column of the table.


     The s option can be used to determine the execution times of the script.

     This options verifies that a majority of the time is spent waiting for

     the diskutil(8) command to return property lists.


COMPATIBILITY

     At the time of this writing, driveinfo found to be compatible with High

     Sierra (macOS 10.13) and newer versions of macOS.


EXIT STATUS

     An value of 0 is returned to indicate success. A value of 2 is returned,

     if the script determines a error condition. Otherwise, any exit code,

     found in a diskutil(8) property list, will be the returned exit status of

     the script.


VALIDATION

     Normally, a CRC32 validation is preformed on the source script. This can

     be disabled with the i option. If the script is deliberately modified,

     then the hexadecimal value given in the error message should be used to

     replace the value at the end of the script. This value should be followed

     by a newline.


SEE ALSO

     diskutil(8), gpt(8)


HISTORY

     The driveinfo utility is not part of macOS. The first downloadable ver-

     sion appeared in December of 2018.


VERSION

     This documentation is current for version 1.0.4 of driveinfo.


BUGS

     The tabular information is only produced for drives with a GPT.


     The default maximum number of partition entries allowed in GPT is assumed

     to be 128. While this is a fairly safe assumption, if the actual value is

     different, then this utility will not know unless set by the t option.


AUTHOR

     driveinfo was written by David M. Anderson.


     Support and development are available at

     https://sourceforge.net/projects/driveinfo/


macOS                          February 1, 2020                          macOS