TestDisk won’t write the USB table: find the blocker first
By Daniel Brooks Published 9 min read
On this page (8 sections)
- The short version
- Why TestDisk cannot write partition table on USB drive
- Check whether Windows, macOS or Linux reports the drive as read-only
- Confirm the USB adapter, port or card reader is not forcing read-only mode
- Close the apps holding the drive open before you retry
- Verify the correct physical disk and partition are selected in TestDisk
- Retry the write and read the remaining error honestly
- Questions people still ask
In short: Whether TestDisk can write depends on what is blocking the drive: write protection, a read-only controller in the adapter, another app holding the disk open, or running TestDisk without admin rights. Check those four in that order, because each one fails the write the same way.
Part of our guide on versioning and data retention
Four different faults produce the same TestDisk write error, and each has a quick check before you risk another write.
| First check | read-only flag on the drive |
|---|---|
| Windows command | attributes disk clear readonly |
| macOS check | diskutil info, Read-Only line |
| Linux check | blockdev –getro /dev/sdX |
| Permission | admin or sudo required |
| Most common blocker | read-only controller, not TestDisk |
| Before any write | back up what you can copy |
The short version
- Check Windows, macOS or Linux for a read-only flag before blaming TestDisk
- Some card readers and USB bridges report read-only when the controller is failing
- Close Explorer windows, backups, antivirus scans and Disk Management before the write
- Run TestDisk as administrator on Windows or with sudo on macOS and Linux
- Confirm the physical disk by size and model before writing any table
Why TestDisk cannot write partition table on USB drive
TestDisk can find a damaged partition table yet fail when you choose Write. The drive may still appear normally in a file browser, which makes the error seem like a TestDisk fault. TestDisk sends the table change to the physical device, so any read-only flag, locked handle, missing permission or failed controller can stop it.
Four blockers produce the same symptom. The operating system may flag the disk read-only, the adapter may force read-only mode, another program may hold the disk open, or TestDisk may lack permission. Check them in that order because the early tests are quick and reversible.
A drive that writes on one machine but refuses writes on another typically has an OS-level read-only flag set on the refusing machine. The same drive can therefore behave differently across Windows, macOS and Linux.
Check whether Windows, macOS or Linux reports the drive as read-only
Windows provides the clearest check. Open PowerShell or Command Prompt, run diskpart, then list disk, select disk N and attributes disk. Read Current Read-only State and Read-only. If either attribute is active, run attributes disk clear readonly, then check again.
MacOS reports the same condition through diskutil info diskN. Read the Read-Only Media and Read-Only Volume lines. Read-Only Media: Yes points toward the drive or adapter, while a volume-only restriction can come from the file system or mounted volume.
Linux exposes the block-device state with blockdev --getro /dev/sdX. A result of 1 means read-only, while 0 means the kernel allows writes. Use lsblk -o NAME,SIZE,MODEL,RO,TYPE to identify /dev/sdX before running the command, because the wrong device path can affect another disk.
A manual switch on an SD adapter can also cause this result. Slide it away from Lock, reconnect the device and repeat the check. If the state returns after clearing it, stop repeating the command; the flash controller or adapter is probably enforcing read-only mode.
What a manual write-protect switch means
Some SD adapters and a few rugged USB devices carry a small physical slider. If it moved toward Lock, every tool on every computer will refuse writes. Move it, reconnect the device and check the read-only state again before using TestDisk.
Confirm the USB adapter, port or card reader is not forcing read-only mode
A card can mount normally through a reader yet refuse every write after the reader or bridge starts failing. If the restriction follows one reader but disappears with another, replace the reader rather than changing the partition table again.
Test one part at a time. Put a microSD card in another reader, connect a USB stick directly to the computer and replace the cable for an external enclosure. USB hubs can add power or connection faults, but they don't usually create a software read-only flag by themselves. A failing hub, port or bridge can still interrupt writes and make TestDisk report failure.
USB 2.0 and USB 3.0 ports do not normally impose read-only mode. Their speed standard is not a write-protection setting. A damaged USB 3.0 port, poor cable or unstable hub can cause resets and failed writes, so test the same drive through a direct USB 2.0 port and a direct USB 3.0 port when available.
USB hard drives and SSDs in enclosures can fail in the SATA-to-USB bridge while reads continue. If every computer and direct connection gives the same result, the drive controller may have locked itself. No partition utility can override that hardware state.
| Blocker | Where you see it | What clears it |
|---|---|---|
| OS read-only flag | diskpart, diskutil or blockdev reports read-only | Clear the attribute; if it returns, move on |
| Manual lock switch | Every computer refuses writes | Slide the switch and reconnect |
| Failing reader or bridge | Read-only through one adapter or enclosure | Replace the reader, cable or enclosure |
| Disk in use | Windows reports a write error; macOS or Linux reports a busy device | Close apps and unmount the disk |
| No permission | Access denied immediately at launch | Run as administrator or with sudo |
Close the apps holding the drive open before you retry
Multiple programs can lock a drive simultaneously, including backup software, antivirus scans, and open file browser windows. TestDisk then requests a partition-table write while another process still has an open handle.
Close every Explorer or Finder window showing the drive. Pause scheduled backups and cancel an antivirus scan covering the drive. Close Disk Management on Windows and any disk utility on macOS, because these tools can keep polling the device.
Run TestDisk as administrator on Windows by right-clicking it and choosing Run as administrator. On macOS or Linux, start it with sudo testdisk. Without elevation, TestDisk may fail to open the raw disk, which can look like a write error.
On macOS, unmount the volume with diskutil unmountDisk diskN, leaving the physical disk available. Linux can use umount /dev/sdX1 for each mounted partition, or udisksctl unmount -b /dev/sdX1. If unmounting fails, use lsof /dev/sdX or fuser -vm /dev/sdX to identify the process.
- Close every Explorer or Finder window showing the USB drive.
- Pause scheduled backups and antivirus scans covering the drive.
- Close Disk Management or any disk utility monitoring the device.
- Run TestDisk as administrator on Windows, or with sudo on macOS and Linux.
- Unmount the volumes on macOS or Linux before opening TestDisk.
- Retry the Write step and record the exact error text if it still refuses.
Verify the correct physical disk and partition are selected in TestDisk
TestDisk lists every physical drive it sees. A USB stick can share a capacity range with an internal disk or another external drive, so selecting by size alone is unsafe.
Match the reported size, model and partition count before confirming Write. Cross-check the list against Windows Disk Management, macOS diskutil list or Linux lsblk -o NAME,SIZE,MODEL,TYPE. The model string separates two disks with similar capacities.
Inside TestDisk, create a log if asked, choose the physical disk, select the detected partition-table type, then choose Analyse and Quick Search. Review the found partitions before selecting Write. If the results look wrong, use Deeper Search instead of writing the table.
A partition-table write has no simple undo. Confirm the physical disk twice, especially when an internal and external disk have similar sizes.
Retry the write and read the remaining error honestly
After the read-only checks, connection tests, app closures and permission checks, retry Write once. Read the exact message instead of treating every failure as the same hardware fault.
TestDisk commonly displays "Write error: Can't write partition table" when the table write fails. A device that has disappeared can produce "Partition: Read error", while a failed search can show "No partition is bootable". TestDisk versions and operating systems can change the surrounding wording, so record the complete screen before searching for a match.
Windows can test the same hardware path with diskpart and clean on the selected disk, but this destroys partition information. Use it only after the needed files are safe and the disk identity is certain. If clean also returns an I/O error, the drive, bridge or connection is failing.
Linux live media removes Windows from the test. Use lsblk to identify the disk, blockdev --getro /dev/sdX to check its state and sudo testdisk /dev/sdX to run TestDisk. If Linux writes while Windows does not, investigate the Windows flag, driver or open handle instead of blaming the flash storage.
A failing controller cannot be repaired with another partition command. Keep later attempts limited when the drive matters, and use professional recovery if important files become unreadable.
- "Write error: Can't write partition table": TestDisk could not commit the table
- "Partition: Read error": the device or connection failed while reading sectors
- "No partition is bootable": the search found no bootable partition, not necessarily a write failure
- Access denied after elevation: controller, bridge or security software may be blocking the device
- Device busy after closing apps: use lsof, fuser or Resource Monitor to find the remaining handle
Work through the four blockers in order. Failures that remain after those checks usually point to the adapter, bridge or flash controller.
Questions people still ask
Can TestDisk write to a write-protected USB drive at all?
No. If the OS flag, lock switch or drive controller says read-only, TestDisk fails like every other tool. Clear the OS flag with diskpart, diskutil or blockdev first. If the state returns, the controller has locked the device and software cannot override it.
Why does TestDisk need administrator rights to fix a USB drive?
Operating systems reserve raw-disk access for elevated processes. Without admin rights on Windows or sudo on macOS and Linux, TestDisk may not open the physical disk, and the resulting message can resemble a write failure.
My drive is read-only on every computer. Is it dead?
Not necessarily, but the controller may have locked writes after detecting failing flash blocks. Reads can still work, so keep the recovery decision from the opening callout in place. A different reader rules out the enclosure, but a lock that follows the drive usually means replacement.
How do I know TestDisk is writing to the right disk?
Match the model name and capacity in TestDisk against Disk Management, diskutil list or lsblk before confirming Write. Size alone is not enough because two disks can share a capacity range.
Should I use TestDisk or just reformat the drive?
Reformat only after the needed files are safe. TestDisk can rebuild a partition table without immediately formatting the existing partitions, while a format starts fresh. Use Analyse and Write when the goal is recovery; format only when you want a blank drive.