Remove the Read‑Only State from a USB Drive
In this article
Yes, you can clear the read‑only flag on a USB flash drive using built‑in tools in Windows, macOS, or Linux; the process involves changing the drive’s attribute with a command‑line utility or, on Windows, with Diskpart.
What You’ll Need
- A computer running Windows 10/11, macOS 10.15 or later, or a modern Linux distribution.
- The USB drive that is currently read‑only.
- Administrator or root privileges on the computer.
- Basic comfort with command‑line interfaces (cmd, PowerShell, Terminal).
Step‑By‑Step
- Back up any data you still need. Removing the read‑only attribute does not delete files, but if the drive is failing, a backup protects you from accidental loss.
- Identify the drive letter (Windows) or device node (macOS/Linux).
- Windows: Open
File Explorer, locate the USB drive, and note its letter (e.g.,E:). - macOS: Open
Terminaland rundiskutil list. Find the entry that matches the size and name of your USB; note the identifier such as/dev/disk2. - Linux: Open a terminal and run
lsblkorfdisk -l. Look for a device like/dev/sdbwith the correct size.
- Windows: Open
- Open an elevated command prompt.
- Windows: Click
Start, typecmd, right‑clickCommand Promptand chooseRun as administrator. - macOS/Linux: Open
Terminal. Usesudo -i(or prefix commands withsudo) to gain root privileges.
- Windows: Click
- Use the appropriate tool to clear the attribute.
- Windows – Diskpart
- Type
diskpartand press Enter. - At the
DISKPART>prompt, typelist volumeand press Enter. Locate the volume number that matches your USB drive. - Select the volume:
select volume X(replaceXwith the number you found). - Remove the read‑only flag:
attributes volume clear readonly. Diskpart will confirm the change. - Type
exittwice to leave Diskpart and the command prompt.
- Type
- macOS – Disk Utility (GUI) or Terminal
- Open
Disk Utility(found inApplications > Utilities). - Select the USB drive in the sidebar, click the
Infobutton, and verify that the "Read‑Only" checkbox is unchecked. If it is checked and cannot be changed, proceed to Terminal. - In Terminal, run
diskutil info /dev/diskN(replaceNwith your identifier) to confirm the currentRead‑Onlystatus. - Clear the flag with
diskutil unmountDisk /dev/diskNfollowed bydiskutil eraseDisk FAT32 TEMP MBRFormat /dev/diskN. This command formats the drive, which also removes the read‑only attribute. If you do not want to erase, usesudo mount -uw /dev/diskNto remount it as writable.
- Open
- Linux – hdparm or blockdev
- First, ensure the drive is not mounted:
sudo umount /dev/sdX*(replaceXwith the appropriate letter). - Check the current flag:
sudo hdparm -r /dev/sdX. If it returnsreadonly = 1, the flag is set. - Clear the flag:
sudo hdparm -r0 /dev/sdX. This sets the drive to read‑write mode. - If
hdparmreports that the device does not support the command, trysudo blockdev --setrw /dev/sdXinstead.
- First, ensure the drive is not mounted:
- Windows – Diskpart
- Verify the change.
- Windows: In
File Explorer, try creating a new folder or copying a file onto the USB drive. If it succeeds, the flag is cleared. - macOS: Run
diskutil info /dev/diskNagain; theRead‑Onlyline should showNo. Then drag a file onto the drive. - Linux: Use
touch /media/usb/testfile(adjust the mount point) to confirm write access.
- Windows: In
- Safely eject the drive. Use the OS‑provided eject command (
Safely Remove Hardwareon Windows, right‑click and chooseEjecton macOS, orudisksctl unmount -b /dev/sdXon Linux) before unplugging.
Common Mistakes
Attempting to clear the flag on a drive that is physically write‑protected (a hardware switch) will never succeed; the software commands only affect logical attributes. Selecting the wrong volume or device node can lead to data loss on an internal drive, so double‑check the identifier before issuing any command that modifies attributes. On Windows, forgetting to run the command prompt as administrator will cause Diskpart to report “Access denied.” On macOS and Linux, omitting sudo will result in “operation not permitted.” Finally, using the eraseDisk command in macOS without intending to format will permanently delete all data.
Tips
- Keep a small text file on the USB drive as a quick test for write permission after each change.
- If the drive repeatedly reverts to read‑only after a reboot, the flash memory may be failing; consider replacing the drive.
- When using
hdparmon Linux, add the-vflag for verbose output to see exactly what the tool is doing. - On Windows, you can also clear the flag via the registry if Diskpart fails: navigate to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePoliciesand setWriteProtectto0. Restart after editing. - Always eject the drive properly; abrupt removal can cause the controller to flag the device as read‑only on the next insertion.
Troubleshooting
Step 1 – Confirm the drive is not physically locked. Some USB sticks have a tiny switch on the side. If it is set to “Lock,” software cannot override it.
Step 2 – Re‑run the attribute command. A typo or an interrupted session can leave the flag unchanged. Close the terminal, reopen it with elevated rights, and repeat the appropriate command.
Step 3 – Check for driver or firmware issues. On Windows, open Device Manager, expand Disk drives, right‑click the USB device, and select Update driver. On macOS, ensure the system is up to date; firmware updates sometimes resolve controller bugs.
Step 4 – Use a different computer. If the same USB remains read‑only on multiple machines, the issue is likely hardware‑level.
Step 5 – Re‑format as a last resort. Formatting will definitely remove the read‑only flag because it rewrites the file‑system structures. In Windows, right‑click the drive → Format…. Choose NTFS or exFAT depending on your needs. On macOS, use Disk Utility → Erase. On Linux, mkfs.vfat /dev/sdX1 (or another file system) will do the job.
If none of the above resolves the problem, the flash controller may have entered a permanent read‑only mode due to wear‑leveling failures. In that case, replace the drive.
Frequently Asked Questions
Why does my USB drive become read‑only after a power loss?
Sudden power loss can trigger the drive’s firmware to protect data by switching to a read‑only mode. Running the attribute‑clearing commands after the next boot usually restores write access.
Can I remove the read‑only flag without losing any files?
Yes. The commands listed (Diskpart, hdparm, diskutil) modify only the attribute; they do not format or delete data. Only formatting will erase files.
Is the read‑only attribute the same as the “write protection” switch?
No. The hardware switch physically disables the write circuit, while the attribute is a software flag stored in the drive’s controller. Both prevent writing, but only the software flag can be changed via commands.
My drive still shows as read‑only after using Diskpart. What now?
Double‑check that you selected the correct volume number. If the correct volume is selected and the command succeeded, try unplugging and re‑plugging the drive. If the problem persists, test the drive on another computer or consider that the flash memory may be failing.
Do these steps work on USB‑C external SSDs?
The same principles apply to any USB mass‑storage device, including external SSDs, as long as the operating system recognizes it as a standard disk.
Will disabling write protection affect the data already on the drive?
No. Existing files remain unchanged; you simply regain the ability to modify, add, or delete files after the flag is cleared.