How to enable File Vault from Terminal

osx-mavericks, shell, terminal

Solution

Try the `fdesetup` tool:

NAME
     fdesetup -- FileVault enabling tool

SYNOPSIS
     fdesetup verb [options]

DESCRIPTION
     fdesetup is used to enable or disable FileVault, to list, add, or remove
     enabled FileVault users, and to obtain status about the current state of
     FileVault. Most commands require root access and need to be authenticated
     with either a FileVault password, a personal recovery key (if enabled),
     and in some cases the private key from the installed institutional recov-
     ery key.  Some status related commands can be run from a non-root ses-
     sion.

...

Problem

I am trying to write a script to automate software installs on new computers using boxen. There is a requirement where boxen will only run if the hard drive is encrypted. I can disable it but I would like to encrypt the drive anyways. Is there a way to do it from terminal so that I can streamline the process more?

Original source