Make and format partition with command prompt in recovery mode

Joined
Nov 4, 2021
Messages
9
Reaction score
0
Points
1
I need to know how to make and format a partition for OS in recovery mode using command prompt. Currently, other than the recovery partition, there is only free space. The graphic options do not respond/are greyed out. I tried these:

This link: Disk Management From the Command-Line, Part 2 - The Instructional gives this example:
diskutil partitionDisk /dev/disk2 GPT JHFS+ New 0b

Using that example, I tried: diskutil partitionDisk /dev/disk0 GPT HFS+ OS Ob
Here is the result: "Ob does not appear to be a valid disk size"

The installer needs 6 gb, so I tried: diskutil partitionDisk /dev/disk0 HFS+ OS 6g
Here is the result: "Error: 69888: Couldn't unmount disk"

I need more clues. Thanks.
 
Joined
Jan 1, 2009
Messages
16,378
Reaction score
4,731
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
Welcome to the forum.

The example ends in 0b, zero-b

Your line ends in Ob, capital-o b.

That's one error. But I don't think you can create a zero byte partition. Maybe you can, but it seems really strange to do so.

Why don't you tell us more about what it is you want to do? What Mac, what version of macOS was on it, what do you mean by "graphic options?"

Trying to do things from Terminal when you don't know what you are doing is very, very risky. It is really easy to end up with a doorstop instead of a computer.
 

Slydude

Well-known member
Staff member
Moderator
Joined
Nov 15, 2009
Messages
17,928
Reaction score
1,352
Points
113
Location
North Louisiana, USA
Your Mac's Specs
M1 MacMini 16 GB - Sequoia, iPhone 14 Pro Max, 2015 iMac 16 GB Monterey
If you're trying to create a new partition to re-install a version of the OS, you can usually be done from the Recovery partition without using Terminal.
 
OP
R
Joined
Nov 4, 2021
Messages
9
Reaction score
0
Points
1
MacInWin:
-0/O--okay. In the example line, there was no slash, so it looked like the letter. I tried again with zero, but received a couldn't unmount disk error.
-According to the article, 0b does not create a zero byte partition, but instead creates a partition using all the remaining available free space, that is what I wanted, after creating a 6g partition for the installer.
-The icon in MacUtilities looks like High Sierra.
-By "graphic options", I mean what I believe Slydude is referring to, but the Add option is greyed out.
-Using terminal is no risk here as there is nothing on it anyway. I can partition and format MS disks all day long, but I don't know how to do it with this.

Slydude is correct. I am trying to create a partition to install OS. I already ran the installer and it is looking for a partition to install it on. It only shows the recovery partition to choose from but it is greyed out, of course, because it shouldn't be installed there. There are no other partitions because the rest is allocated as free space.
 
OP
R
Joined
Nov 4, 2021
Messages
9
Reaction score
0
Points
1
Thanks, for your response.

Stage 1: Regarding mounting the drive, mount is greyed out, so I would guess it already is mounted.

Stage 2: Regarding Install MacOS, this results in "The recovery server could not be contacted", ...and yes, wifi is on and connected. That is why I downloaded the installer (external drive), which looks like it is going to work, but again, it is looking for a place to install.

Stage 3: After selecting the internal disk, I find no option on the page toolbar that says, "Format".

Stage 4 is not applicable because in my case, Stage 3 did not use APFS.
 

IWT


Joined
Jan 23, 2009
Messages
10,700
Reaction score
2,599
Points
113
Location
Born Scotland. Worked all over UK. Live in Wales
Your Mac's Specs
M2 Max Studio Extra, 32GB memory, 4TB, Sequoia 15.4.1 Apple 5K Retina Studio Monitor
that is what I wanted, after creating a 6g partition for the installer.

Are you sure 6GB is enough space? You haven't said what you are installing, but if it's any recent macOS, you will probably need more than 6GB.

Ian
 
Joined
Jan 1, 2009
Messages
16,378
Reaction score
4,731
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
Here is Apple's guide on reinstalling macOS. How to reinstall macOS In it is this image:
Screen Shot 2021-11-05 at 11.10.42 AM.png

From your description, you are getting to that image, right? And then selecting Disk Utility to format the drive? If that is correct, you should see something like this:
Screen Shot 2021-11-05 at 11.14.06 AM.png

To get to this exact view, select "View" on the bar above the device information and then "Show All Devices" to get the hardware to show. Once that is done, if you post it here we can see what is going on with the drive and give exact steps to get you a partition or Container to do what you want.
 
OP
R
Joined
Nov 4, 2021
Messages
9
Reaction score
0
Points
1
Are you sure 6GB is enough space? You haven't said what you are installing, but if it's any recent macOS, you will probably need more than 6GB.

Ian
The 6gb partition is not to install macOS, but it is to install the installer that installs macOS. I already tried it and it indeed starts installing until asking me where to install, which is what I need to create the partition for the macOS.
 
OP
R
Joined
Nov 4, 2021
Messages
9
Reaction score
0
Points
1
Here is Apple's guide on reinstalling macOS. How to reinstall macOS In it is this image:
View attachment 34966

From your description, you are getting to that image, right? And then selecting Disk Utility to format the drive? If that is correct, you should see something like this:
View attachment 34967

To get to this exact view, select "View" on the bar above the device information and then "Show All Devices" to get the hardware to show. Once that is done, if you post it here we can see what is going on with the drive and give exact steps to get you a partition or Container to do what you want.


See under Stage 2 in my previous post.
 
Joined
Jan 1, 2009
Messages
16,378
Reaction score
4,731
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
Stage 2 is not dependent on having a connection. All Stage 2 requires is a recovery partition, or a bootable installer.

I don't think your plan is going to work as you are setting out. The drive from which you are booted cannot be changed. You will need to make an external bootable drive, boot from that, then use Disk Utility to format the internal as needed, reinstall the OS and then boot from the internal.
 

Slydude

Well-known member
Staff member
Moderator
Joined
Nov 15, 2009
Messages
17,928
Reaction score
1,352
Points
113
Location
North Louisiana, USA
Your Mac's Specs
M1 MacMini 16 GB - Sequoia, iPhone 14 Pro Max, 2015 iMac 16 GB Monterey
The 6gb partition is not to install macOS, but it is to install the installer that installs macOS. I already tried it and it indeed starts installing until asking me where to install, which is what I need to create the partition for the macOS.
If I'm understanding what you mean correctly, I don't believe the macOS installer behaves that way. You don't actually "install" the installer. It gets copied to the drive during the download. When it is actually run the installer needs some free disk space to work properly. A 6 GB partition isn't enough for recent Os versions.
 
OP
R
Joined
Nov 4, 2021
Messages
9
Reaction score
0
Points
1
Stage 2 is not dependent on having a connection. All Stage 2 requires is a recovery partition, or a bootable installer.

I don't think your plan is going to work as you are setting out. The drive from which you are booted cannot be changed. You will need to make an external bootable drive, boot from that, then use Disk Utility to format the internal as needed, reinstall the OS and then boot from the internal.


"Stage 2 is not dependent on having a connection"--I know that, but that is what it says.
 
OP
R
Joined
Nov 4, 2021
Messages
9
Reaction score
0
Points
1
If I'm understanding what you mean correctly, I don't believe the macOS installer behaves that way. You don't actually "install" the installer. It gets copied to the drive during the download. When it is actually run the installer needs some free disk space to work properly. A 6 GB partition isn't enough for recent Os versions.

Well, the operation is through "Restore". It "restores" the installation disk image to a partition, and then that "restored" installation disk image should install the OS.
 
OP
R
Joined
Nov 4, 2021
Messages
9
Reaction score
0
Points
1
Even though I figured this out at the end, I would not have been able to do so without the clues given to me in this thread regarding the Mac command language and syntax--thank-you.


Here is what I did:

1. When I tried to create a partition out of free space using Disk Utility, the options to do so are greyed out.

2. If I try to use Mac command line to create a partition out of free space, it always gives the error: couldn't unmount disk. I assume this means Apple, unlike Windows, cannot create partitions from free space when it is performed from a partition from the same physical drive, even though it is not affected by making more partitions, so...

3. Next, I created a 6g partition for the OS installer using a Windows machine (ntfs). The OS installer then installed ("restored") there and automatically reformated to Mac formatting. I then tried to run the installer on Mac to install OS on the free space, assuming it would create its own partition for the OS, or offer me some options to do so as part of the installation. Instead, it only showed the 6g partition and did nothing else.

4. I then created a partition out of the remainder of the free space, again using Windows (ntfs). I then ran the installer. It recognized the new partition and displayed it as the option to choose the location. However, it would not let me select it. When I tried to use Disk Utility to reformat it using Mac formatting, no matter what formatting I chose, it always says: Failed...not enough space on device for requested operation--which does not make sense to me.

5. Next, I tried installing the OS installer to a flash drive and started over with just free space on Mac HD (except for the recovery partition). Again, it would not recognize, offer partitioning options, or do anything with the free space, and again, partitioning options in Disk Utility were greyed out. I tried again initially formatting with Windows formatting (ntfs) just so it would recognize the partition and hopefully redo it...but nope, same results as before.

6. Finally, I wondered if formatting with Mac command line would now work because the installer was running externally on the flash drive...Doggone, it let me format...and then, doggone, it both displayed and allowed me to choose the new formatted space...DOGGONE, it let me install the thing!!

Conclusions:
1. Disk utility, unlike Windows, will NOT allow partitioning on free space from a separate partition on the same physical drive.
2. Disk Utility partitioning/formatting of the internal drive will NOT work, even from an external drive. Command line must be used (externally).
3. MacOS installers do NOT offer partitioning/formatting options upon install. It must be performed prior to install by the user with command line.
 
Joined
Jan 1, 2009
Messages
16,378
Reaction score
4,731
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
It is not that DU won't allow partitioning of free space, it is that it won't allow partitioning/erasing/formatting on the boot drive. You finally got to format the internal drive when booted from the external drive. I told you that in post #11.

DU will work if you are booted from an external drive into the Recovery Panel (post #8). I've done it lots of times. I've never had to use the command line. I don't know why your setup wouldn't allow formatting of the internal, once booted from an external, but DU will definitely do that, normally.

Mac OS installers, when booted from external drives, offer Disk Utility from which to format the target of the installation. It's how you replace a drive on a Mac. Build a bootable installer external drive, replace the internal drive with a new one, boot from the external, use DU to format the new drive for the Mac, run the installer and you are done. I've done that multiple times as well, as have others here on this board.

I don't know why you had to use the command line interface, or Windows, to install the system. I've never heard anybody say that was the case, before your experience. Done properly, a bootable external drive with the installer application on it will boot to the Recovery panel I posted in post #8 and allow DU to be started to format the target drive.
 
OP
R
Joined
Nov 4, 2021
Messages
9
Reaction score
0
Points
1
It is not that DU won't allow partitioning of free space, it is that it won't allow partitioning/erasing/formatting on the boot drive. You finally got to format the internal drive when booted from the external drive. I told you that in post #11.

DU will work if you are booted from an external drive into the Recovery Panel (post #8). I've done it lots of times. I've never had to use the command line. I don't know why your setup wouldn't allow formatting of the internal, once booted from an external, but DU will definitely do that, normally.

Mac OS installers, when booted from external drives, offer Disk Utility from which to format the target of the installation. It's how you replace a drive on a Mac. Build a bootable installer external drive, replace the internal drive with a new one, boot from the external, use DU to format the new drive for the Mac, run the installer and you are done. I've done that multiple times as well, as have others here on this board.

I don't know why you had to use the command line interface, or Windows, to install the system. I've never heard anybody say that was the case, before your experience. Done properly, a bootable external drive with the installer application on it will boot to the Recovery panel I posted in post #8 and allow DU to be started to format the target drive.



" It is not that DU won't allow partitioning of free space, it is that it won't allow partitioning/erasing/formatting on the boot drive. "
--It was booting from the recovery partition (drive), which was not being affected. Apparently, it disallows anything on the physical drive, whether it is affected or not, and I was comparing that Windows will do so on the same drive, if it is not affecting the boot partition that is doing the operations. (Actually, as far as the installer being able to use it, the formatting I tried with Windows was not successful, as I had to start over with free space and re-do it from the Mac command line. I only included it to note that I had tried it.)

"Mac OS installers, when booted from external drives, offer Disk Utility from which to format the target of the installation."
--I think you are saying here that Disk Utility IS the "offer" of partitioning options I mentioned. I should have added then, "other than Disk Utility", or a more direct option.

I understand what you are saying and what you posted in 8 and 11, but for some reason in this case, it just would not work that way.

I do appreciate everyone's help here.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top