2

I have 8 disks in a RAID. They are 4TB each so can not be formatted with MBR or APM. The EFI takes up 200MB on each of the 8 disks so 1600 MB for no purpose is wasted.

I have tried using diskutil commands and been unsuccessful in reclaiming that space.

sudo gpt show disk5

       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  7813365344      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  7813774984      262151         
  7814037135          32         Sec GPT table
  7814037167           1         Sec GPT header

I asked diskutil to create just one partition and it disregarded and added two anyway!

diskutil partitionDisk disk5 1 GPT JHFS+ disk5 0

Started partitioning on disk5
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk5s2 as Mac OS Extended (Journaled) with name disk5
Initialized /dev/rdisk5s2 as a 4 TB case-insensitive HFS Plus volume with a 311296k journal
Mounting disk
Finished partitioning on disk5
/dev/disk5 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *4.0 TB     disk5
   1:                        EFI EFI                     209.7 MB   disk5s1
   2:                  Apple_HFS disk5                   4.0 TB     disk5s2

I know I can erase the EFI, but I also want to reclaim that space for the single partition. Thanks.

https://developer.apple.com/library/archive/technotes/tn2166/_index.html

Apple's policy from 2006 is hopelessly outdated. An EFI is mandatory on a "big" disk, and a big disk is anything larger than 2 GB... yes.

enter image description here

2
  • Have you tried using gpt (or gdisk) to partition and newfs_hfs to format? I tried this on a 4 TB sparse disk image and was able to mount the file system. Commented Oct 1, 2023 at 2:32
  • @DavidAnderson I have no experience with newfs_hfs. A quick glance at the man page is discouraging... looks very low level.
    – John
    Commented Oct 1, 2023 at 4:05

2 Answers 2

3

The EFI partition uses 409600/7814037168*100%=0.00524% of the drive, while the JHFS+ partition uses 7813365344/7814037168*100%=99.99140% of the drive. IMO, avoiding having an EFI partition is not worth the effort. Anyway, below is an answer.


This answer relies on using a command that can edit GUID Partition Tables (GPT), such as gpt, gdisk or sgdisk. Some pertinent information is given below.

  • The gpt command is part of macOS. The gdisk and sgdisk commands are third party and are currently maintained by Rod Smith.
  • The gpt add command is no longer available under certain versions of macOS, such as Ventura.
  • The macOS operating system includes a MBR Partition Table editor command called fdisk. The gdisk command is a GPT version of the fdisk command. Like fdisk, gdisk is interactive. The sgdisk command is the non-interactive version of the gdisk command. The gdisk command has more functionality than the sgdisk command.
  • The gdisk and sgdisk binaries can be downloaded from this gptfdisk SourceForge website. The gdisk command was tested to work with newer versions of macOS on Intel Macs. Testing has shown this downloaded sgdisk command does not work on Intel Macs. I do not know if either command, downloaded from this website, will work on Apple Silicon Macs.
  • There is a Homebrew formulae for gptfdisk. This is supposed to install both gdisk and sgdisk for the newest versions of macOS on both Intel and Apple Silicon Macs. Testing shows both commands work on Intel Macs. I did not test on Apple Silicon Macs.
  • There are Linux man pages for gdisk and sgdisk.

Note: The OP's question used the volume name disk5. This answer will use the volume name mydisk5 instead.

Drive without an EFI Partition

  1. Create a new GPT with no entries.

    diskutil erasedisk free none gpt disk5
    diskutil erasevolume free none disk5s1
    
  2. Add a partition of type 48465300-0000-11AA-AA11-00306543ECAC to the GPT. The value 7813774944 is the sum of the values 409600 and 7813365344. Below are three methods of add this partition. Choose only one of the three methods presented.

    • Use the gpt command, as shown below.

      sudo gpt add -b 40 -s 7813774944 -t hfs disk5
      
    • Use the interactive gdisk command, as shown below.

      sudo gdisk /dev/disk5
      

      The inputs to the gdisk command are given in the first column below.

      Entry Type Comment
      x Command Goto experts menu.
      l Command Set the sector alignment value.
      8 Parameter Enter an alignment on 8 sector boundaries.
      m Command Return to main menu.
      n Command Add a new partition.
      1 Parameter Partition number.
      40 Parameter First Sector.
      +7813774944 Parameter Size in sectors.
      af00 Parameter Code for 48465300-0000-11AA-AA11-00306543ECAC
      w Command Write table to disk and exit.
      y Parameter Confirm to proceed.
    • Use the sgdisk command, as shown below.

      sudo sgdisk -a 8 -n 0:40:+7813774944 -t 0:af00 /dev/disk5
      
  3. Format the partition and mount the volume.

    sudo newfs_hfs -J -v mydisk5 disk5s1
    diskutil mount disk5s1
    

Drive without a Partition Table

Actually, you can format a drive without any partitioning scheme. For example, the commands below would do this.

diskutil erasedisk free none gpt disk5
sudo newfs_hfs -J -v mydisk5 disk5
diskutil mount disk5
0

With EFI

> diskutil eraseDisk exFAT NONAME /dev/diskX

> diskutil list external physical

/dev/diskX (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *62.9 GB    diskX
   1:                        EFI EFI                     209.7 MB   diskXs1
   2:       Microsoft Basic Data NONAME                 62.7 GB    diskXs2

Without EFI

> diskutil eraseDisk -noEFI exFAT NONAME /dev/diskX

> diskutil list external physical

/dev/diskX (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *62.9 GB    diskX
   1:       Microsoft Basic Data NONAME                  62.9 GB    diskXs1
3
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jul 17 at 15:05
  • Answer is very clear thank you. Is the -noEFI flag listed anywhere in diskutil man page? Is this only available when using exFAT?
    – John
    Commented Jul 18 at 15:31
  • @John Yes, -noEFI is available in eraseDisk and partitionDisk along with many options, see man diskutil
    – Alice Chan
    Commented Jul 19 at 16:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .