Creating new partition from boot volume

el2493
Contributor III

If I need to carve off 1 GB from the boot volume to create a new partition, is the best policy to create a script that uses the "diskutil splitPartition" command? I wasn't sure if there was a better way to do this through the JSS. I'm trying to avoid reimaging all computers if I can, and that seemed to be the cleanest way to do it that I could find.

And if anyone is familiar with that command (I haven't used it myself), is there any way in a script to unmount the boot volume before creating the new partition, or other ways to optimize the chance of the command not messing something up?

Thanks

6 REPLIES 6

Asnyder
Contributor III

http://www.theinstructional.com/guides/disk-management-from-the-command-line-part-2

That's what I do. It also allows you to password protect the partition if needed.

Look
Valued Contributor III

Worth noting at this point that once 10.13 converts the disks to APFS you will be using something like.

diskutil APFS resizecontainer $Container_ID $New_Container_Size FAT32 WINDOWS 0

This particular example obviously needing a few variables and designed to create a WINDOWS partition with the remaining space.

el2493
Contributor III

So I tried this and it looks like it messed stuff up with JSS.

I booted to a bootable USB drive and then ran:

diskutil splitPartition /dev/disk0s2 JHFS+ 'Macintosh HD' 498GB JHFS+ Examplify_Backup 2GB

Confirmed disk0s2 was the right partition, I had to use the apostrophes around Macintosh HD because the command wouldn't run otherwise. It seemed to complete, I shut down the computer, removed the USB, then booted to the internal HDD. It took longer to boot than I expected, then when it did boot it didn't automatically login to the local account that was created in JSS (and which had worked previously). I was able to login using a management account, and when I noticed it didn't seem to be checking in I ran sudo jamf policy and got the mesage "Device Signature Error - A valid device signature is required to perform the action."

I'm gonna keep troubleshooting and maybe try re-enrolling, but does anyone know if I missed something obvious with my command (like did I need to do something to set the 'Macintosh HD' as a bootable drive, or should I have only entered in the Examplify_Backup triplet of info)? I also noticed that if I go to Finder and click on Macintosh HD that it's empty, so I definitely did something wrong.

el2493
Contributor III

I also noticed if I did "diskutil list" that it's booting from (and all the Applications are stored on) a partition on the same HDD called "Netboot 1012," which didn't exist before. Definitely time for a rebuild...

Before rebuilding I booted from a USB drive and tried using splitPartition on the Netboot 1012 drive with the following command, hoping it might just skim 2GB off the existing partition and make it into a new partition:

diskutil splitPartition /dev/disk0s4 JHFS+ Examplify_Backup2 2GB

I didn't really think it would work but since it was already going to require a rebuild I figured it couldn't hurt anything. That ended up just making things worse, now diskutil list just shows the following partitions:

0: GUID_partition_scheme
1: EFE
2: Macintosh HD (this was created when I did the first split, it is totally empty), (498GB)
3: Examplify_Backup (2GB)
4: Examplify_Backup2 (2GB)

So the Netboot 1012 partition is gone. I'm having a hard time finding anything online that lists more than a brief paragraph or two on the usage of splitPartition, does anyone have any experience with this command and splitting the boot drive without breaking it? I would really rather not have to image 50-ish computers if I don't have to.

@Asnyder you mentioned you've used this command before, I was using the instructions on the website you provided (which seemed to be the most in-depth I could find, but still weren't as comprehensive as I would've liked).

Asnyder
Contributor III

You needed the parentheses because of the space. you could do Machintosh HD (the slash cancels the space). As far as setting the machd as the bootable drive you shouldn't have to. It gets blessed during imaging. I'm not sure where your extra partition came from. The netboot one, but something had to put it there. I don't use the split partition command.

diskutil partitionDisk /dev/disk2 GPT JHFS+ New 0b

el2493
Contributor III

Thanks, I've been looking into this and I think it'll be a lot easier to boot from a bootable USB and then use Disk Utility to decrease the boot partition by 2GB and turn that free space into a new partition. It's a lot easier than reimaging when things go wrong!