How to fix deep formatting problems with OS X drives

DiskUtilityIconXEven though formatting advances like Journaling in Apple’s filesystem formats help prevent data corruption, problems can still happen that result in a drive not only being unreadable, but also unable to be reformatted.

If this happens, the drive may show up in the Finder sidebar but not show data when clicked, or it may just not show up but be present in Disk Utility; however, if you try to mount it you get a “resource busy” error. Another possible symptom is if you get this error or one claiming the drive cannot be unmounted, when trying to format the drive or running a fix routine on it with Disk Utility.

These errors and behaviors might indicate to you that your drive is malfunctioning and you need a new one; however, before you give up on a $100+ drive, ensure the problem is not simply a very low-level formatting snag that causes the drive to hang when accessed. This is especially true if you do not hear any tell-tale signs of physical failure, such as repeated click, tap, and whirr sounds coming from the drive at regular intervals.

Assuming the drive is just experiencing major low-level corruption, the problem you face now is how to format a drive that apparently cannot be formatted on your Mac? One option is to use another operating system like Windows in Boot Camp, in a Virtual Machine, or on a dedicated PC to manage the drive and attempt to repartition it; however, this may not be feasible in some situations.

Another option that should work in most cases is to use the Terminal to interact with special device files to force an overwrite of the device file representing the drive.

OS X Device files

Device file list in OS X

The /dev folder has a number of different device files that are assigned to system components and peripherals, allowing programs to interact with them using system calls. These devices include disks, consoles, terminals, and standard input and output, among others (click for larger view).

Device files in OS X are a collection of drivers in the hidden “/dev” directory that are assigned to devices, allowing them to be accessed by system calls (open, read, write, close, etc.). These allow programs to interact directly with the device, so for instance you can use a filesystem manager like the “diskutil” command to get information on, or fix a device.

For local storage drives, your boot drive is the first enumerated disk device, so it will be assigned the device file /dev/disk0, and you can get information on it in the Terminal by running the following “diskutil” command:

diskutil info /dev/disk1

In Unix-based systems like OS X, often there are some special device drivers, such as /dev/null, or /dev/random, which instead of providing access to system devices, offer unique services. For /dev/null, this device acts like an instant trash can for any information sent to it, and is useful for scripting and programming. When /dev/random is accessed and read, it will output random data. You can see this by running the following command in the terminal to read through the “random” device file (be ready to press Control-C to stop the torrent of characters that will be output from this command):

cat /dev/random

Fixing your drive

If you have a local storage drive that is malfunctioning, and especially because of a low-level formatting issue, then you can use the random number generator device to force overwriting of the hard disk. This will destroy any partitioning schemes and current formatting, and make the drive appear to the system as a blank storage device. With this effort, the hope is to bypass the corrupted drive logic that is causing the system to hang up when accessing it, but since the drive is captured by the system and held in a “busy” state whenever attached, doing this may require using Terminal commands in special timing:

  1. Open the Terminal utility (Applications > Utilities) and enter “root” mode by running the following command (supply your password when prompted—it will not be shown):
    sudo su
  2. Run the following command to get a list of drives and their corresponding device files:
    diskutil list
  3. Peruse the output of this command and identify the drive by partition name and size, and then note the device file assigned to it (see “A” in the screenshot to the left).
  4. Force-overwriting a drive in OS X

    Running “diskutil list” (A) will show the drives and corresponding partitions. Use the located device file (arrows) repeatedly in the command to overwrite the disk (B) after you have attached it to the system (click image for larger view).

    Run the following command to attempt to overwrite the contents of the device file (which is the contents of the disk). Note that when this command runs successfully, the cursor will drop to an empty line and wait, instead of returning to the command prompt. During this time, the command will be writing to the disk, so you can wait a few moments and then press Control-C to halt the command. While the device “disk1” is used in this example, be sure to replace it with the device you found in step 2 above:

    cat /dev/random > /dev/disk1

It is likely that this command will initially result in an error claiming the disk resource is busy; however, this does not mean the command won’t work. Instead, it just means you ran the command after the system captured the device and got stuck trying to manage it. If you see this error, then do the following:

  1. Press the Up arrow key in the Terminal to load and prepare the previously entered command.
  2. Unplug your drive and plug it back in.
  3. Immediately press Enter, and if you see the same error, then press the Up arrow key again followed by Enter again.
Blank drive in disktuil

After the command has run for a few moments, if you cancel and then re-run “diskutil list” you will see the drive listed with no partitions on it, indicating it has been wiped (click for larger view).

Repeat step 3 as fast as you can, until the Terminal cursor drops to a new line without returning to the command prompt (see “B” in the screenshot above). This will indicate the command has captured the device before the system, and is now overwriting it.

Allow the command to continue for a minute or two before pressing Control-C to cancel it. At this point you can open the Disk Utility program and you should see your drive with no storage volumes available. You can then partition and format the drive to prepare it for use in OS X.

99 thoughts on “How to fix deep formatting problems with OS X drives

  1. MaX

    This is what I get for a pendrive:

    /dev/disk4
    #: TYPE NAME SIZE IDENTIFIER
    0: GUID_partition_scheme *32.7 GB disk4
    1: EFI EFI 209.7 MB disk4s1
    2: Apple_HFS LaCieXtremKeyUSB3GUI… 32.4 GB disk4s2
    sh-3.2# cat /dev/random > /dev/disk4
    sh: /dev/disk4: Resource busy
    sh-3.2# cat /dev/random > /dev/disk4
    sh: /dev/disk4: Operation not supported
    sh-3.2# cat /dev/random > /dev/disk4
    sh: /dev/disk4: Operation not supported
    sh-3.2# cat /dev/random > /dev/disk4
    sh: /dev/disk4: Operation not supported
    sh-3.2#

    To cut a long story short, the pendrive is 
LaCie XtremKey USB 3.0
http://www.lacie.com/us/products/product.htm?id=10612

    It broke when automatically unmounted while copying a VMware Fusion disk image.
    Since I cannot repair it (Disk Utility, DiskWarrior, TechTool Pro, DiskTools Pro & SpeedTools Utilities Pro, and Drive Genius on Mac with OS X 10.9.2 Mavericks), I just want to format it, yet I cannot with any tool tested so far.

    Any idea how to repair or format it?
    
Thanks.

    1. Topher Kessler Post author

      Repeating the “cat /dev/random > /dev/disk4” command at the root prompt will require timing. When it says “Operation not supported,” it means the disk4 device file is not yet assigned to the device. If it says “Resource Busy” then it means the device has been assigned but has been captured by other processes and cannot be handled by system calls.

      Try again, repeating the “cat /dev/random > /dev/disk4” command rapidly by pressing the up arrow, followed by Enter, to capture the disk between the time it is assigned the device to where other processes take it over. It may take a few attempts but it should be doable.

      Alternatively, you can try placing the command in a looping script and then run the script as root, to apply the command as fast as possible:

      1. Open the Terminal and run this command:

      pico formatdrive.sh

      2. Copy and paste the following into the editor that appears:

      #!/bin/bash
      while [ 1 ]; do
      cat /dev/random > /dev/disk4
      done

      3. Press Control-O to save, followed by Control-X to exit.

      4. Run the following command to make the script executable:

      chmod 777 formatdrive.sh

      5. Now switch to root in the Terminal

      sudo su

      6. And finally run the script, immediately followed by attaching your drive to the Mac:

      ./formatdrive.sh

      When you do this, the script will run rapidly and output many “not permitted” or “permission denied” errors, but should halt on one when the drive is mounted. When this happens, wait a few moments as mentioned in the article, and then close the Terminal, confirming to cancel running processes. If you simply press Control-C will cancel the command but the script will start it right up again.

      When this is done, you can then try using Disk Utility to partition and format the disk for use again.

      1. MaX

        Many thanks Topher for your comprehensive reply. I have done as you indicate:

        – The “Press Control-O to save” (step 3) did not save the formatdrive.sh file. I had to press the carriage return and then it was saved at “Macintosh HD/Users/~” and the Terminal nano showed [ Wrote 4 lines ].

        – At step 6, I got the following:

        Last login: Mon Apr 7 13:56:43 on ttys001
        [MacOSX-X:~] me% chmod 777 formatdrive.sh
        [MacOSX-X:~] me% sudo su
        Password:
        sh-3.2# ./formatdrive.sh
        ./formatdrive.sh: line 3: /dev/disk4: Operation not supported

        With hundreds of such last line in a row (several each second!). After about 15 minutes waiting, I unplugged and plugged back the pendrive. Then Terminal stopped not showing mure of such last line (no other message shown).

        Then I closed the Terminal window selecting “Shell – Close Window”, and opened Disk Utility, selected the drive on the left and clicked the Partition tab. I named it as LaCie, and selected 1 Partition – Mac OS Extended (Journaled). Options as GUID Partition Table. After clicking Apply, I got:

        Partition failed
        Partition failed with the error:
        Couldn’t unmount disk.

        When I tried again, I got:

        Partition failed
        Partition failed with the error:
        Disk object invalid or unable to serialize.

        An then such last error message for all consecutive trials. I got the same last error when afterwards selecting Options as Apple Partition Map, as well as Master Boot Record.

        What could I do next?
        Thanks again for your great help!

        1. Topher Kessler Post author

          This command should overwrite the partition table, but if the drive is working then the system should be able to recognize it as blank media and write another partition table to it. My guess is if wiping the drive like this does not work, then it is likely the drive is beyond repair. However, before giving up, run “diskutil list” and see if there are any partitions listed for the faulty drive (there shouldnt be if the above process was run correctly).

          1. Rima

            how much time should i wait before pressing ctrl C(or close the terminal)? the message is always permission denied, I waited for 1mn, 5mn, 10mn, 15mn

      2. Iván Martiñón

        Funcionó perfecto, desde recovery no hay pico así que corrí el while directamente en la terminal y funcionó perfectamente. Gracias!!!

  2. MaX

    This is what I get (Mac mini with 1TB Fusion Drive):

    Last login: Tue Apr 8 12:42:54 on console
    [MacOSX-X:~] me% sudo su
    Password:
    sh-3.2# diskutil list
    …/…
    /dev/disk4
    #: TYPE NAME SIZE IDENTIFIER
    0: GUID_partition_scheme *32.7 GB disk4
    1: EFI EFI 209.7 MB disk4s1
    2: Apple_HFS LaCieXtremKeyUSB3GUI… 32.4 GB disk4s2
    sh-3.2#

    The disk4 is the drive (pendrive). Before doing what you explained in the article, Disk Utility showed a single volume (partition) inside the drive. After doing what you said, Disk Utility shows no volumes inside. Yet, I cannot partition the drive. This is what I get when I try to partition it with Disk Utility:

    Partition failed

    Partition failed with the error:
    
Couldn’t unmount disk.

    And when I try to partition again:

    Partition failed

    Partition failed with the error:
    
Couldn’t open device.

    And then (in all subsequent trials):

    Partition failed
    
Partition failed with the error:

    Disk object invalid or unable to serialize.

    Could it be possible to partition/format/erase such pendrive? Thanks again.

    1. Topher Kessler Post author

      I’m still leaning towards this drive having some hardware fault, but you can try the above procedure again, but this time wait a very long time for the “cat /dev/random > /dev/disk4” command to run before canceling it. This will ensure more of the drive is overwritten by the command, and possibly allow you to recover it.

      1. MaX

        Thanks for your help. I have done as you said. Terminal was indicating hundreds of the following lines in a row (several per second):

        ./formatdrive.sh: line 3: /dev/disk4: Operation not supported

        And Menu Meters
        http://www.ragingmenace.com/software/menumeters
        showed high CPU activity (the Mac mini fan could be heard also). If then I unplugged and plugged back the pendrive, it stopped showing such message line (and the CPU activity was down and no fan heard). But after eight minutes, it started again. I did that several times.

        I also left such activity running for about four hours (doing nothing else on the Mac). Eventually the Mac rebooted itself (!). I got the message:

        Your computer was restarted because of a problem.

        Now the pendrive shows both the drive and the single volume inside on the left pane of Disk Utility, as did before doing what is indicated in your article above.

        If I run Disk Utility repair for the drive, I get:

        Alert
        Some information was unavailable during an internal lookup.
        Verifying and repairing partition map for “LaCie XtremKey Media”Checking prerequisites
        Problems were encountered during repair of the partition map
        Error: Some information was unavailable during an internal lookup.

        If I try to partition the drive, the Apply button is grayed, so I cannot do it (before today it was possible, as described above).

        Any possibility to format this pendrive. I am lost.

        Thanks again for your kind help!

        1. Lloyd

          I also use a 1 TB hybrid drive from Seagate in a MacMini, two LaCie external enclosures and a Pro Book. When trying to use Apple’s Disk Util for adjusting partitions or reformatting, I would end up with a greyed selection or what appeared empty space that could not be recovered. (Using 10.6.x.)

          To look back a bit, I was a fan of LaCie’s SilverLining and used it until OS 10. Much information, along with graphic illustrations of all the partitions on a drive. When I was finally stuck with Apple and 10.6, I looked around and found a program named iPartition. Gives all of the infor SilverLining did, and better control over partitioning. You cannot use it on the same drive you are trying to partition or change partition sizes, attempt to activate, etc., but I assume you are using an external drive you can boot from.

          I’m pretty cautious when it come to running just about any tool on my working, main, drive, but I have never found an issue with this program. Just in case, always back up what you don’t want to lose, but in the few years I have been using it, no problems.

          http://coriolis-systems.com/iPartition/

  3. B. 9776Jefferson Le Blanc

    Before reformatting a drive that is reporting mount errors, try restarting your computer. I get this kind of error on occasion and restarting will render the drive usable again. I surmise that, in this case, the problem is not with the drive but with the system which has somehow become constipated, for lack of a better word. Of course if the drive truly is damaged this will not help. My point is that there can be other, less serious, reasons for a drive to become inaccessible or unresponsive and drastic measures should not be the first resort. I sometimes run into mount errors when I’m in the process of testing or repairing a drive with Disk Utility. In my experience, the process of un-mounting and mounting drives and partitions can actually precipitate mount errors which, as I said, can be resolved with a restart.

    In a situation like MaX has encountered, while trying strenuously to save a pen drive may have intellectual value, or provide an interesting challenge to an experienced troubleshooter, on the whole the time and effort you expend in trying to resurrect the drive may be more than the replacement cost of the drive. Given that the procedure Topher describes effectively erases the drive, there will be no data to be salvaged and thus the value of the data is not part of the equation.

    Of course, with a large hard drive this value equation will be different, and a conscientious effort to salvage the drive may be appropriate. Even here, though, one will eventually reach a point of diminishing returns. It’s also worth mentioning that pen/keychain drives are inherently less reliable than hard drives and optical media. For this reason they should be used only for temporary storage.

    In the case of hard drive problems, the best solution is to regularly back up the data on your drives. This way, if the drive truly is broken, at least your data will be safe. Some really conscientious people keep multiple backups and regularly rotate these from older to newer media. Others use mirrored RAIDS to insure data integrity. These are more expensive solutions and their use will depend on the intrinsic value of the data, the budget available for a backup solution – and one’s inherent paranoia or the impact of one’s experience with drive failure and data loss.

    All that said, I will save this article because it offers a solution beyond what most disk utilities offer. Indeed, I have thought before this that such a solution must be available somewhere; I guess it was only a matter of time before Topher uncovered it. Thanks. There really are some problems for which Terminal is the only solution.

    1. Joe

      I was killing myself over ‘can’t unmount’, ‘can’t read disk’ errors, having no luck with command line operations, and then I read this. Restarted and voila! we have erasure.
      Thanks!

  4. MaX

    Thanks. I have restarted many times to no avail. Actually, I have been trying to first repair and then format this pendrive for about a year now.

    I think it could be possible to format it, flashing it; reloading the drive’s firmware and performing a low-level formatting. But that does not seem to be an easy procedure, depending on the manufacturer, etc. Somebody knows how to do it for the LaCie XtremKey USB3 pendrrive? Thanks.

    1. B. Jefferson Le Blanc

      I checked out those drives on Amazon – I can see why you‘re trying to restore it. They‘re expensive. But all that environmental durability is wasted if the drive itself tends to fail. Have you contacted LaCie about the problem? If anyone knows how to get it working again they should.

      Otherwise, if Topher’s solution doesn’t work, you may have to face the probability that the drive somehow sustained irreparable damage. And, if you replace it, you may want to consider whether you really need such a physically robust keychain drive. You could buy a lot of standard and even security enhanced thumb drives for the price of one of those LaCie XtremKey USB3 pendrrives.

      Sorry I have no better solution to offer.

  5. MaX

    Yes, I have contacted LaCie, and they say that they do have the tool to reload the drive’s firmware, but it is only for internal use within LaCie. So, no joy there.

    1. B. Jefferson Le Blanc

      Given how stingy they are in supporting a product you paid over $150 for, I’d say you should be sure and buy your next flash drive from someone else. And plaster the web with bad reviews describing the one you have and LaCie’s failure to support it. Their parsimonious and short-sighted behavior deserves all the bad news you can spread about them. As the saying goes, don’t get mad, get even.

  6. MaX

    Awesome! I have found it:

    LaCie XtremKey 32 GB
    VID: 059f
    PID: 106c

    But how to flash it? There is no flash utility for LaCie at FlashBoot.

    Topher, an article about this topic would be awesome.

    Thanks.

    1. B. Jefferson Le Blanc

      MaX: If you look up ChipEasy on Google or Bing you’ll find links to some software for flashing drives – for which you’ll need the VID an PID numbers you found. But they are Windows apps – you’ll need access to a Windows PC or a virtual machine in Parallels of VMWare Fusion.

  7. MaX

    This is what I get when trying to connect the pendrive (LaCie XtremKey USB3 GUID 32GB) to Windows XP SP3 on VMware Fusion 6.0.2 on Mac with OS X 10.9.2 (Mavericks):

    The device “LaCie XtremKey USB 3.0” was unable to connect to its ideal host controller.
    An attempt will be made to connect this device to the best available host controller. This might result in undefined behavior for this device.

    Therefore, I cannot use
    ChipGenius_v4_00_0027_pre2
    or
    ChipEasy_EN_V1.5.6.6

    But just for the sake of the information, I have connected another WORKING but older pendrive (LaCie XtremKey USB2 GUID 16GB) to see what I can get:

    1. First, ChipGenius_v4_00_0027_pre2
    from
    http://dl.mydigit.net/2010/09/chipgenius.html
    says:
    Description: [F:]USB Mass Storage Device(LaCie XtremKey)
    Device Type: Mass Storage Device
    Protocal Version: USB 2.00
    Current Speed: High Speed
    Max Current: 2mA
    USB Device ID: VID = 059F PID = 1038
    Serial Number: XXX
    Device Vendor: LaCie
    Device Name: XtremKey
    Device Revision: 0100
    Manufacturer: LaCie
    Product Model: XtremKey
    Product Revision: Dev
    Controller Part-Number: Unknown <——————————————————— NO DATA!!!

    2. On the other hand, ChipEasy_EN_V1.5.6.6
    from
    http://flashboot.ru/files/file/361
    says:
    Logical drive : F:\ Capacity: 14.3G
    Device ID : VID = 059F PID = 1038
    Device SN : XXX
    Device version : Dev
    Device vendor : LaCie
    Device model : XtremKey
    Protocol : USB2.0
    Max power : 2mA
    Partition type : HFSJ Device active : no
    Aligned state : 204820 KB, Have been Aligned
    Controller : <———————————————————————————– NO DATA!!!
    Controller model: <——————————————————————————- NO DATA!!!
    Tools :
    OS Version : Microsoft Windows XP Professional Service Pack 3
    Update Status : The current version is the latest version!

    So, no data is shown for the controller.

    I can see the defective LaCie XtremKey USB3 GUID 32GB with Disk Utility on Mac (showing its volume inside on the left pane) but when I try to Erase it, I get:

    Disk Erase failed
    Disk Erase failed with the error:
    Couldn’t unmount disk.

    If I click the Partition tab, I get the spinning color wheel and
    Option Command esc
    shows that Disk Utility is not responding. After a few minutes, it shows the Partition window, but after selecting the Partition Layout (1 Partition), the Apply button is grayed (and I cannot type inside the Name or Size fields).

    Any idea on how to repair or format this defective pendrive will be most appreciated.
    Thanks!

    1. B. Jefferson Le Blanc

      MaX: I see one other possibility: You might try using those utilities on a newer version of Windows – on an actual Windows PC. First, XP is very old (as operating systems go) and may not support the necessary drivers for your USB device. There’s also the question, using virtualization, whether you have Fusion set to use the Apple drivers or have loaded the Windows drivers and selected them. You can do either one with both VMWare Fusion and Parallels. The default behavior is to use the Apple drivers to access external devices because, in most cases, that is simpler and more transparent. But you can change that setting. If you do, Windows may direct you to download the drivers you need, which means more rooting around on Windows web sites. If you have access to a Windows PC you might get more reliable results with the utilities in question, and it might ultimately be simpler. If you can access the drive on Windows, go ahead and format it Fat 32. If you can formate the drive on Windows, you can then mount it on your Mac and reformat it HFS+ if you like. Though Fat 32 will work OK on a Mac for data storage, as long as you don’t need to install OS X on it. The advantage of using Fat 32 is that the drive will also be usable on a Windows PC, supposing that necessity ever arises. On a side note, most flash drives are formatted Fat 32 because that is sufficient for the smaller sizes flash drives come in. Also, if you could format a flash drive with the newer NTSF format, if would not work on a Mac without additional software.

      1. MaX

        After almost a year, I did it! No way trying to repair the pendrive or format it either on Windows on Fusion (VMware) on Mac, or directly on Windows on a PC.

        The only solution was to flash it on a Windows PC (I used Windows XP SP3). The flashing tool found that it had one bad block (probably the first one, which prevented formatting). After flashing it (which formats it as well), the pendrive works fine. Amazing!

        Surprisingly, the LaCie XtremKey USB3 GUID 32GB previously (before breaking as described above) had a capacity of 32.37 GB (32.26 GB available; LaCie XtremKey media), but after flashing and re-formatting with Apple Disk Utility, it shows a larger capacity of 32.79 GB (32.68 GB available; Innostor Innostor media). So, LaCie flashing takes 42 MB more than the native Innostor (!). No Spotlight Index in all cases.

        Topher, it would be great if you could write an article about it. The procedure involves visiting a Chinese site (to get ChipGenius to reveal the VID, PID and Controller chip part number), and and Russian site to get the flash tool for such specific controller.

        1. B. Jefferson Le Blanc

          While Topher’s expertise is remarkable, it was you who solved the problem through incredible persistence (with a nudge here and their from interested parties). While Topher may be able to reconstruct what you did in a general way, you are the one who knows the nitty-gritty details of the project. May I suggest you write it up yourself and then ask Topher to publish it on MacIssues, if not on the main page, then on the forums as a stand-alone topic. The subject certainly begs condensing from the rambling dialog on this thread. And, if you do write it up, I suggest you include links to the sites from which you downloaded the necessary software – the more direct the link, the better. Not everyone will have your skill at sniffing out items on non-english web sites.

          And finally – congratulations! No doubt the time you spent on this was worth far more than the cost of the drive, but nothing can match the satisfaction of solving such a difficult problem. Keep up the good work.

        2. Tim

          congratulations! I’ve been digging and reading this string of events hunting for clues on my own quest. many many many parallels.. I am very barely grasping and hanging on to much of what you guys are kicking around.. so please bare with me… but yeah, i’ve got a bad block on a 128 gb toshiba ssd, ( which i think may have been caused by the knucklehead who sold it to me rushing to prove it worked and formatting it in front of me and prematurely yanking the cable out. ) but anyway, was trying the whole terminal fix to hopefully write over as described, but wasn’t able to hit that sweet spot, and catch a break..

          so yeah i’m writing this to congratulate on your successful inhuman perserverance against all odds and in the name of principle and refusing to give in… but also for some assistance, in hopefully finding some how some way to flash this drive and be able to resurrect it.. please don’t leave me danglin. cheers and thanks for your time and consideration

  8. Andrei

    Hi,

    I have tried to shrink my external drive in disk utility and the power shut down in the process.
    When I restarted the pc , everything dissapeared. I formated my HDD from hfs to fat. I need to recover all my work. there was my 4 years work and now is gone.
    Can you please give me your advice.

    Thanks a lot.

    1. Topher Kessler Post author

      By reformatting your drive you wiped out the indexes that tell it where files are on the drive. Your only option for recovering your files would be to use a file recovery tool like DiskDrill, or Prosoft Data Rescue, to scan the drive for file structures and try to recover them. This will likely not recover everything, but should be able to get at least something. Be sure to not use your drive before doing this, as using it will overwrite the data on the drive and make it impossible to recover.

      1. B. Jefferson Le Blanc

        This is just one more sad example of data lost because it wasn’t backed up. The first thing Andrei should have done before trying to shrink his drive was back it up. Adjusting a drive’s partition size is a risky procedure at the best of times. Ignoring the possibility that something might go wrong only compounds the problem.

        Of course, not knowing that reformatting a drive would make the data on it inaccessible is serious technical malpractice. The reformat procedure even warns you that your data will be lost. Apparently Andrei didn’t read, or didn’t heed the warning.

        It’s tempting to scoff at such foolishness, but Andrei has already been severely punished for his lack of foresight. Since I, too, have lost data from time to time, I should follow the prescription that people living in glass houses shouldn’t throw stones.

        Be that as it may, the moral of this story is back anything and everything you don’t want or cannot afford to lose. Ignore this warning at your peril.

  9. MaX

    Topher, as I said above, it would be great if you could write an article about it (flashing pendrives). The procedure involves visiting a Chinese site (to get ChipGenius to reveal the VID, PID and Controller chip part number), and and Russian site to get the flash tool for such specific controller.

    Could you do that in the future? Thanks.

  10. Jello

    This worked. Someone flipped a breaker during a restore session and I almost cried when I got the error that my encryption made my drive useless. I used this and was able to remount the restore from time capsule, and I almost cried with joy. Almost. Lol. Thanks so much for this.

  11. Jerry Krinock

    It worked for me. The additional advice from Topher was also helpful. Plug that baby in, then immediately start hitting ‘enter’ followed by up-arrow until you start getting “^[[A” instead of errors.

  12. ali

    i follow the instructions but when i repeat the up key and enter, i got a new error: permission denied.

    what would be the problem in my case?

  13. Mansha

    Thank you so Much! I had pretty much given up when I came across your post. A totally radical solution. Handling the terminal scared me but your instructions were great and my disk is formatted. Thanks again!!!

  14. Ralph

    I followed your instructions which are well documented and very much appreciated.

    As a FYI, the result I got upon trying to run the ./formatdrive.sh batch file due to the operation not supported or device busy situation caused my Mac to crash when the faulty drive came on line.

    OS X Yosemite 10.10.1 (14B25)

    I then checked (after the Mac finally came back from the white screen) to see if DiskUtility could do anything. Same result there. Could not repair or erase the disk. Not sure if the batch file worked or not but it was exciting to see what happened to the Mac. Glad no other damage was done.

  15. xhoenner

    Thanks a lot for that very detailed post, I was about to contact the manufacture (WD, My Passport 2TB).

    I couldn’t get that cat /dev/random > /dev/disk2 to run successfully after unplugging/replugging my hard drive in.

    So what I did was to identify the process that the OS was running using ‘ps aux | grep /dev/disk2’, which gave me:
    root 2505 100.0 12.6 3511284 1053484 ?? R 11:20am 3:15.82 /System/Library/Filesystems/hfs.fs/Contents/Resources/./fsck_hfs -y /dev/disk2s2
    xavierhoenner 2584 0.0 0.0 2432772 640 s002 S+ 11:25am 0:00.00 grep /dev/disk2

    Then I killed this process by ‘sudo kill [process number]’, in my case ‘sudo kill 2505’

    Once that was done, I tried re-running cat /dev/random > /dev/disk2 and it worked beautifully!!

    1. Topher Kessler Post author

      Yes it will. This fix is intended for the drive, and not for the data on it. With this fix you can make use of a drive that otherwise cannot be partitioned and formatted.

  16. Ninad Desai

    Hi ,
    I am getting error “stdout: Input/output error”; I tried it several times …
    its this error or else “Operation not supported”.

  17. Alex

    Hi,

    I am booting my Mac using an external disk. My internal SSD appears as “Virtual Whole Disk” in Disk Utility.
    I get “cat /dev/random > /dev/disk0” to run successfully and the disk appears fine in Disk Utility, but the partitioning using Disk Utility stucks at 50% and if I reboot the computer the disk appears again as “Virtual Whole Disk”. Any advice? Thanks!

    1. Topher Kessler Post author

      You might try leaving the command running for longer, especially if the drive is a relatively large one. You want to ensure all logic is destroyed on the drive, so it can be re-written from scratch, instead of being interpreted by your system.

      1. Alex

        Thanks for advice. The disk is 256 Gb SSD. How long should I leave the command running? I left it all night and got the same result.

  18. Georgina

    Hi, appreciate your post/help here.

    I was setting up a usb Yosemite boot drive but it hanged (upgrading from Snow Leopard to Yosemite). Had issues reformatting the USB to restart the process. Disk utility is stuck at “erase” or “partitioning.”

    I would get the same message:
    sh-3.2# cat /dev/random > /dev/disk1
    sh: /dev/disk1: Operation not supported
    sh-3.2# cat /dev/random > /dev/disk1
    sh: /dev/disk1: Operation not supported

    And a pop up window saying “The disk you inserted was not readable by this computer: Initialize… Ignore or Eject”.

    I’ve restarted my macbook and went through the instructions but I would end up with same issue. I’ve thrown the USB onto a Windows PC and reformatted as a FAT32 first and it works. However, when I want to reformat it using Disk Utility, i’m getting the same issue again.

    Any advice?

  19. MARLON

    Hi! I am having the same message like Cristian.

    “stdout: Input/output error” – I tried Disk Utility but always error message “Unable to write to the last block of the device” please help.

    Thanks for your answer Topher.

  20. Santhosh Paramesh

    Hi Topher,

    I had hard disk errors so i ordered a new one. When I booted using the USB boot drive (Mavericks) and run disk utility to partition it, I am getting “unable to write to the last block of the device” and “Unable to erase or partition” error. I read about your solution above, but wondering if it would work on the internal SATA hard drive. I also tried to create a new partition, but it fails too.

    I tried to cat /dev/random and it keeps scrolling and hangs. Cannot run CTRL-C command.

    Really appreciate your help.

    1. B. Jefferson Le Blanc

      @ Santhosh Paramesh: From your post it isn’t clear if the disk problems you’re having are with the old disk or the new one. If it’s the new one, it could be bad out of the box. What model and vintage Mac are you working with? Since you can boot from a thumb drive, your computer will apparently work from an external drive. To test whether the problem is with the new drive or perhaps the connections on your computer’s motherboard, you would need to test the new drive using an external connection.

      If you don’t have an external drive enclosure in which you can test the new drive, Otherworld Computing has a NewerTech Universal USB 3 Drive Adapter (http://eshop.macsales.com/item/NewerTech/U3NVSPATA/) on sale for $28. I use one from time to time for testing drives. For a little more ($34) you can get a NewerTech Voyager S3 USB 3 “toaster” (http://eshop.macsales.com/item/NewerTech/U3S3HD/) that’s easier to use. The Voyager Q provides more connection options (FireWire 800 | USB 3.0/2.0 | eSATA) but it’s more expensive (http://eshop.macsales.com/item/NewerTech/VU3ESFW8/) at $72.99. If your Mac only has USB 2, you might want to consider the Q for faster FireWire performance. If you are going to end up getting a new computer, the USB 3 model will be sufficient.

      I suggest you need to know whether it’s the new drive that’s faulty or the motherboard on your computer before returning the drive for a replacement. If your computer is failing no replacement drive is likely to work. If that’s the case, you can milk more life out of it by installing your system on an external drive and running it from there. You can use any of the drive adaptors for this, though an external drive (in a case) is probably a better way to go if you intend to continue using the computer for any length of time.

  21. Parshwa

    Hi Topher,

    Thank you for writing this article. I have been using WD My Book Essential (3TB) as time machine. Recently I upgraded to Yosemite. After few successful back-ups, I decided to encrypt back up. Encryption was going on fine, when suddenly on 3rd day, my MCB (mid 2010) started ejecting My Book after few minutes. After this I tried many things and I think I ended up making it worse. Now, when I try to partition my external drive, it sometimes throw:
    POSIX reports: The operation couldn’t be completed. Resource busy (This error came during partition after following the steps )
    or
    Unable to write to the last block of the device.

    I will really appreciate, if you can help me out.

    Best regards

  22. Birdeen

    Thank you! Thank you! Thank you! This has helped keep my mental sanity on numerous occasions with corrupted drives.

  23. ABC

    Dear TK,

    Thank you. It worked perfectly. I could erase the volume and later reformat the HDD.

    But just one question, how do you come up with such ideas?

    If I would not have read your name on this article, I would have stopped hitting
    cat /dev/random > /dev/diskx after the second time.

    Once, more thanks a lot for Macissues.

  24. Micah James

    Hi and good day, im having a similar issue with my pendrive. Its not popping up on my macbook pro desktop, im getting the “initialize, ignore etc” error, but its showing in diskutility. i ran some of the terminals above and got to this point

    Last login: Wed Apr 15 05:33:16 on ttys000
    Micahs-MacBook-Pro:~ MJLive$ sudo su
    Password:
    Sorry, try again.
    Password:
    sh-3.2# cat /dev/random > /dev/disk2
    ^[[A

    where do i go from here ???

    thanks in advance

  25. duongel

    Just wanted to say thank you dude! I was really starting to get frustrated, but your instructions worked 🙂

  26. Brad

    I successfully erased all partitions but when I got to reformat in Disk Utility i get “Partition failed with the error: Couldn’t open device.” info comes up unformatted but the disk is not mounted. I’ll maybe try to mount it in terminal?
    I sure would appreciate any help someone may have. Thank you

    1. B. Jefferson Le Blanc

      Hi Brad. Have you restarted your Mac with the drive connected? Often when the system sees a drive it cannot recognize it will offer to format it. Does Disk Utility recognize the disk? If so, will it mount when you click the Mount button in the toolbar?

      1. Brad

        Thanks. I’ll try the restart. Disk utility does recognize but will not allow mount. I tried to mount it in terminal. It said it mounded but did not show that in diskutil.

    1. Brad

      After doing some research on line I found that the USB flash drive I had purchased was a counterfeit drive. When plugged in it read in disk utility 1TB but would not support the data. It would load the initial folders and the first few would be good, but the rest would be empty.
      Why does disk utility show an incorrect amount of storage and is there a way to ascertain the correct storage other then just dropping data on it?

  27. Larry

    Hi Topher,

    As others have said, thanks for all your guidance and congratulations to those who have used it successfully.

    Unfortunately, in my case, after following all possible avenues covered in the multitude of ideas here, my situation remains that I have an external Seagate HDD, 1TB FreeAgent GoFlex that no longer works. I’ve tried it on three different Mac computers, iMac, MacBook Pro, MacBook Air, as well as one Windows XP notebook.

    The problem started when I tried to erase/reformat (to exFat for dual use with Windows machines) with Disk Utility. That fell over (I don’t recall specifically why). The current situation is thus:

    I plug into a USB port, the activity light comes on, sometimes steady, sometimes flashing to indicate communication with the Mac, until ultimately (up to 10 minutes or more) a msg comes up saying “The disk you inserted was not readable by this computer” and has three options, Initialize, Ignore, Eject. I select Initialize and the DiskUtil left hand pane shows a single line “1 TB Seagate USB 3.0 Cable Media”.

    On the right hand side, First Aid is all grayed out, but Erase is operational. So, I try to erase with the default options, i.e., Mac OS Extended (journaled), Security option fastest. DU shows Unmounting disk for just a little over a minute before a msg comes up saying “Disk Erase failed with the error: Unable to write to the last block of the device.” and the disk is gone from the left hand pane. I close that error msg window and the disc returns to the left hand pane while another msg window comes up with “The disk you inserted was not readable by this computer” and again shows the Initialize, Ignore, Eject options.

    I then go to what seems to be the “Last Resort” on your pages, open Terminal, go to diskutil list, find the disk (disk1), use “cat /dev/random > /dev/disk1”. The results of that initially were “Resource busy”. However, on the last attempt, as I write this post, I now have “cat: stdout: Device not configured”! “diskutil list” still shows the disk as /dev/disk1 and it is still showing in Disk Utility (it never shows up in Finder).

    I guess that gives me another path to investigate but if you have any new advice to offer, I would be very grateful. Thanks.

    1. B. Jefferson Le Blanc

      Larry, rather than trying to erase the drive, reformat it instead. Create a single new partition and make sure Options is set to GUID. Let us know if this works.

      1. Larry

        Hi, Jefferson, this is something I have tried, multiple times. Trying again, this is what happens:

        I connected the USB drive to my MacBook Pro, the activity light came on and, after some seconds, started blinking indicating at least communication with the Mac. After about 5 minutes, it finally showed up in Disk Utility along with a comment window saying “The disk you inserted was not readable by this computer” and had three options – Initialize, Ignore, Eject. When I selected Initialize, that window disappeared, the activity light dimmed a bit, the drive disappeared from the DU left hand pane for quite some time but eventually reappeared ( but still only one line, the name 1 TB SeagateUSB 3.0 Cable Media). I select the drive in that pane, then go to Partition in the right hand pane, choose 1Partition with defaults including Options/GUID Partition Table, select Apply which brings down a window to confirm that I want to take the action. I select Partition, DU starts to “Unmount disk”. Then “Creating the partition map” shows in DU followed almost immediately with a failure msg “Partition failed with the error: POSIX reports: The operation couldn’t be completed. Resource busy”.

        Try then to erase, Mac OS Extended (Journaled) format, with Fastest Security Optiion, I get “Disk Erase Failed with the error: Unable to write to the last block of the device”. With any of the Security zero overwrite functions, the result is “Secure Disk Erase failed with the error: Securely erasing data to prevent recovery failed”.

        It was after trying these options yesterday that I then resorted Topher’s posts and tried all of the possibilities suggested. Nothing worked, hence my request for assistance.

        I know the easiest thing to do is to simply trash the drive but I hate to do that if there is any chance at all of retrieving it. If it were a smaller drive I might relent but 1 TB is too big to not at least try everything possible before admitting defeat (which is something I hate to do).

        Thanks for listening.

        cheers,

        larry

        1. B. Jefferson Le Blanc

          Hi Larry. One more thing to try: Before partitioning the drive, try using Disk Utility to unmount it (not eject). If this works it should solve the disk is busy problem. DU will try to unmount it in any case in order to partition it.

          Another possibility: Boot in recovery mode and see if Disk Utility can handle the drive from there. If DU can see the disk, it will still be unmounted and should not be seen as busy.

          1. Larry

            Hi Jeff,

            Your first suggestion didn’t work so went to the second.

            Using DU in Recovery Mode, in the Left Hand Pane (LHP), in addition to the single line “1TB Seagate USB 3.0 Cable”, below that I can now see a horizontal line followed by two new lines: top line is “Disk1”, lower indented line is “OS X Base System”.

            Selecting the top “Disk 1” line, both the Mount and Eject buttons in the menu bar are grayed out so cannot try either. In the right hand pane (RHP), First Aid has everything grayed out as does the Erase tab while the Partition tab shows the Current partition is “OS X Base System”, formatted HFSJ+ and size 1.25GB and, again, everything is grayed out. Trying to select anything other than Current in the Partition Layout is impossible.

            Selecting the indented lower line and going to the First Aid tab on the RHP shows everything except Verify Disk grayed out. I choose Verify Disk and watch it go thru the steps with the final step showing, in green, “The volume OS X Base System appears to be OK”. Checking the Erase tab shows everything all grayed out. Looking at the details for the OS X Base System at the bottom of DU shows: Mount Point: /, Format: Mac OS Extended, Owners Enabled: Yes, Number of Folders: 12,067, Capacity: 1.25GB, Available: 40.6MB, Used: 1.12GB, Number of Files: 40,030.

            The only thing left then was the “1TB Seagate” disk. Selecting “1TB Seagate USB…” still has Mount grayed out but Eject is active. Just to see if working in Recovery Mode makes a difference, I tried to Partition again and it started with “Unmounting disk” but ended after a bit of time with the same previous result “Resource busy”!

            Back to square one!!!! Eject and hope someone has a solution for me!!!!!

            Thanks for the advice.

            cheers,

            larry

          2. B. Jefferson Le Blanc

            Sorry it didn’t work. You did find some interesting facts, however. One, that the drive is still formatted as HFS+. Two, that the drive is supposedly almost full. And three, that it appears to contain an OS X base system, which is usually just an invisible boot partition or in some cases can refer to an OS X recovery HD partition. Still, obviously, the drive in non-functional.

            Do you have access to DiskWarrior? It can fix far more than Disk Utility and might be able to restore your volume’s file catalog to the point where you can use it. If that doesn’t work, you may want to evaluate how much your time is worth trying to rehab this drive. If there’s no critical data on it, you may have reached the point of diminishing returns.

          3. Larry

            Hi Jeff,

            No, don’t have DiskWarrior and, given buying it would actually cost me more than a replacement drive, I don’t plan on buying it. Thanks for all your help. Will put the drive on the back shelf and try to come up with a solution “some time down the track”.

            cheers,

            larry

          4. B. Jefferson Le Blanc

            Hi Larry –
            I wouldn’t recommend buying DiskWarrior to fix just one drive, especially as the outcome for that drive is problematic. I thought you might have a friend who has it if you do not, in which case you could check the drive without cost. That’s why I said “access to” rather than “own.” In my case, I am responsible for many drives of my own as well as others belonging to friends and clients, so DiskWarrior is a justifiable expense. But most people don’t need it often, so buying a copy is less appealing. The other reason you might want to get DW is if the data on the drive is important enough to justify the expense. However, from you previous posts the drive does seem to be hosed.

  28. Jason M. Carter

    Was having trouble “cat..ing” /dev/random to the disk due to the resource busy response. I was able to run

    $ diskutil unmount /dev/disk2
    $ diskutil mountDisk
    $ cat /dev/random > /dev/disk2

    and bingo it worked. Now I am writing zeros to the disk… Maybe this will help.

  29. Clang

    Hot damn! It worked! After updating to Yosemite my LaCie 3TB external hard drive stopped showing up in Finder and Disk Utility couldn’t fix it because it would not mount/unmount. I followed your thorough instructions and bam, they worked!

  30. Стас Бицько

    I solved my problems like this:
    zbstof@Stas-MBP:~$ cat /dev/random > /dev/disk2
    -bash: /dev/disk2: Permission denied
    zbstof@Stas-MBP:~$ sudo cat /dev/random > /dev/disk2
    -bash: /dev/disk2: Permission denied
    zbstof@Stas-MBP:~$ sudo su
    Password:
    root@Stas-MacBook-Pro:/Users/zbstof$ sudo cat /dev/random > /dev/disk2
    sh: /dev/disk2: Resource busy
    root@Stas-MacBook-Pro:/Users/zbstof$ umount /dev/disk2
    root@Stas-MacBook-Pro:/Users/zbstof$ sudo cat /dev/random > /dev/disk2
    # here I just waited 10 minutes – then stopped command and disconnected/reconnected usb drive

    # Use Disk Utility to erase USB drive to FAT32 with MBR partition table

    root@Stas-MacBook-Pro:/Users/zbstof$ diskutil list

    /dev/disk2 (external, physical):
    #: TYPE NAME SIZE IDENTIFIER
    0: FDisk_partition_scheme *15.5 GB disk2
    1: DOS_FAT_32 SILI16GB 15.5 GB disk2s1

    DONE!

  31. Evan

    I get the error:

    cat: stdout: Input/output error

    after typing:

    cat /dev/random > /dev/disk2

  32. Dann

    I did this and got it going in a minute or so…
    cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5 && cat /dev/random > /dev/disk5

    Eventually Terminal showed binary garbage. I was able to run first-aid is disk utility and then format the sd card. That was a nightmare.

  33. John D.

    Excellent suggestion, and it got me out of a bind.

    Because you’re looking at blowing away the data on the drive anyway, another method that doesn’t require timing is to connect the drive to a Windows machine and open up drive management. You can delete the partitions on the drive there very quickly, and then reconnect it to your Mac for reformatting there.

  34. Jason Watkins

    This post has got to be one of the dumbest tech suggestions I have ever read. Why not just wave a rubber chicken over the flash drive too. I really can’t get over how bad it is. Wow!

    1. B. Jefferson Le Blanc

      @ Jason Watkins: It’s not clear which post you are referring to, the one just before yours regarding using a Windows PC to reformat the drive, of Topher’s original prescription at the start of this thread. I can’t speak for the Windows solution, but if you had bothered to read the other comments on the thread you would have seen that the solution worked for a majority of the people posting here. Some had a problem here or there, and for others it didn’t work at all. But it’s not clear you even tried it, or had a drive to try it on—or if you tried and it failed. You’re just slinging mud, which is less than helpful. Perhaps typing insults is the limit of your skill set and actually using a complex process like this one is beyond even your imagination. In any case, you never get a second chance to make a good first impression—which is to say, you blew it.

    2. John D.

      @ Jason Watkins: In my case, I had a brand-new Western Digital MyBook USB drive that I wanted to encrypt – should be pretty simple, just a right-click in Finder. Did that, and a couple of seconds into it the device was unreadable and unusable.

      Took me a considerable amount of time and searching to figure out how to get it back to a state where I could even try to reformat it, and this particular post actually worked (although trust me, the Windows way is MUCH faster and easier.)

      Is the post (author’s or mine) the “only” way to get a drive working again? Nope. But it certainly had sufficient detail to get my drive working again, without having to incur the cost of an RMA.

      If you have a better way, or constructive solution of your own, by all means please share it so others can benefit.

      If not, STFU.

      1. B. Jefferson Le Blanc

        @ John D: It may not be possible to determine at this late date, but I’m curious how the drive got corrupted in the first place. One possibility that occurs to me is that the drive was formatted in FAT32 or HTFS to begin with. So when you tried to encrypt it on the Mac the encryption failed and hosed the drive. Disk Utility, if that’s what you used, should have thrown up an error message when you tried to encrypt a drive with an incompatible file system. If you used Western Digital software to try to encrypt the drive, it too should have warned you. If you got no such warning then perhaps I am mistaken about the origin of the problem. That being said, it’s always a good idea to reformat a new drive before you use it to be sure it’s initialized in the desired layout. Usually on the Mac this would be with a GUID partition map. If you want or need to use a drive on multiple platforms, the Mac as well as Windows can read and write to a FAT32 drive, which is sufficient for all but the largest thumb drives. Of course, a FAT32 drive will not hold a bootable Mac system. But for data transfer purposes, it works just fine.

      2. Lloyd Smith

        Other than Jason being a jerk… well, I guess that sums it up.

        A couple of weeks ago, I ordered a USB 3 Western Digital My Passport for Mac 3 TB drive for Time Machine. Plug-and-play. Ha! A nightmare. Too much of their own garbage. A reboot froze half-way through. When I finally was able to boot, the WD drive had disappeared. Along with all of the icons for the apps in the dock, and half of them failed to appear. The generic Mac icon for apps was all that was left.

        I was unaware of this thread, but doubt it would have helped because the Mac (Mini, 16 GB RAM, 500 GB 7200 RPM drive) took minutes just to type a word. Drive Genius, a program I’m not too fond of, finally “found” the drive and I was able to reformat it. But the Mac’s own Disk repair could not find it. Somehow, I was able to get DiskWarrior to recognize it as an unmounted drive and I installed a new directory. I rebooted, reset the PRAM, and the drive appeared. This time, reformatting by the Mac worked. But the blinking white light is so bright I have placed a strip of tape over it. So far, it has not failed, but searching the net, I found hundreds of complaints about my drive and yours.

        Now, to restoring all of the icons and the contents of the dock. Tried booting from other drive and running a couple of programs, but no good. DiskWarrior advised no replacement directory was required. Replaced it anyway. Rebooted to the internal drive and ran Onyx. After running the services and cleaning the surplus logs and rebooting, all the icons returned, the dock was fine, and so far, so good.

        Going back to the 8600 Mac towers, I always ran at least five drives in the tower. Two drives failed over the couple of years I used the 8600. Both were WD. I shudda’ known better. The only brand that has ever failed since my first Mac in 1984.

        1. B. Jefferson Le Blanc

          It appears that your system caches got corrupted at some point. How a new drive could have done that is a mystery—unless there was some malware on the drive. Not much of that around for the Mac, though. Anyway, once again, DiskWarrior to the rescue. A few people posting here think DW is a waste of money. And it may be—until you need it. The current version comes on a thumb drive with a utility that will put it on another thumb drive with your current base system. The drive DW comes on will boot older Macs, including PPC models, so creating an emergency disk for your current system is a good idea.

          1. Lloyd Smith

            Thanks for you follow-up.

            Possibly so. But I am registered as a Mac OS X developer and my most recent update was 10.11.6 Beta 2 on 6 June, and after each iteration I run Onyx, reassign and rebuild permissions (not the old version), rebuild almost everything Onyx will rebuild, run all maintenance scripts, and remove all cache files, leaving only a few net items. After the reboot, I then boot from one of my external drives and run DiskWarrior, replace the directory, then go back to work after a second boot.

            Never can understand while people do not maintain at least one bootable external drive and consider DiskWarrior to be useless. Saved me many times, back to the 8600/9600 days. Since I do always have at least two mirrored backups (not counting two current full disk images auto backed up by SuperDuper scripting), I guess I take more chances than most. (Getting ready to install Sierra.)

            Regarding problems with the two drives from WD mentioned in this thread, simply enter the drive name plus “Mac problems” and you’ll find pages of issues covering the past two years. Changing out terms and adding “boot problems” and “cannot load” will take you to other sites.

            Enjoy!

          2. B. Jefferson Le Blanc

            Hi Lloyd: Typos are par for the course. 😉 I’ve used DiskWarrior for a long time, too. I’ve been doing Mac Tech Support for more than 16 years and utilities like DiskWarrior and TechTool Pro have been essential to my work. Believe it or not, TTP has fixed a volume that choked DW a few times. So having more than one tool in the box can be important. I use iDefrag for drive optimization. Though drive defragmentation is controversial, I’ve found it to be useful.

            I guess I’ve been lucky. I’ve got a bunch of WDC drives that have given me no trouble. In fact, the only one I’ve had a problem with lately is an HGST drive that will mount but not boot. I’ve read that HGST is well regarded by some. Results like these, therefor, seem a bit random. I’m not denying that Western Digital drives are problematic. Obviously they are, as you report.

            But how did a new drive hose your system? Particularly as your system is so well maintained? Did you in fact reformat the drive before trying to encrypt it? Was it a GUID volume to begin with? If the cause of your problem can be diagnosed, it will make it easier to avoid it in the future.

          3. Lloyd Smith

            A long time to reply, but when someone assumes that the person they are responding to is pretty much a dullard and finally do end up replying.

            A small, bus-powered external drive did not do the harm. The trashy software that came with it, as many others attest, should simply be overwritten and forgotten.

            HGST is a WD company. (To respond to someone’s point.)

            The WD 3 GIG drive that has been written about is advertised that it is for Mac, so it would be pretty weak to argue that it might have been formatted FAT 32, particularly when WD advises the purchaser that if they wish, the purchaser can reformat for Windows use.

            Just wandering around, cleaning up loose ends.

  35. Boris Starosta

    I had a HDD go “bad” after some difficulties moving back and forth between two different kinds of dock. Reformatting or erasing using Disk Utility was no longer possible. Your fix has saved me! Worked swell!

  36. Tim Jones-Yelvington

    Have executed these instructions in Terminal several times and am still getting the “cant write to the last block of drive” error message when I try to create partitions or erase the drive in disk utility.

    (What happened w/ me is that I was trying to erase and reformat an old external drive so that I can donate it to my office, and it had only one partition on it—or is the correct language no partitions when there is only one?—Instead of running the erase on the one named partition, ie the part that mounts on my dekstop, I ran the erase on the named hardware element that appeared above it in the hierarchy in disk utility, which apparently was the wrong thing to do? That operation errored out (that was the first time the “last block of drive” message appeared), the named partition disappeared from the navigation in disk utility, the drive stopped mounting/being readable on the desktop, and now I can’t do anything to reformat it without this error message).

    1. B. Jefferson Le Blanc

      @ Tim: Not that it will help you now, but yes, you did it wrong. One partition is the right term for a drive formatted with one partition. That is the element you should have erased, to any of several levels of security available in Disk Utility. You can also just reformat a drive from the top level hardware name; that will erase the file catalog that keeps track of the data. But it doesn’t erase the data so it’s not sufficient on a drive you want to pass on. To be thorough you can repartition a drive after you have erased it. Erasing the drive as you did removed the partition from the drive. Lacking a partition it would naturally be unmountable, though Disk Utility should still be able to see it for the purposes of applying a partition scheme to it. Without a partition DiskWarrior probably wouldn’t help either.

      The error message you’re seeing indicates that there is a bad block on the drive, which is not, in fact, unusual. Normally this should not be a problem; reformatting a drive will just ignore bad blocks when the new file catalog is built, leaving them out of the catalog so data won’t subsequently be written to the bad blocks. In this case the problem seems to be more severe for some reason—perhaps the age of the drive has something to do with it. It’s clearly a hardware fault of some kind. The error message may not describe it properly, there being no appropriate message available to the utilities you’re using, which are quite limited in their vocabularies in any case.

      This suggests to me that the drive may have been on the verge of failing in the first place, and what you did merely uncovered the hidden problem. Drives will often limp along in use showing no obvious signs of trouble even when trouble is lurking. Smart checking a drive—checking various drive parameters—with a utility like TechTool Pro can expose hidden problems, though sometimes even this is not enough. I’ve had a drive fail even when it recently passed a TTP smart check. Which is to say these are complicated devices and it’s simply not possible to cover all the bases, even when you’re being careful.

      Disk Utility routinely does a smart check on a drive when you launch the app. But all it does is say pass or fail. It doesn’t offer any useful details. To complicate things, there are also different kinds of smart check. Some utilities do a more thorough job than others. Disk Utility is fairly rudimentary. In some cases external drives cannot be smart checked at all so you can be flying blind. You won’t know something is wrong until the drive goes toes up.

      What you do now will depend on how valuable you think the drive enclosure is. You can replace the drive, though the bridge board in an enclosure can fail when the drive itself is perfectly good. But this is another problem that does not seem to apply in your case. It will depend on whether the drive connections, FireWire, USB 2 or eSATA, pair with the computers at work you intended to use it with. If the computer(s) are of a similar vintage then it might be worth swapping out the drive with a new one. New external drives will routinely have USB 3, which is faster than even FireWire 800. And the drives are relatively inexpensive and come in higher storage capacities than older drives. Thunderbolt drives are faster still, but they are expensive and unless they are used in a performance critical situation they may be overkill. USB 3 and Thunderbolt, however, are useful primarily with newer computers. One advantage of USB 3 is that it will work with both Macs and Windows (and Linux) PCs.

      I hope this is not too much information. I tend to rattle on.

  37. Rodrigo Siqueira

    I would like to thank you for your text, do not know if you will read because your post is already long, but it was the trigger for the solution of my problem. My External Hard Drive was not being read with an error [Error: -69877: Couldn’t open device] when made by disk utility. Followed by the solution you gave the terminal, but the device was said it was busy and nothing was made the terminal to format it, always appearing as busy everytime. As you said some system process was hooking it first, I thought, and if I format before the system open?, then restart the mac with command+R, then disk utility. Formatting there didn’t take even 10 seconds, and now everything was perfect. THANK YOU!

  38. aaron tremblay

    OK well I too am having a problem with a USB 16GB drive from Lexar. I created an install drive for OS Sierra and now that I want to use it for something else I cannot erase, repair the drive. I’ve tried to erase and repair the drive in recovery mode with no luck. I’ve tried disktutil in terminal with no success.

    sh-3.2# fdisk /dev/disk2
    Disk: /dev/disk2 geometry: 1945/255/63 [31258624 sectors]
    Signature: 0xAA55
    Starting Ending
    #: id cyl hd sec – cyl hd sec [ start – size]
    ————————————————————————
    1: EE 1023 254 63 – 1023 254 63 [ 1 – 31258623]
    2: 00 0 0 0 – 0 0 0 [ 0 – 0] unused
    3: 00 0 0 0 – 0 0 0 [ 0 – 0] unused
    4: 00 0 0 0 – 0 0 0 [ 0 – 0] unused
    sh-3.2# diskutil eraseDisk JHFS+ USB disk2
    Started erase on disk2
    Unmounting disk
    Error: -69877: Couldn’t open device

    I have followed the post almost to its entirety and my eyes were bleeding LOL. I have also tried to use the cat command to write the random data and here is the output.

    sh-3.2# ps aux | grep /dev/disk2
    root 897 0.0 0.0 2423384 232 s000 R+ 3:59AM 0:00.00 grep /dev/disk2
    sh-3.2# sudo kill 897
    kill: 897: No such process
    sh-3.2# cat /dev/random > /dev/disk2
    sh: /dev/disk2: Permission denied
    sh-3.2# sudo cat /dev/random > /dev/disk2
    sh: /dev/disk2: Permission denied
    sh-3.2# sudo cat /dev/random>/dev/disk2
    sh: /dev/disk2: Permission denied
    sh-3.2# sudo cat /dev/random>/dev/disk2s2
    sh: /dev/disk2s2: Permission denied

    configuration is MBP late 2013 OS Sierra 10.12.1 16GB RAM 512 SSD. My ultimate goal is to create a bootcamp drive to run Windows 10 for testing and training purposes. Any help would be great!! Thanks

Comments are closed.