Divide partition on the drive where OS X used to reside into two partitions of equal size. Normally, the Disk Utility or diskutil
command would be used to make the changes. However, since you are booted from the recovery volume on the same drive, neither the Disk Utility or diskutil
command can be used to successfully make the changes. The procedure given in this step does use the diskutil
command, but not to make changes to the this drive. Other commands are used to make the changes.
Start by enter the command below to get a list of partitions.
diskutil list disk0
Below is the output from my test environment. I assume you would get similar output with different sizes.
-bash-3.2# diskutil list disk0
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme +268.4 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 267.6 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
For this procedure to work, the Macintosh HD
volume (disk0s2
) needs to be replaced by two volumes of equal size. Eventually, one of the volumes will be converted to free space and the other will be expand to fill this free space. To determine the size of the two new volumes, the following command needs to be entered to get the sizes pertaining to the current volume.
diskutil info disk0s2 | grep Size
Below is my output from entering the above command.
-bash-3.2# diskutil info disk0s2 | grep Size
Disk Size: 267.6 GB (267575697408 Bytes) (exactly 522608784 512-Byte-Units)
Device Block Size: 512 Bytes
Allocation Block Size: 4096 Bytes
The equation below can be used to compute the size of the new partitions in sectors.
Partition Size in Sectors = Disk Size in 512-Byte-Units/16*(4096/Device Block Size)
This equation can be evaluated by entering the command given below. You will need to replace the values of 522608784
and 512
with your values for Disk Size in 512-Byte-Units
and Device Block Size
, respectively.
echo "Partition Size in Sectors = $((522608784/16*(4096/512)))"
Below is my output from entering the above command.
-bash-3.2# echo "Partition Size in Sectors = $((522608784/16*(4096/512)))"
Partition Size in Sectors = 261304392
These next commands will prevent the partition (disk0s2
) containing the existing volume from mounting. Also, the new partitions created later will not be able to mount until after being formatted. You will need to replace the values of 261304392
and 512
with your values for Partition Size in Sectors
and Device Block Size
, respectively.
diskutil unmount disk0s2
dd if=/dev/zero count=100 bs=512 of=/dev/disk0s2
dd if=/dev/zero count=100 bs=512 seek=261304392 of=/dev/disk0s2
Below is my output from entering the above commands.
-bash-3.2# diskutil unmount disk0s2
Volume Macintosh HD on disk0s2 unmounted
-bash-3.2# dd if=/dev/zero count=100 bs=512 of=/dev/disk0s2
100+0 records in
100+0 records out
51200 bytes transferred in 0.024378 secs (2100249 bytes/sec)
-bash-3.2# dd if=/dev/zero count=100 bs=512 seek=261304392 of=/dev/disk0s2
100+0 records in
100+0 records out
51200 bytes transferred in 0.050295 secs (1017996 bytes/sec)
Use the gdisk
command to divide partition where OS X used to reside into two partitions of equal size. Here, I assume your EFI partition (/dev/disk0s1) is still mounted on /Volumes/EFI
. If not, enter the command below.
diskutil mount disk0s1
The command below can be used to execute gdisk
.
/Volumes/EFI/gdisk /dev/disk0
The above command is interactive. The table below lists the required entries. The commands and data need to be entered in the order given in the table.
Note: Read each comment and any applicable footnote carefully before making an entry.
Entries for 512 Byte Device Block Size |
Entries for 4096 Byte Device Block Size |
Comments |
x |
x |
Enter the experts' menu |
l |
l |
Change the sector alignment value |
8 |
1 |
New sector alignment value |
m |
m |
Return to main menu |
p |
p |
Display basic partition summary |
d |
d |
Delete a partition |
2 |
2 |
Partiton to delete |
n |
n |
Create a new partition |
2 |
2 |
Partition to create† |
409640 |
76806 |
Starting sector† |
+261304392 |
+32663049 |
Size in sectors* |
AF00 |
AF00 |
Hex code for HFS+ partition† |
n |
n |
Create a new partition |
4 |
4 |
Partition to create† |
261714032 |
32739855 |
Starting sector‡ |
+261304392 |
+32663049 |
Size in sectors* |
AF00 |
AF00 |
Hex code for HFS+ partition† |
s |
s |
Sort partition entries |
p |
p |
Display basic partition summary |
w |
w |
Write GPT to disk and exit |
y |
y |
Yes proceed to write and exit |
*You should enter the Partition Size in Sectors that you calculated earilier instead of the value shown. Note, the +
character is significant and should not be omitted.
†This should be the default value.
‡This should be the default value. However, the value you see will not be the same as shown in the table. The value you see will be the new second partition's starting sector plus size in sectors.
Below is my output from using the gdisk
command. The default values were used when appropriate.
-bash-3.2# gdisk /dev/disk0
GPT fdisk (gdisk) version 1.0.8
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.
Command (? for help): x
Expert command (? for help): l
Enter the sector alignment value (1-65536, default = 2048): 8
Expert command (? for help): m
Command (? for help): p
Disk /dev/disk0: 524288000 sectors, 250.0 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): D32269E7-0718-4BCC-A2BD-24ACA171AE82
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 524287966
Partitions will be aligned on 8-sector boundaries
Total free space is 13 sectors (6.5 KiB)
Number Start (sector) End (sector) Size Code Name
1 40 409639 200.0 MiB EF00 EFI System Partition
2 409640 523018423 249.2 GiB AF00 Apple HFS/HFS+
3 523018424 524287959 619.9 MiB AB00 Recovery HD
Command (? for help): d
Partition number (1-3): 2
Command (? for help): n
Partition number (2-128, default 2):
First sector (34-524287966, default = 409640) or {+-}size{KMGTP}:
Last sector (409640-523018423, default = 523018423) or {+-}size{KMGTP}: +261304392
Current type is AF00 (Apple HFS/HFS+)
Hex code or GUID (L to show codes, Enter = AF00):
Changed type of partition to 'Apple HFS/HFS+'
Command (? for help): n
Partition number (4-128, default 4):
First sector (34-524287966, default = 261714032) or {+-}size{KMGTP}:
Last sector (261714032-523018423, default = 523018423) or {+-}size{KMGTP}: +261304392
Current type is AF00 (Apple HFS/HFS+)
Hex code or GUID (L to show codes, Enter = AF00):
Changed type of partition to 'Apple HFS/HFS+'
Command (? for help): s
You may need to edit /etc/fstab and/or your boot loader configuration!
Command (? for help): p
Disk /dev/disk0: 524288000 sectors, 250.0 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): D32269E7-0718-4BCC-A2BD-24ACA171AE82
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 524287966
Partitions will be aligned on 8-sector boundaries
Total free space is 13 sectors (6.5 KiB)
Number Start (sector) End (sector) Size Code Name
1 40 409639 200.0 MiB EF00 EFI System Partition
2 409640 261714031 124.6 GiB AF00 Apple HFS/HFS+
3 261714032 523018423 124.6 GiB AF00 Apple HFS/HFS+
4 523018424 524287959 619.9 MiB AB00 Recovery HD
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/disk0.
Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Warning: The kernel may continue to use old or deleted partitions.
You should reboot or remove the drive.
The operation has completed successfully.
Enter the following command to get the identifiers for the two new Apple_HFS
type partitions.
diskutil list disk0
Below is my output from entering the above command.
Note: The output is still showing the Macintosh HD
as the name of disk0s2
. This name will be updated later, when the diskutil
is used to mount disk0s2
.
-bash-3.2# diskutil list disk0
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme +268.4 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 133.8 GB disk0s2
3: Apple_HFS 133.8 GB disk0s5
4: Apple_Boot Recovery HD 650.0 MB disk0s3
Enter the following command to format, mount and list the two new partitions. If your two new partitions have identifiers which differ from disk0s2
or disk0s5
, then make the appropriate substitutions.
newfs_hfs -J -v Upper /dev/disk0s2
newfs_hfs -J -v Lower /dev/disk0s5
diskutil mount disk0s2
diskutil mount disk0s5
diskutil list disk0
Below is my output from entering the above commands.
-bash-3.2# newfs_hfs -J -v Upper /dev/disk0s2
Initialized /dev/rdisk0s2 as a 125 GB case-insensitive HFS Plus volume with a 16384k journal
-bash-3.2# newfs_hfs -J -v Lower /dev/disk0s5
Initialized /dev/rdisk0s5 as a 125 GB case-insensitive HFS Plus volume with a 16384k journal
-bash-3.2# diskutil mount disk0s2
Volume Upper on disk0s2 mounted
-bash-3.2# diskutil mount disk0s5
Volume Lower on disk0s5 mounted
-bash-3.2# diskutil list disk0
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme +268.4 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_HFS Upper 133.8 GB disk0s2
3: Apple_HFS Lower 133.8 GB disk0s5
4: Apple_Boot Recovery HD 650.0 MB disk0s3
Quit the Terminal application.
Open Safari by selecting "Get Help Online". Under Safari Preferences, set "File download location:" to the Lower
device, as shown below.

At this point, I offer two options. The first option would be to use website http://maclinks.publicvm.com (or https://maclinks.publicvm.com) to get the URL or link necessary to download the InstallMacOSX.dmg
file for Mountain Lion from Apple. If you use the first option, then you can skip the rest of this step. The second option would be to proceed with the rest of this step.
Next, goto https://support.apple.com/kb/DL2076. If you are using a newer version of Safari, then a Download
button will appear, as shown below. If the button appears then select the button, download the InstallMacOSX.dmg
file to /Volumes/Lower
and proceed to the next step. Otherwise, complete the rest of this step.

Most likely, the Download
button will not appear, as shown below.

From menu bar, select File
→Save As…
, then set the format to Page Source
, as shown below. When finished, select the Save
button, the quit Safari.

From the menu bar, select Utilities
→Terminal
to open a Terminal window and enter the command below. This will output text containing the URL assigned to the missing Download
button.
grep updates /Volumes/Lower/Mac\ OS X\ Mountain\ Lion\ Installer.html
When I run the above command, the following was output.
"metaUrl": "https://updates.cdn-apple.com/2021/macos/031-0627-20210614-90D11F33-1A65-42DD-BBEA-E1D9F43A6B3F/InstallMacOSX.dmg",
From which, the following URL can be extracted.
https://updates.cdn-apple.com/2021/macos/031-0627-20210614-90D11F33-1A65-42DD-BBEA-E1D9F43A6B3F/InstallMacOSX.dmg
From your output, copy the Url, quit Terminal, open Safari and paste the URL as the location to open. This should download the InstallMacOSX.dmg
file to /Volumes/Lower
.