Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Possibly format a troublesome USB drive via Terminal Storage Devices
I recently needed to format a USB hard drive to get rid of multiple partitions. Disk Utility kept crashing without finishing up its job, leaving me with an unusable disk. Multiple attempts in Disk Utility failed. To make a long story short, I'm cheap and didn't want to shell out for more software, so I tried diskutil in Terminal:
diskutil eraseDisk HFS+ newdisk disk1
Where diskutil is the program being run, eraseDisk is the operand, HFS+ is the format of the new disk, newdisk is the name of the new disk, and disk1 is the mount point for the disk to be formatted. You can easily find the mount point in Disk Utility by Control-clicking on the offending disk and picking Information from the pop-up menu, then looking at the Disk Identifier entry.

Somewhat surprisingly, diskutil worked for me where Disk Utility failed, so perhaps it will help you out with a similar troublesome disk.
    •    
  • Currently 4.12 / 5
  You rated: 3 / 5 (17 votes cast)
 
[101,122 views]  

Possibly format a troublesome USB drive via Terminal | 8 comments | Create New Account
Click here to return to the 'Possibly format a troublesome USB drive via Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Possibly format a troublesome USB drive via Terminal
Authored by: Coumerelli on Mar 08, '07 08:11:19AM

THIS is the sort of hint that keeps me coming to MacOSX Hints.com each and every day. Bravo! :D

---
"The best way to accelerate a PC is 9.8 m/s2"



[ Reply to This | # ]
Possibly format a troublesome USB drive via Terminal
Authored by: nmerriam on Mar 08, '07 08:20:19AM

I confess I've had a real hassle getting some USB drives formatted back to Apple Partition Format after they've been used on a Windows system and partitioned with fdisk. Disk Utility would hang, diskutil would hang, and pdisk would report success at manually editing the partition table to APF but I could never actually create HFS partitions with it or Disk Utility.

Sadly enough, I hooked up the drives to my windows system and Macdrive partitioned and formatted the drives as APF/HFS+ perfectly in 15 seconds.

I should note that these exact drives in these enclosures were initially used on this same G5 system formatted as HFS+ for the first year i had them, then used on a Windows system as NTFS for a year, so it isn't a matter of the USB enclosure not working on the Mac. They've been scanned from front to back with Diskwarrior, Drive Genius, etc and several terabytes have gone back and forth on them with no errors.



[ Reply to This | # ]
Possibly format a troublesome USB drive via Terminal
Authored by: boredzo on Mar 08, '07 12:38:11PM

disk1 is the mount point for the disk to be formatted.

Incorrect. disk1 is the special device, not the mount point. The existence of a mount point would prove that the device is mounted, in which case it cannot be formatted (that would be Very Bad for anything that was using something on the mounted volume, so the OS won't allow it).

Mount points, in OS X, are usually in /Volumes, and are named after the volume. Special devices are in /dev and are named sequentially (disk1, disk2, disk3).



[ Reply to This | # ]
Possibly format a troublesome USB drive via Terminal
Authored by: cjcj01 on Jun 08, '09 01:20:40AM

Out of interest, if you're formatting in HFS+ on a USB drive on an Intel Mac, and you don't want to boot from the USB drive, you'll want to change the partition map to AFP not GUID. This saves you around 200Mb of space on an 8Gb usb flash drive.

e.g. on my 8Gb Flash drive:
It's 7.5 GB when viewed in Disk Utility. But when I format it with GUID only 7.2Gb is available. When it's formatted AFP I get 7.4Gb.



[ Reply to This | # ]
Possibly format a troublesome USB drive via Terminal
Authored by: amirz on Dec 31, '10 09:43:39PM

worked perfectly!

thanks!



[ Reply to This | # ]
Possibly format a troublesome USB drive via Terminal
Authored by: WRXSTER on Jun 25, '11 02:54:27PM

LIFESAVER !!!

Disk Utility was crashing, DVD drive conked out, so couldn't use SnowLeopard DVD to fix Disk Utility. Win Vista only formats in NTFS / extFAT. Was in between a rock and a hard place.

Thanks bud!



[ Reply to This | # ]
Possibly format a troublesome USB drive via Terminal
Authored by: Issask on Dec 07, '12 02:39:02PM

I tried the command and got this error msg
Started erase on disk6
Unmounting disk
Error: -69877: Couldn't open device
I have a Verbatim 8GB drive that stopped working and have been trying to format it on Mac and windows with both telling me I don't have permission to write
I don't care much about the Data in the drive so all I wan to do is to force format it



[ Reply to This | # ]
Possibly format a troublesome USB drive via Terminal
Authored by: cklegan on Dec 08, '12 10:14:32AM

My system could NOT unmount the drive, even when booting with Apple-R, etc., and command-line eraseDisk also failed.

Reason is something is accessing the drive. Using Terminal.app, fix it as follows (need to be Administrator type User for superuser/sudo privs):

at command line enter: ps aux | grep fsck

root 597 12.8 12.7 2965496 533992 ?? U 11:50AM 5:41.00 /System/Library/Filesystems/hfs.fs/Contents/Resources/../../../../../../sbin/fsck_hfs -y /dev/disk1s2

** kill that process

at command line enter: sudo kill -9 597 (enter password)

** proceed to reformat using DiskUtility



[ Reply to This | # ]