How to examine disks and their partitions via terminal?
I am trying to examine my settings to prepare for a triple boot and would like to know how to completely examine my HDD before to make sure I know everything usefull for the project to know about it.
Examine with
- diskutil list
- diskutil info /dev/disk0 (disk0s1 etc.)
- sudo gpt -r show disk0
- fdisk /dev/disk0 (make/change partitioning with MBR)
- sudo gdisk -l /dev/disk0 (make/change partitioning with GUID)
- refit Partition Inspector / gptsync
diskutil is the OS X program to get info on and change partitions.
$ diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *4.0 TB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_HFS iMac HD 4.0 TB disk0s2
BVs-iMac-3:~ bvimac$
gpt is the OS X program specialized for GUID partition tables (in contrast to MBR)
$ sudo gpt -r show disk0
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 7812237856 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
7812647496 1389639
7814037135 32 Sec GPT table
7814037167 1 Sec GPT header
fdisk is a program for several operating systems that manipulates master boot record partitioning tables.
$ sudo fdisk /dev/disk0
Disk: /dev/disk0 geometry: 219051/255/63 [3519069872 sectors]
Signature: 0xAA55
Starting Ending
#: id cyl hd sec - cyl hd sec [ start - size]
-----------------------------------------------------------------------
1: EE 1023 254 63 - 1023 254 63 [ 1 - 4294967294] <Unknown ID>
2: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
3: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
4: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
gdisk is a program for several operation systems that minipulates GUID partition tables (like gpt, but not just OS X). It can be downloaded here.
$ sudo gdisk -l /dev/disk0
GPT fdisk (gdisk) version 1.0.1
Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Disk /dev/disk0: 7814037168 sectors, 3.6 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 5782184C-C4EA-47D2-9039-F1564F7735F3
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 7814037134
Partitions will be aligned on 8-sector boundaries
Total free space is 1389645 sectors (678.5 MiB)
Number Start (sector) End (sector) Size Code Name
1 40 409639 200.0 MiB EF00 EFI System Partition
2 409640 7812647495 3.6 TiB AF00 iMac HD
diskutil can be ised to get more information on the whole disk0 and its subsequent partitions disk0s1 and disk0s2.
$ diskutil info /dev/disk0
Device Identifier: disk0
Device Node: /dev/disk0
Part of Whole: disk0
Device / Media Name: ST4000DX001-1CE168 Media
Volume Name: Not applicable (no file system)
Mounted: Not applicable (no file system)
File System: None
Content (IOContent): GUID_partition_scheme
OS Can Be Installed: No
Media Type: Generic
Protocol: SATA
SMART Status: Verified
Total Size: 4.0 TB (4000787030016 Bytes) (exactly 7814037168 512-Byte-Units)
Volume Free Space: Not applicable (no file system)
Device Block Size: 512 Bytes
Read-Only Media: No
Read-Only Volume: Not applicable (no file system)
Ejectable: No
Whole: Yes
Internal: Yes
Solid State: No
OS 9 Drivers: No
Low Level Format: Not supported
$ diskutil info /dev/disk0s1
Device Identifier: disk0s1
Device Node: /dev/disk0s1
Part of Whole: disk0
Device / Media Name: EFI System Partition
Volume Name: Not applicable (no file system)
Mounted: Not applicable (no file system)
File System: None
Partition Type: EFI
OS Can Be Installed: No
Media Type: Generic
Protocol: SATA
SMART Status: Verified
Total Size: 209.7 MB (209715200 Bytes) (exactly 409600 512-Byte-Units)
Volume Free Space: Not applicable (no file system)
Device Block Size: 512 Bytes
Read-Only Media: No
Read-Only Volume: Not applicable (no file system)
Ejectable: No
Whole: No
Internal: Yes
Solid State: No
$ diskutil info /dev/disk0s2
Device Identifier: disk0s2
Device Node: /dev/disk0s2
Part of Whole: disk0
Device / Media Name: iMac HD
Volume Name: iMac HD
Escaped with Unicode: iMac%FF%FE%20%00HD
Mounted: Yes
Mount Point: /
Escaped with Unicode: /
File System Personality: Journaled HFS+
Type (Bundle): hfs
Name (User Visible): Mac OS Extended (Journaled)
Journal: Journal size 311296 KB at offset 0x3a3c000
Owners: Enabled
Partition Type: Apple_HFS
OS Can Be Installed: Yes
Media Type: Generic
Protocol: SATA
SMART Status: Verified
Volume UUID: 1819AB9E-CACA-3408-8F03-B3ADBEEABC5B
Total Size: 4.0 TB (3999865782272 Bytes) (exactly 7812237856 512-Byte-Units)
Volume Free Space: 3.8 TB (3820305375232 Bytes) (exactly 7461533936 512-Byte-Units)
Device Block Size: 512 Bytes
Read-Only Media: No
Read-Only Volume: No
Ejectable: No
Whole: No
Internal: Yes
Solid State: No
refit is a bootmanager (that is currently not maintained any more) that comes with a tool, which is called gptsync or Partition Inspector. Its output looks like this:
*** Report for internal hard disk ***
Current GPT partition table:
# Start LBA End LBA Type
1 40 409639 EFI System (FAT)
2 409640 98749479 Mac OS X HFS+
3 98749480 100019015 Mac OS X Boot
4 156317696 234440703 Basic Data
Current MBR partition table:
# A Start LBA End LBA Type
1 1 409639 ee EFI Protective
2 409640 98749479 af Mac OS X HFS+
3 98749480 100019015 ab Mac OS X Boot
4 156317696 234440703 0c FAT32 (LBA)
MBR contents:
Boot Code: Unknown, but bootable
Partition at LBA 40:
Boot Code: None (Non-system disk message)
File System: FAT32
Listed in GPT as partition 1, type EFI System (FAT)
Partition at LBA 409640:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 2, type Mac OS X HFS+
Listed in MBR as partition 2, type af Mac OS X HFS+
Partition at LBA 98749480:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 3, type Mac OS X Boot
Listed in MBR as partition 3, type ab Mac OS X Boot
Partition at LBA 156317696:
Boot Code: None
File System: Unknown
Listed in GPT as partition 4, type Basic Data
Listed in MBR as partition 4, type 0c FAT32 (LBA)