Skip to main content

I got back a Mac from a client that had enabled FileVault. All I want to do is re-format the drive and be on my way.
I don't ned to save any data. I don't have the unlock key and the system won't boot normally in order to turn off or decrypt the machine.
In Disk Utility I don't have the option of re-partitionaing the drive. In order to just format the main partition I'm prompted to unlock the disk.
Is there any way to just reformat the disk along with any encryption information?

@wmateo, still use the script as a manual process. It's located on the desktop when our techs use Netboot. They have to manually click on the script to run it when it's needed.

I have noticed that with 10.9, it looks like you can erase a encrypted drive using Disk Utility. I think you have to unlock it first. By default Disk Utility will want to format the drive as "Mac OS Extended (Journaled, Encrypted)" and you'll need to change it to "Mac OS Extended (Journaled)".

I would not want to have the script run automatically, because there can be many variations of hard drives connected to the system. The tech might net boot, or boot from a external drive. They might also have another drive connected for backing up the user's data. I don't want to take chances at nuke and paving the wrong drive. That's also why the script includes the list of connected drive and informs the tech to be certain disk0 is the one you want formatted. With more effort in the script, I believe you could display the list of drives and prompt the tech for the correct drive to format.


@jhalvorson Thanks, yes, that is possible but with the NetInstall Creator the casper imaging app wont even run, because drive is not unlocked. so I have resorted to making my own NetBoot Image and including Diskutility in it.


Updated script to fix issue with error 69888 (couldn't umount disk)

#!/bin/sh

# Author: Jared F. Nichols
# Purpose: Nuke and pave the first internal drive to prepare for imaging.
# Reference:  https://jamfnation.jamfsoftware.com/discussion.html?id=5763
# Modified by Jason Halvorson
# - added displaying of drives and volumes (2013/04/24)
# - added second verification process prior to format drive (2013/04/24)
# - folded to the peer request to not use 'nuke and pave' in the dialog :( (2013/04/24)
# Modified by Erik Aulin
# - added unmountDisk to adress error 69888

clear
echo "Show all drives:"
echo
diskutil list
echo "-----"
echo
echo "This script will reformat /dev/disk0 listed above."
echo "Be aware the list includes external and extra internal drives."
echo
sleep 2
echo
echo "If you are not certain which drive will be reformatted,"
echo "enter 'n' at the next prompt."
echo
echo "Do you wish to remove all partions and reformat the /dev/disk0 drive?"
echo "Type 'y' to continue with formatting or type 'n' to quit this tool."
printf "(y/n) "
read response

case $response in
    Y|y|YES|yes|Yes|yEs|yeS|YEs|yES)
        echo
        echo
        echo
            echo "All data will be erased from /dev/disk0 with zero chance of recovery."
            echo "Are you really sure you want to format it?"
            echo "Type 'sure' to continue with formatting or type 'exit' to quit this tool. "
            printf "(sure/exit) "
            read response2

            case $response2 in
            sure|Sure|SURE)
            echo
            echo
            sudo diskutil unmountDisk force /dev/disk0
            sudo diskutil partitionDisk /dev/disk0 1 gpt jhfs+ "Macintosh HD" 100%
            echo
            echo "The drive... "
            echo "  has been named 'Macintosh HD'"
            echo "  is formated as Mac OS X Extended (Journaled)"
            echo "  removed the recovery partition.  Now a single partition."
            echo
            echo "Continue with Casper Imaging."
            echo
            echo
            exit 0 # Normal Exit
            ;;
            exit|EXIT|Exit|N|n|NO|no|No|nO)
            echo
            echo
            echo "No changes have been made to any drive(s). "
            echo
            echo
            exit 1 # User quit
            ;;
            esac
        echo
        exit 0 # Normal Exit
        ;;
    N|n|NO|no|No|nO)
        echo
        echo
        echo "No changes have been made to any drive(s)."
        echo
        echo
        exit 1 # User quit
        ;;
esac

Hey is anybody seeing this with Sierra .3?

diskutil partitionDisk /dev/disk0 1 gpt jhfs+ "Macintosh HD" 100%
Started partitioning on disk0
Unmounting disk
Error: -69877: Couldn't open device
(Is a disk in use by a storage system such as AppleRAID, CoreStorage, or APFS?)


Hi @gachowski , I have seen this and was able to get around it by using "diskutil cs revert logicalvolumeidstring". "diskutil cs list" to get the ID. Once reverted, repartitioning worked. In my case, it was an unencrypted corestorage device.

I ran into it while netbooting and wiping a drive on a Mac mini.

-Dennis


@dmueller

Thanks Dennis, That got me focused and found my issue I had code for cs in my script, but it wasn't pulling the correct info... : )

C


[@dmueller](@dmueller)
I have been trying since one moth I could do nothing with the usb I try your solution but this what I got when I post the "diskutil cs list this "No CoreStorage logical volume groups found", I am feeling loose.


Hi @alex.villalta.10, you may need to unmount the drive first. Depending on what you see with "diskutil list", if the drive is disk0, you can try "sudo diskutil unmountDisk disk0" first, then try to repartition the drive. CoreStorage is typically seen with the fusion drives and those encrypted with FileVault2.

Hope this helps.

-Dennis


Hi, on Macbook Pro A1706 i had Firewault enabled drive. I did boot to Recovery mode. In terminal i ran the command " diskutil cs delete UUID " .
Then i did reboot. Well, i did not made new partition.

Now when i am trying to boot from USB device ( key ALT held on start ), it shows me USB with new OS. After selecting boot device, the " NO WAY " sign is shown.

What to do now please ?

I am able to boot to Internet Recovery, but i do not know, if i deleted whole disk, including icloud etc. because i forgot the password.

Thanks for advice, Lucas