Clear Read-Only flag on Disk in Windows 7 using Diskpart

This is a short HOWTO clear the read-only/readonly flag/attribute on a disk in Windows 7 using the diskpart command from a Windows Command Prompt.

Warning!
Be sure to do this on the right disk since the diskpart command can do serious damage if you run it on the wrong disk.

  1. Open a command window by running the diskpart command from a Command Prompt
  2. Determine which disk you are going to modify:
  3. DISKPART> list disk
    
      Disk ###  Status         Size     Free     Dyn  Gpt
      --------  -------------  -------  -------  ---  ---
      Disk 0    Online          149 GB  1024 KB
      Disk 1    Online          465 GB   465 GB
  4. Select the disk you are going to modify
    DISKPART> select disk 1

    You have now selected disk 1

    list disk
    
      Disk ###  Status         Size     Free     Dyn  Gpt
      --------  -------------  -------  -------  ---  ---
      Disk 0    Online          149 GB  1024 KB
    * Disk 1    Online          465 GB   465 GB
  5. Clear the Read-Only attribute on the selected disk
    DISKPART> attributes disk clear readonly

The disk is no longe Read-Only protected.

If you would like to set the disk Read-Only again just do the same procedure and write

DISKPART> attributes disk set readonly

in the last operation.

When you are done modifying the disk attributes just issue the exit command

DISKPART> exit

and the diskpart windows will be closed.

27 thoughts on “Clear Read-Only flag on Disk in Windows 7 using Diskpart

  1. Thank you so very much, I have been looking everywhere for this solution best one i have found. Already took one card back and didn’t have to.
    Once again Ty worked like a charm after removing and reinserting

    1. Are you sure you did run diskpart with administrator rights?

      1. What if ….”diskpart failed to clear disk attributes” msg pop? using as administrator

    1. You probably know the capacity/size of the disk you are going to modify and choose it.
      Try to remove disks if you have several of the same size to avoid working on the wrong disk.

  2. Just installed Windows 7 yesterday for the first time and all went nice and smooth until this “read-only” problem started to pop-up. I did google the solution and came to this web site and did it like explained – all I can say it thank you big time cause it worked right away with no problems what so ever.

  3. I did as you said every command got successfully executed but still it shows disk is write protected??

  4. not working…i have sandisk pd bt same problem….pls help…urgent….contact me on email id(chintanshah0123@gmail.com) pls….

  5. I tried it but still write protected. Are there still any other methods? Please help me. Thank you

    1. Sorry to hear that. This method worked for me so I have not done any more searching about this problem.

  6. ive tried this… and afterwards i typed in “det dis” and i got the following:

    DISKPART> list disk

    Disk ### Status Size Free Dyn Gpt
    ——– ————- ——- ——- — —
    Disk 0 Online 298 GB 0 B
    Disk 1 Online 596 GB 7168 KB
    * Disk 2 Online 29 GB 0 B

    DISKPART> sel dis 2

    Disk 2 is now the selected disk.

    DISKPART> att dis clear readonly

    Disk attributes cleared successfully.

    DISKPART> det dis

    ChipsBnk Multi-Reader USB Device
    Disk ID: 00000000
    Type : USB
    Status : Online
    Path : 0
    Target : 0
    LUN ID : 0
    Location Path : UNAVAILABLE
    Current Read-only State : Yes
    Read-only : No
    Boot Disk : No
    Pagefile Disk : No
    Hibernation File Disk : No
    Crashdump Disk : No
    Clustered Disk : No

    Volume ### Ltr Label Fs Type Size Status Info
    ———- — ———– —– ———- ——- ——— ——–
    Volume 5 E RAW Removable 29 GB Healthy

    i need “current read only State” to be “no” as well…

    Any suggestions please email me at ballzac2000(at)hotmail.com.

    Thanks,

    Zacc

    1. Hi Rajendra gupta,

      Why don’t you try to follow the instructions in the post and let me know what went wrong?

  7. I tried the above mentioned commands.When I run the last command “attributes disk clear readonly” then I am getting the message as “Disk attributes cleared successfully” . But still when I try to format or paste something then I am getting the same message that disk is write protected. Plz guide me.

    1. Hi Ketaki,

      Are you sure you did run diskpart with administrator rights?

  8. You guys need to unplug your drives and then plug them back in. Also, try rebooting your computer. For harddrives for example, setting the readonly bit will only work after a reboot (or possibly after remounting the drive).

  9. I get this error, so apparently you need to run a check-disk to remove the dirty flag from the drive. chkdsk u: /f /r /x I have a exfat ssd on windows 7 and this happens every other month where it mounts as read only. If it tells you the drives in use, in task manager you can go view>select columns> image path name to see whats loading off the drive. Not 100% but may help.

  10. @Hans-Henry & @Solver, Morning! I’ve been searching a method myself for un-setting the read-only state on my sandisk drive. Nothing seems to work. I followed this procedure every step of the way, but nothing seems to work.

    I got to this so far:

    DISKPART> list disk

    Disk ### Status Size Free Dyn Gpt
    ——– ————- ——- ——- — —
    Disk 0 Online 250 GB 0 B
    Disk 2 Online 16 GB 0 B

    DISKPART> sel dis 2

    Disk 2 is now the selected disk.

    DISKPART> att dis clear readonly

    Disk attributes cleared successfully. (This is really annoying… Appearently all worked out just fine…)

    DISKPART> det dis

    ChipsBnk Multi-Reader USB Device
    Disk ID: 00000000
    Type : USB
    Status : Online
    Path : 0
    Target : 0
    LUN ID : 0
    Location Path : UNAVAILABLE
    Current Read-only State : Yes
    Read-only : No
    Boot Disk : No
    Pagefile Disk : No
    Hibernation File Disk : No
    Crashdump Disk : No
    Clustered Disk : No

    That current Read-Only State has never changed, no matter what I do. After that, I typed exit as instructed, removed the flashdrive then plug it back in but nothing seems to work. I even repeated every step but after I typed “exit” and removed the flashdrive I even went ahead and reboot my PC, still, no changes took place. is there anything I’m missing? I’d very much appreciate if you could please guide me a little bit on this matter. Thanks in advance.

    jogs2602@yahoo.com

  11. Try and close any Control Panel, My Computer and any folder you have opened. Then insert memory card and close autorun. Run the procedure. In My Computer eject memory card dismount dismount, reinsert. See if that helps!

  12. Many thanks – worked like a charm!!! i had a 3TB backup drive that all of the sudden went READ-ONLY, and i’ve been ‘stuck’ with it like that for almost a year!!!

    this solution is too easy ( as they say in the military )

    THANK YOU x 1000!!

  13. I tried the above mentioned commands.When I run the last command “attributes disk clear readonly” then I am getting the message as “Disk attributes cleared successfully” . But still when I try to format or paste something then I am getting the same message that disk is write protected. Plz guide me.

  14. Hello Everyone,

    I was able to resolve my issue. Here is what I did.

    Firstly, there are a series of options in the Group Policy Object Editor that deal with read/write permissions on hard drives and removable media. I basically changed their individual settings from “Not configured” to “Disabled”.

    Start -> Run… -> gpedit.msc -> OK

    Computer Configuration -> Administrative Templates -> System -> Removable Storage Access

    In here I disabled all of the “Deny read access/write access” options; you may only want to disable the ones relating directly to the type of media that you want to access.

    Here are the ones I changed:

    Removable Disks: Deny execute access
    Removable Disks: Deny read access
    Removable Disks: Deny write access
    Double-click each one and select the ‘Disabled’ radio button.
    i got same problem but try this

  15. GREAT page. Searched and searched, I didn’t found the solution anywhere as here. Still a mystery why the (initially GPT, now MBR, always with exFAT partition) disk got readonly! THANK YOU!!

Comments are closed.