APFS to HFS+ Netbook Script

New Contributor

Hi Folks

We are trying to create a script that converts an APFS to HFS+ during a Netboot. The script we are using is below


We can netboot and run the command from terminal however if we try and run the command from a script in JSS it does nothing.

Any help would be great.


New Contributor II

Just adding more info

The following doesn't work either

diskutil apfs deleteContainer /dev/disk1s2 NewNuked

In Casper Imaging logs, all the scripts we have in the configuration have the following message (with the respective script names)

Downloading APFS_Nuke...
Could not download APFS_Nuke to the cache.

The script is set to run Before everything else in the config, and not on reboot

New Contributor III

Not sure if anyone is still looking for this, but found the following script on the deploystudio forums


convertDisk=$(diskutil list internal | grep -B 2 "APFS Container Scheme" | grep /dev | awk '{print $1}')

diskutil apfs deleteContainer "$convertDisk"

diskutil eraseDisk JHFS+ "Hard Disk" /dev/disk0


I'm investigating in our environment and will post an update on how it goes.

New Contributor III

Did my own testing. The above script almost works, but fails because following the deleteContainer step, /dev/disk0 ends up with a mounted partition called Untitled, and you can't format a mounted partition, obviously. Added 1 line and comments in case anything happening here isn't clear.


# Script to delete APFS container on any devices delivered with or upgraded to 10.13 with an APFS conversion
# Script adapted from this forum http://www.deploystudio.com/Forums/viewtopic.php?id=8035

# Find and name APFS Container
convertDisk=$(diskutil list internal | grep -B 2 "APFS Container Scheme" | grep /dev | awk '{print $1}')

# Delete APFS Container
diskutil apfs deleteContainer "$convertDisk"

# Unmount disk0 partition
diskutil unmountDisk force /Volumes/Untitled

# Reformat as HFS+ and name
diskutil eraseDisk JHFS+ "Macintosh HD" /dev/disk0


Note this is tested in current gen MacMinis, and I can't vouch for it on any other hardware, though I would expect behavior would be the same.

While the script does 'work' in the generic sense of the world, it didn't solve my problem, which is automating a downgrade of an APFS 10.13 Mac to HFS+ to install a 10.12-based image with Casper Imaging, as the disk you're targeting to image changes once the script runs. You can run the script manually and then follow the normal process, but running the script in casper imaging is a no-go.

Contributor II

@msw-sa and @Piggott did you ever find an automated way of converting a drive from APFS to HFS+ during a NetBoot?

New Contributor III

@dtmille2 I didn't. Been working on doing device deployment with DEP instead of using Jamf Imaging and imaging over the wire. Since we do still have occasional scenarios where we need to downgrade an APFS 10.13 device to HFS+ for 10.12, I used Platypus to package the script above into a little standalone app, and then added that to the Desktop of my netboot.

Since we often have non-technical staff imaging, they can just double-click to run this, then launch Casper/Jamf Imaging, and proceed as usual. Obviously offered without any guarantees that it won't break your computer, but you're welcome to try it out (or just make the script above into your own app using Platypus).