Problem using Win32DiskImager to write to SD Card – Error 5, Lock problem

Same day that my Pi arrived, I tried to write the Debian squeeze image to an 8GB Sandisk Micro SD. Actually I tried it with a 2GB unbranded and found the same problem.

The problem was that when clicking the ‘Write’ button in Win32DiskImager, it would say it could not lock the disk, the disk being the SD Card. Nothing I knew of  had accessed the card since I had inserted it into the reader.

Looking around I saw a comment that said delete all partitions on the card. The only partition of course was a FAT32 one which was standard for this kind of disk. I used windows 7 diskpart as follows to delete the partition:

  • Open a command prompt.
  • Type ‘diskpart’ and the ‘Diskpart>’ prompt will be displayed.
  • Against the Diskpart> prompt, type ‘list disk’.
  • A list of disks will appear, for example:DISKPART> list disk

    Disk ###  Status         Size     Free     Dyn  Gpt
    ——–  ————-  ——-  ——-  —  —
    Disk 0    Online          465 GB      0 B
    Disk 1    Online         7580 MB  5723 MB

    DISKPART>

  • Here you can see that my SD card is Disk  1 just by inspecting the sizes.
  • With diskpart, before you can work on a disk or a partition, you must set the focus. So to select Disk 1 in my example, type ‘select disk 1′.
  • Next check the partitions on the disk you have selected by entering ‘list partition’.
  • In my example there was just the one FAT 32 partition called ‘partition 1′.
  • Before deleting, you need to set the focus to the partition, so in my example I entered ‘select partition 1′.
  • To delete the partition, enter ‘delete partition’.
  • In my case, it still would not let me do this, saying the disk was locked. So we can use the ‘override’ parameter with delete by entering:
  • delete partition override

We now have an SD card with no partiton defined! The next step was to exit diskpart by entering ‘exit’ and then try writing the disk image again.

Success!

I hope this helps someone else, please leave a comment! Someone has to be my first non-family-member commenter!!

31 thoughts on “Problem using Win32DiskImager to write to SD Card – Error 5, Lock problem

  1. Sorry only just seen your comment – many thanks for that. I’m glad the post helped. What have you been doing with your Pi? Cheers, Chris.

  2. This was right on the money, solved the problem for me too. Now to get to grips with Raspian…the official version!

  3. Thanks for the comments. I took a different approach and just formatted SD card (same brand… SanDisk). It worked after using FAT32, 32 kilobytes and a quick format.

  4. I was having the problem, followed your advice using diskpart, and still had the problem. Then I restarted with the flash reader unplugged, disabled antivirus, shut down all other programs, installed the reader and flash card, ran win32 disk imager as admin, and was successful. I’m sure not all of those were necessary, but one of them did the trick. Thanks for the write up.

  5. if you would just right click and run as Admin it will work more than most of the time. js.

  6. Did not work for me. I get the message “can not delete volumes on removable media”.
    any other advice?

  7. HI, One of the contributors below (Zed) mentioned right clicking and running as administrator. So if you right click the Command Prompt icon in Programs and choose Run as Administrator then carry on as before. I have had to resort to that before in other situations, but must admit I didn’t think of when I had this problem!

    If it sorts it, would appreciate it if you could report it back here to add to the info. Cheers, Chris.

  8. I also had the same problem. Running as administrator did the trick. Simply right-click and select Run as administrator!

  9. Thanks for this very useful post, I came across the exact same problem and didn’t know how to fix it, cheers! :)

  10. Thank you. I had the lock issue too, and your advice cleared it. No to see if the debian version works even though the checksums do not match the online manual! Andrew

  11. With your valuable suggestions in a few minutes all went well.

    Thank you!

    Roberto from Italy

  12. I have try it but it writes when i wanted to delete: “can not delete volumes on removable media” I have run it as Admin but it doesn’t work.
    Can some one help me? :)

  13. I tried what zed said, and what you said, but the override command won’t work. any more ideas?

  14. Excellent, it worked!
    Now I can get on with my life :)
    ps – where can I get the the kind of captcha you have here?

  15. This worked for me.
    For the past few days, my Windows system kept giving me the Error 5 after years of writing images with no problems using Win32DiskImager.

    I do not know what changed on my system that causes this routine process to fail for no reason, but your solution worked. Thank you very much!!

  16. Thanks very much!! It had me scratching my head for an hour or so; and the internet searches were not turning up much- until I hit on your post.

    Thanks again.

  17. Perfect… worked immediately! I wish all of this start up information was gathered in one place.. one of these days I might get around to it… or become a consultant :-)

  18. You made my day :-)
    At first nothing mentioned here did work for me.
    But ….
    The essential tip was that there should be NO prtition on the SD-Card.
    So I ran “EaseUS Partition Master 9.3.0″ which was already installed on my computer and I was able to delete the partition. (Be carefull to choose the right drive!).

Leave a Reply

Your email address will not be published. Required fields are marked *


six × 4 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>