Unable to format pendrive, diskutil error

When I insert my USB Pendrive in my iMac i see this message: enter image description here

I tried to format it both with DiskUtility and with diskutil command in terminal but I get this error:

iMac:~ User$ diskutil eraseVolume HFS+ PenDrive disk2
Started erase on disk2
Unmounting disk
Erasing
newfs_hfs: WriteBuffer:  pwrite(3, 0x108551000, 131072, 0): Device not configured
newfs_hfs: write (sector 0): Invalid argument
Mounting disk
Could not mount disk2 with name (null) after erase
Error: -69832: File system formatter failed

How can I solve it?


Click on "Initialize..."

or if the useer your login with can adminastrat the computer then try adding "sudo " and entering your password when prompted.

So:

sudo diskutil eraseVolume HFS+ PenDrive disk2

You could try booting into any free Linux livecd with Gparted on it, or this one called Parted Magic which is designed for disk maintenance tasks like this. (it costs a tiny $5 though.)

Do note that you may not be able to format as HFS+ using linux, however if you choose a compatible file system like FAT32 you'd be able to read/write to the drive in most OS's.