diskutil eraseDisk results in Error: 12: POSIX reports: Cannot allocate memory I'm trying to format my usb drive that is partitioned with FAT32 by the following command in Terminal:

$ diskutil eraseDisk JHFS+ UntitledUFS disk1


However, I get this output: 

Started erase on disk1
Unmounting disk
Error: 12: POSIX reports: Cannot allocate memory
It could be likely that you are not running the command as admin (Unix root) user.

To run a command with administrator privileges use the sudo command so:

$ sudo diskutil eraseDisk JHFS+ UntitledUFS disk1


The error message can lead one astray giving the impression that something else is wrong but it is likely a permissions issue.