Created
June 23, 2012 19:07
-
-
Save mralexgray/2979512 to your computer and use it in GitHub Desktop.
OS X Lion diskutil commands (documented and hidden).sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Usage: diskutil coreStorage list | |
Usage: diskutil coreStorage info[rmation] [-plist] | |
Usage: diskutil coreStorage convert | |
Usage: diskutil coreStorage revert | |
Usage: diskutil coreStorage create lvgName | |
Usage: diskutil coreStorage delete lvgUUID | |
Usage: diskutil coreStorage addDisk lvgUUID NewMemberDeviceName | |
Usage: diskutil coreStorage removeDisk pvUUID | |
Usage: diskutil coreStorage deleteVolume lvUUID | |
Usage: diskutil coreStorage resizeVolume lvUUID size | |
Usage: diskutil coreStorage resizeDisk pvUUID size | |
Usage: diskutil coreStorage resizeStack lvUUID size | |
Usage: diskutil coreStorage unlockVolume lvUUID | |
Usage: diskutil coreStorage changeVolumePassphrase|passwd lvUUID | |
Usage: diskutil coreStorage createVolume lvgUUID type name size | |
Usage: diskutil enableJournal MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil disableJournal [force] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil moveJournal internal MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil moveJournal external | |
Usage: diskutil verifyVolume MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil repairVolume MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil verifyDisk MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil repairDisk MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil verifyPermissions [-plist] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil repairPermissions [-plist] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil resetUserPermissions MountPoint|DiskIdentifier|DeviceNode UID | |
Usage: diskutil listUsers MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil info[rmation] [-plist] | |
Usage: diskutil list [-plist] [MountPoint|DiskIdentifier|DeviceNode] | |
Usage: diskutil listFilesystems [-plist] | |
Usage: diskutil activity | |
Usage: diskutil mount [readOnly] [-mountPoint Path] DiskIdentifier|DeviceNode | |
Usage: diskutil mountDisk DiskIdentifier|DeviceNode | |
Usage: diskutil u[n]mount [force] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil u[n]mountDisk [force] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil eject MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil rename[Volume] MountPoint|DiskIdentifier|DeviceNode newName | |
Usage: diskutil enableOwnership MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil disableOwnership MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil eraseDisk format name [[APM]Format|[MBR]Format|[GPT]Format] | |
Usage: diskutil eraseVolume format name MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil reformat MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil eraseOptical [quick] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil zeroDisk MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil randomDisk [times] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil secureErase [freespace] level MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil partitionDisk MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil mergePartitions [force] format name | |
Usage: diskutil splitPartition MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil resizeVolume MountPoint|DiskIdentifier|DeviceNode size | |
Usage: diskutil appleRAID create mirror|stripe|concat setName | |
Usage: diskutil appleRAID delete | |
Usage: diskutil appleRAID list [RAIDSetUUID] | |
Usage: diskutil appleRAID enable mirror|concat MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil appleRAID repairMirror | |
Usage: diskutil appleRAID update key value | |
Usage: diskutil appleRAID add member|spare | |
Usage: diskutil appleRAID remove MemberDeviceName|MemberUUID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Usage: diskutil coreStorage list | |
Usage: diskutil coreStorage info[rmation] [-plist] | |
Usage: diskutil coreStorage convert | |
Usage: diskutil coreStorage revert | |
Usage: diskutil coreStorage create lvgName | |
Usage: diskutil coreStorage delete lvgUUID | |
Usage: diskutil coreStorage addDisk lvgUUID NewMemberDeviceName | |
Usage: diskutil coreStorage removeDisk pvUUID | |
Usage: diskutil coreStorage deleteVolume lvUUID | |
Usage: diskutil coreStorage resizeVolume lvUUID size | |
Usage: diskutil coreStorage resizeDisk pvUUID size | |
Usage: diskutil coreStorage resizeStack lvUUID size | |
Usage: diskutil coreStorage unlockVolume lvUUID | |
Usage: diskutil coreStorage changeVolumePassphrase|passwd lvUUID | |
Usage: diskutil coreStorage createVolume lvgUUID type name size | |
Usage: diskutil enableJournal MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil disableJournal [force] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil moveJournal internal MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil moveJournal external | |
Usage: diskutil verifyVolume MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil repairVolume MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil verifyDisk MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil repairDisk MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil verifyPermissions [-plist] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil repairPermissions [-plist] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil resetUserPermissions MountPoint|DiskIdentifier|DeviceNode UID | |
Usage: diskutil listUsers MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil info[rmation] [-plist] | |
Usage: diskutil list [-plist] [MountPoint|DiskIdentifier|DeviceNode] | |
Usage: diskutil listFilesystems [-plist] | |
Usage: diskutil activity | |
Usage: diskutil mount [readOnly] [-mountPoint Path] DiskIdentifier|DeviceNode | |
Usage: diskutil mountDisk DiskIdentifier|DeviceNode | |
Usage: diskutil u[n]mount [force] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil u[n]mountDisk [force] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil eject MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil rename[Volume] MountPoint|DiskIdentifier|DeviceNode newName | |
Usage: diskutil enableOwnership MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil disableOwnership MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil eraseDisk format name [[APM]Format|[MBR]Format|[GPT]Format] | |
Usage: diskutil eraseVolume format name MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil reformat MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil eraseOptical [quick] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil zeroDisk MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil randomDisk [times] MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil secureErase [freespace] level MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil partitionDisk MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil mergePartitions [force] format name | |
Usage: diskutil splitPartition MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil resizeVolume MountPoint|DiskIdentifier|DeviceNode size | |
Usage: diskutil appleRAID create mirror|stripe|concat setName | |
Usage: diskutil appleRAID delete | |
Usage: diskutil appleRAID list [RAIDSetUUID] | |
Usage: diskutil appleRAID enable mirror|concat MountPoint|DiskIdentifier|DeviceNode | |
Usage: diskutil appleRAID repairMirror | |
Usage: diskutil appleRAID update key value | |
Usage: diskutil appleRAID add member|spare | |
Usage: diskutil appleRAID remove MemberDeviceName|MemberUUID | |
CoreStorage Command Overview | |
The diskutil command is the core command line interface for CoreStorage, along with regular disk partitioning, AppleRAID, and other disk activities. | |
All CoreStorage functions use the “coreStorage” adverb, which can be abbreviated “cs”. For example, to show status of all CoreStorage volumes, one may type either: | |
diskutil coreStorage list | |
or | |
diskutil cs list | |
Typing just “diskutil cs” will show a list of nine supported “verbs”, but there are six other undocumented commands as well. Perhaps these are not fully functional (though all worked fine in my testing), or perhaps Apple simply wasn’t ready to expose them for end users to use. | |
I have grouped all 15 CoreStorage verbs by functional area, and note here which are officially listed and which are undocumented. | |
Informational Commands | |
list – Show all CoreStorage volumes | |
info[rmation] – Get detailed information about a physical volume | |
Conversion Commands | |
convert – Convert a volume into a CoreStorage volume | |
revert – Revert a CoreStorage volume to its native type | |
Logical Volume Group Commands | |
create – Create a new CoreStorage logical volume group | |
delete – Delete a CoreStorage logical volume group | |
Physical Volume (Disk) Commands | |
resizeDisk (undocumented) – Resize a physical volume | |
removeDisk (undocumented) – Remove a physical volume from a logical volume group | |
addDisk (undocumented) - Add a new physical volume to a logical volume group | |
Logical Volume Commands | |
createVolume – Create a new logical volume | |
unlockVolume – Mount an existing encrypted logical volume | |
changeVolumePassphrase – Change the encryption password for a logical volume | |
deleteVolume (undocumented) – Delete a logical volume and all of its contents | |
resizeVolume (undocumented) – Grow or shrink a logical volume (non-destructive) | |
resizeStack (undocumented) – Grow or shrink a logical volume as well as the logical volume group and physical volume that supports it | |
CoreStorage Informational Commands | |
Two commands are for information about volumes and disks. Note that these only return information about CoreStorage volumes: Use the bare “diskutil list” and “diskutil info” commands for non-encapsulated storage. | |
list | |
Usage: diskutil coreStorage list | |
diskutil coreStorage list -plist | |
diskutil coreStorage list UUID | |
List all current CoreStorage objects in a tree-like view. | |
info[rmation] | |
The verbs “info” or “information” get CoreStorage information by UUID. | |
CoreStorage Conversion Commands | |
These commands are used to convert a drive or volume to or from CoreStorage. | |
convert | |
Usage: diskutil coreStorage convert | |
MountPoint|DiskIdentifier|DeviceNode | |
[-stdinpassphrase | -passphrase [passphrase]] | |
Convert a regular JHFS+ partition into a CoreStorage logical volume. | |
The file system must be mounted and resizable (i.e. Journaled HFS+). | |
Ownership of the affected disk is required. | |
Note that CoreStorage only functions on drives that meet the following criteria: | |
Partition type is GPT | |
Filesystem type is Journaled HFS+ (JHFS+) | |
Conversion from the command line is non-destructive (unlike using Disk Utility) and is the one shot you have to encrypt a volume. If you convert it without the passphrase, it will be placed in a LVF with no encryption and there is no command to encrypt it later! | |
revert | |
Usage: diskutil coreStorage revert | |
MountPoint|DiskIdentifier|DeviceNode|lvUUID | |
[-stdinpassphrase | -passphrase [passphrase] | -recoverykeychain file] | |
Convert a CoreStorage logical volume back to its native type. | |
The file system must be mounted and resizable (i.e. Journaled HFS+). | |
Ownership of the affected disk and a passphrase (if encrypted) is required. | |
Reverting a CoreStorage volume completely returns it to its original state, including restoring the partition type and removing encryption. And it’s non-destructive. Slick! | |
CoreStorage Logical Volume Group Commands | |
These commands manipulate logical volume groups (LVGs) that have previously been created. Most use the “LVG Name”, which you can discover using the “diskutil cs list” command. | |
create | |
Usage: diskutil coreStorage create lvgName | |
MountPoint|DiskIdentifier|DeviceNode ... | |
Create a CoreStorage logical volume group from one more more disks. | |
The specified disks will become the initial set of PVs. | |
All existing data on the drive will be lost. | |
Ownership of the affected disk is required. | |
Example: diskutil coreStorage create MyLVG disk1 | |
Note that this command is destructive. Say goodbye to your data or use the “cs convert” command! It automatically creates a PV for you. | |
delete | |
Usage: diskutil coreStorage delete lvgUUID | |
Delete a CoreStorage logical volume group. All logical volumes will be removed. | |
Ownership of the affected disk is required. | |
This is destructive as well. Your volume will be returned to a usable state, but your data will be lost. Use “convert” and “revert” instead if possible! | |
CoreStorage Physical Volume (Disk) Commands | |
All physical volume commands are undocumented in Lion 10.7. Proceed with caution! But these are pretty cool, since they allow a LVG to span multiple physical disks! | |
PV commands use the word, “Disk”, which tells you a lot about what they are and what they do. | |
Note that the “pvUUID” and “lvgUUID” can be discovered in “diskutil cs list” and refer to the PV and LVG, respectively. | |
resizeDisk (undocumented) | |
Usage: diskutil coreStorage resizeDisk pvUUID size | |
[part1Format part1Name part1Size part2Format part2Name part2Size | |
part3Format part3Name part3Size ...] | |
Resize a physical volume, which is one of one or more disks that provide storage | |
to a logical volume group. The logical volume group will have less or more | |
available space after this operation, if it was a shrink or grow, respectively. | |
If this is a shrink operation, you can optionally request that new partitions | |
be created in the newly-formed free space gap. | |
Example: diskutil coreStorage resizeDisk | |
11111111-2222-3333-4444-555555555555 10g JHFS+ New 1g | |
This crazy-complicated command allows you to resize (both grow and shrink) active partitions non-destructively. | |
removeDisk (undocumented) | |
Usage: diskutil coreStorage removeDisk pvUUID | |
Remove a physical volume from its CoreStorage logical volume group. | |
Ownership of the affected disks is required. | |
Example: diskutil coreStorage removeDisk 11111111-2222-3333-4444-555555555555 | |
It is unknown what will happen if a used PV is removed from an LVG. Using a combination of addDisk and removeDisk should non-destructively move data from one physical disk to another, but I couldn’t get any of this to work. | |
addDisk (undocumented) | |
Usage: diskutil coreStorage addDisk lvgUUID NewMemberDeviceName | |
Add a new physical volume to a CoreStorage logical volume group. | |
Ownership of the affected disks is required. | |
Example: diskutil coreStorage addDisk | |
11111111-2222-3333-4444-555555555555 disk4 | |
This should add additional physical capacity to an existing LVG, but I couldn’t get it to work. It always came back with “Error adding disk to CoreStorage Logical Volume Group: Invalid request (-69886)” | |
CoreStorage Logical Volume Commands | |
The logical volume commands are much more functional and friendly. Right now, the only way to really use these is to create a larger-than-needed LV and then shrink it and use the resulting space for new volumes, since you cannot yet fully create a LVG from scratch. | |
createVolume | |
This creates a new LV (and LVF) within an existing LVG, using space cleared by a previous resizeVolume or deleteVolume command. It appears to always create a new LVF rather than placing an LV within an existing one. And there are no LVF manipulation commands right now. | |
Usage: diskutil coreStorage createVolume lvgUUID type name size | |
[-stdinpassphrase | -passphrase [passphrase]] | |
Add a new logical volume to a CoreStorage logical volume group. | |
Type is the file system to initialize on the new logical volume. Valid types | |
are Journaled HFS+ or Case-sensitive Journaled HFS+ or their aliases. | |
Size is the amount of space to allocate from the parent logical volume group. | |
Valid sizes are floating-point numbers with a suffix of B(ytes), S(512-byte- | |
blocks), K(ilobytes), M(egabytes), G(igabytes), T(erabytes), P(etabytes), | |
or (%) a percentage of the current size of the logical volume group. | |
Example: diskutil coreStorage createVolume | |
11111111-2222-3333-4444-555555555555 jhfs+ myLV 10g | |
unlockVolume | |
One of the seemingly-handier commands that isn’t really all that useful. It’s rare that you’ll want to do this alone. Use hdiutil to mount a volume instead. | |
Usage: diskutil coreStorage unlockVolume lvUUID | |
[-stdinpassphrase | -passphrase passphrase | -recoverykeychain file] | |
Unlock a logical volume that is encrypted and currently locked. You must | |
specify the logical volume by its CoreStorage UUID, because if it is locked | |
it is not online. A passphrase is mandatory: you must either supply it | |
interactively or with one of the above parameters. | |
Example: diskutil coreStorage unlockVolume 11111111-2222-3333-4444-555555555555 | |
changeVolumePassphrase | |
A very handy command allowing you to change the passphrase of an existing VileVault 2 encrypted volume. This is probably the one verb that will be somewhat frequently used by the average user! | |
Usage: diskutil coreStorage changeVolumePassphrase|passwd lvUUID | |
[-recoverykeychain file] | [-oldpassphrase old] | |
[-newpassphrase new] | [-stdinpassphrase] | |
Change an encrypted logical volume's password. Beyond the CoreStorage UUID, | |
you will be prompted interactively for parameters that you do not specify. | |
Parameters must be given in the above order. | |
Example: diskutil coreStorage changeVolumePassphrase | |
11111111-2222-3333-4444-555555555555 | |
resizeVolume (undocumented) | |
This appears to work fine. You can resize a volume (given its UUID) using this command, and you won’t even lose your data! | |
Usage: diskutil coreStorage resizeVolume lvUUID size | |
Resize a logical volume, which is one of one or more disks that consume storage | |
out of a logical volume group. The logical volume group will have more or less | |
available space after this operation, if it was a shrink or grow, respectively. | |
Example: diskutil coreStorage resizeVolume | |
11111111-2222-3333-4444-555555555555 10g | |
deleteVolume (undocumented) | |
This also works fine. Create a volume and you can delete it, as long as you get the right UUID from “diskutil cs list”. | |
Usage: diskutil coreStorage deleteVolume lvUUID | |
Delete a logical volume. | |
Example: diskutil coreStorage deleteVolume 11111111-2222-3333-4444-555555555555 | |
resizeStack (undocumented) | |
Probably the coolest undocumented command, resizeStack takes a complete 1:1:1:1 CoreStorage stack (PV:LVG:LVF:LV) and resizes everything non-destructively. You’re left with a fully-operational but smaller volume and partition. Nifty! | |
Usage: diskutil coreStorage resizeStack lvUUID size | |
[part1Format part1Name part1Size part2Format part2Name part2Size | |
part3Format part3Name part3Size ...] | |
Resize both a logical volume and its underlying physical volume in a single | |
operation. The setup must be simple: Exactly one logical volume and one | |
related physical volume can, and must, exist. | |
If this is a shrink operation, you can optionally request that new partitions | |
be created in the newly-formed free space gap. | |
Example: diskutil coreStorage resizeStack | |
11111111-2222-3333-4444-555555555555 10g JHFS+ New 1g | |
What’s Missing | |
These undocumented CoreStorage commands are eye-opening, since it shows that Apple really is working on a complete full-featured volume manager. But lots of functionality is lacking still: | |
You can’t create a logical volume group (LVG) by hand, adding multiple disks. It seems like you could, but not enough works yet. | |
There are no commands for manipulating logical volume families (LVFs), and they can’t even be specified when creating new logical volumes (LVs). | |
The physical volume (PV or disk) commands don’t seem to work. I guess that’s why they’re undocumented! | |
There are no advanced data protection features (mirror, snapshot, RAID, replicate) | |
There is no ability to specify where or how an LV is created or to move an LV from one LVF, PV, or LVG to another. | |
All in all, this is a wonderful start for Apple, showing solid core technology that isn’t yet fleshed out enough to be useful. | |
Stephen’s Stance | |
Clearly, CoreStorage is much more than a simple stack to support FileVault 2 encryption. Apple no only built an entire volume manager but also outfitted it with a good set of commands for configuration. Too bad it still lacks so many key features, and that so many of these are unofficial and hidden. | |
I feel confident that Mac OS X CoreStorage will become much more functional in the future, with complete volume manipulation and migration tools built into the GUI. For now, though, I must remind readers that this is all unofficial and you must proceed with caution. Back up your data, and do not assume that just because cool commands like resizeStack exist they are 100% ready for use! | |
Note: The pre-formatted text above comes straight from the diskutil command and its “help” responses. I discovered these undocumented verbs through trial and error and the judicial use of the “strings” command! | |
You might also want to read these other posts... | |
Mac OS X Lion Adds CoreStorage, a Volume Manager (Finally!) | |
Linux Logical Volume Manager Walkthrough | |
Volume Management: Virtualizing Host Storage | |
Three Key Storage Features Missing in Mac OS X “Lion” | |
Guides | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment