[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 488
  • Last Modified:

Precision Partitioning Mac From Terminal

How to set partitions sizes to byte-level accuracy using Terminal (on Mac)

Examples:
1) diskutil list
2) diskutil resizeVolume /Volumes/MT Limits
3) diskutil resizeVolume /Volumes/MT 40000000000b

Above series of commands work great for one partition, however not so good for multiple partitions.

So possibly use  "diskutil"   instead of  "resizeVolumes" ?

Be gentle - I are 100% senile and can prove it.   ;-)

SuperSenile
0
SuperSenile
Asked:
SuperSenile
  • 16
  • 5
1 Solution
 
SuperSenileAuthor Commented:
Here is the  "Added Attachment"  which proves that partitions can be set to precise values - - - Now if there were only ways to set   _many_   partitions, then I would be happy.
Added-Attachment.rtf
0
 
SuperSenileAuthor Commented:
0
 
serialbandCommented:
You should probably work with the Disk Identifiers instead of the mount points for adjusting the partitions first.

diskutil splitPartition
diskutil mergePartitions

Once you created the partitions then you can resize the volumes.

See the following for more information
http://www.macworld.com/article/1055274/marchgeekfactor.html
http://www.theinstructional.com/guides/disk-management-from-the-command-line-part-1
0
A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

 
SuperSenileAuthor Commented:
This is the main attachment file to show the list of Terminal commands I used to set precise partition sizes at the byte level.
0
 
SuperSenileAuthor Commented:
"You should probably work with the Disk Identifiers instead of the mount points for adjusting the partitions first.

diskutil splitPartition
diskutil mergePartitions

Once you created the partitions then you can resize the volumes."

Thanks serialband for responding.

I had already created four equally sized partitions of approximately 60-GB before I issued the series of commands in my main attachment file named FOO.

The commands I issued did indeed change the 2nd partition to an exact size of 40,000,000,000 bytes.

However, every attempt I make to set all four partitions to exact size fails.

I had hopes that I should abandon the command "resizeVolumes" and instead use the command named "diskutil" in my attempt to set all four partitions to exact byte value.

However I am totally lost in understanding the "man diskutil" page, so had hope that a Unix expert could give me a "canned" solution that would work.

I understand that I can't adjust the last 4th partition to an exact value because I am told that Unix can't do that.

Does any of this babbling make sense to you?
0
 
serialbandCommented:
Example: diskutil resizeVolume disk0s2 10G JHFS+ 10G JHFS+ (Creates two partitions of 10GB apiece formatted as Journaled HFS+ systems).

Taken from: https://superuser.com/questions/50317/resize-hfs-partition
0
 
SuperSenileAuthor Commented:
Thanks serialband for helping, this is a tough problem.

diskutil resizeVolume disk0s2 10G JHFS+ 10G JHFS+

...just yields an error message for me:

       Jhfs+ does not appear to be a valid disk size

I carefully re-entered the command again however the same error message appeared.

Shall I include an attachment of the actual Terminal printout ?

Again, thanks very much for helping, this problem is driving me batty.

From SuperSenile
0
 
serialbandCommented:
From the Error message, it suggest that you only put sizes there.  Maybe try diskutil resizeVolume disk0s2 10G 10G 10G 10G
0
 
SuperSenileAuthor Commented:
Thanks, I will try that.
0
 
SuperSenileAuthor Commented:
I will be offline for about 7-hours.

Pesky working for a living issues.

BTW, thanks for the help.


from  SuperSenile
0
 
SuperSenileAuthor Commented:
Okay, finally free to concentrate on how to set more than one partition to an exact size in bytes, such as 40,000,000,000 bytes.  (40 GB)

To clear the air, I am using a 17-inch Macbook pro made in 2010 with an internal 500 GB SSD running the latest Mavericks OS and using "Terminal" to issue commands.

I can already issue a Terminal command for one precise sized partition, say 40 GB to the nearest byte.

When I attempt to set (or reset) more than one partition, I invariably fail because I do not know how to do it, to the nearest byte.

This would be a trivial task for an expert in Unix with his own Mac.

I also have a more recent 15-inch Macbook Pro bought in Feb of 2014 with a one TB SSD as its internal drive.

Same problem with setting more than one partition to a precise byte size.

Expert "serialband" is kindly helping me, I will try his latest Unix code suggestions including initial setup and results.

"Maybe try diskutil resizeVolume disk0s2 10G 10G 10G 10G"

Only my version of it   :-)

diskutil resizeVolume disk0s2 10000000000b 100000000004b 10000000008b 10000000016b 2000000000b

My initial setup will be a 2-TB USB-3.0 drive with one JHFS+ partition.

It will have one GUID type file system installed.

Terminal printout and results should be forthcoming in about an hour from now.
0
 
SuperSenileAuthor Commented:
Okay, the results are in for my futile attempt to create precision sized partitions.

Please scan the attached file, thanks'
TERMINAL-PRINTOUT.rtf
0
 
SuperSenileAuthor Commented:
I think I am forgetting about the limitations of Mac file systems, which normally jump in 1024 byte "steps".

With that in mind, the most "precise" steps would be only in jumps of 1024 bytes.

How could I forget such basic things?

In other words a 10-GB Mac partition would be exactly  10737418240 bytes.

I could decrease its size by 1024 bytes to exactly 10737417216 bytes.

But could not set any other size values except those that fall directly on 1024 byte boundaries.
0
 
SuperSenileAuthor Commented:
Hi everyone.

Just a last gasp before I give up trying to set "multiple" partitions on one volume to byte-precision values.

I mentioned that I could set ONE partition to byte-precison values.

Attached to this comment is the Terminal printout that accomplishes this task, please read the attached file.

If you want to tackle this "impossible" task of changing precision-byte-level values on "multiple" partitions of the same volume, be sure to reset the font sizes.   I increased the size of the fonts merely to make the size values more human-readable - - - OR you can merely just type all the lines from scratch by hand.
FOO.rtf
0
 
serialbandCommented:
That byte precision may be an artificial setup.  Disk partitions have always aligned to the sector size.  If a partition were really set to precise byte sizes, then part of the disk is wasted in the last sector.
0
 
SuperSenileAuthor Commented:
Thank for that info' - - - Another thing that complicates matters is that I am doing this on SSDs where sectors have little meaning.

Descriptive terminology has not caught up with the SSD hardware yet.   :-|


I would settle for a way to get the partition sizes back to their original sizes, if a Black Hat scrambled the partitions.

This was dead easy to repair when using Unix  "dd"  with spinning mechanical drives.

dd does not work with a SSD.
0
 
serialbandCommented:
SSDs are also written in Blocks.  If they were written to and tracked by individual bytes, you'd need double the circuitry and storage space just to keep track of it.
0
 
SuperSenileAuthor Commented:
I assume SSDs will be written in bigger-sized blocks for larger SSDs.

Think I will play around with smaller variations in my requested partition sizes, just to "feel out" how small a size that will reliably work.

I already know that a KB fails to work, and a MB works reliably on the SSD I am playing with now.

Perhaps half a MB might work reliably, unless I switch to TB sized SSDs that might use larger block sizes.

My main problem remains to be that   _nothing_   I tried has worked on anything except the first partition.

I will be using 16 partitions, with no way to "precision adjust" any partition except the 1st partition. Grrr

I don't much care about the 16th partition, I will just use that as an overflow partition.

Every time I try to adjust the size of a partition, it messes up the assigned size of its neighboring partitions.

Tell ya, it is rough being senile.   ;-)
0
 
SuperSenileAuthor Commented:
Okay, closing remarks.

It appears that 8-KB is the size of blocks on the 2-TB external drive I am using.  (spinning mechanical drive)

Terminal lists the size of my partition okay, for example 80,000,008,192 bytes, or in any multiples of 8192 bytes.

Terminal's  "resizeVolume" appears incapable of setting the exact size of anything except the 1st partition.

I have 15 partitions I want to set the exact size of, down to the byte, when setting partition sizes in block-steps.

For example:

80,000,000,000
80,000,008,192
80,000,016,384
80,000,024,576
etc., etc.

So I have to find some Terminal code to allow me to set a partition's size without changing the size of partitions already set to my requested size.

In other words, to "grow" or "shrink" a partition in its downward direction only, without disturbing the size of partitions sitting on top of it.

Crude language, but hopefully you catch my intent.

That way I could set my partition sizes one at a time, from top to bottom, with any overflow going to a 16th partition.

Hope Springs Eternal.
0
 
SuperSenileAuthor Commented:
Problem FINALLY solved - I had to drop  "resizeVolume" which was getting me nowhere.

Started playing with "partitionDisk" instead.

After MUCH trial-and-error, success, see attached file.

If you want to play with it, be certain to start out with your drive formatted as ONE big partition.

The winning line is:

diskutil partitionDisk disk2 4 JHFS+ PART-1 85900394496b JHFS+ PART-2 85900394496b JHFS+ PART-3 85900394496b JHFS+ PART-4 85900394496b


Proof-of-Concept line is:

sudo gpt -rv show disk2
SOLVED.rtf
0
 
SuperSenileAuthor Commented:
Expert's Exchange did NOT make it clear WHO was getting credit for the solution.

As their was only expert I was communicating with , I assumed he was getting the credit.

Without his help, I doubt whether I would have arrived at my solution.

I prefer that he gets all 500 points for his help.

Please arrange that, because I do not know how to do it myself.

Thanks
0

Featured Post

Automating Your MSP Business

The road to profitability.
Delivering superior services is key to ensuring customer satisfaction and the consequent long-term relationships that enable MSPs to lock in predictable, recurring revenue. What's the best way to deliver superior service? One word: automation.

  • 16
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now