Macos – How to force format read only usb drive in OSx El Capitan

hard drivemacosusb

I have a crashed laptop and used the following method to make a bootable usb drive (32 GB).

hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/ubuntu.iso

diskutil unmountDisk /dev/diskN

sudo dd if=/path/to/downloaded.img of=/dev/rdiskN bs=1m

It did work and made a read only usb that acted as if it were a CD. I would like to now undo that (in OSx) but disk utility doesn't seem to be able to. When I click "Erase" it simply fails with

"Erase process has failed" 

And details reveal

Name invalid.
Operation failed...

Is there a way I can force format this USB drive (to either FAT 32 or OSX Extended) in OSx El Capitan?

Best Answer

Solved.

sudo diskutil unmountdisk force disk2

sudo dd if=/dev/zero of=/dev/disk2 bs=1024 count=1024
Related Question