USB flash drive, now read only

Hello, I have this SanDisk 16 GB USB drive I’m using since 2014, and it works very well under Win10 and several linux distros. It is formatted with NTFS.
Last week I installed a fresh Haiku image (64 bit build) into a virtual machine and I connected that USB drive. As usual, a warning popped up with suggestion of mounting it in read-only. I usually do not care, since NTFS is well supported (I never run into troubles) but that time I clicked OK and OPS! now my USB drive turned into read only FOREVER.
I spent a few days playing with hdparm (on linux), then a few days mounting it again into Haiku and selecting “read-ony”, then “read-write”, then other few days with diskpart (on win10) but the result is… no result: still the drive is write-protected.
I know this may be due to the read-only flag, which is set into the drive controller, not into the OS.
What can I do in order to get back the drive writable?

As far as I know, we do not intentioanlly set any hardware write protection in Haiku. Mounting read-only is a purely software thing and not stored anywhere on the key.

What likely happened is that the NTFS filesystem is not marked “clean”, and as a safety measure, it is mounted read-only to make sure no data is corrupt. If that’s the case, running a filesystem check from Windows would “fix” it, I think?

Mounting read-only is a purely software thing

This is what I thought until last week, ah ah ah ah :slight_smile:

Sadly, Windows’ scandisk won’t fix anything. It aborts almost istantly because “the file system is read-only”.

Edit: I wonder if I’m allowed to post some screenshots showing output from both hdparm and diskpart, hoping they’re helpful.

You can post screenshots of course.

Also I’m sure you meant chkdsk not scandisk since that hasn’t been around for ages. According to the chkdsk /? help output you should probably run

chkdsk /F /X Driveletter:

or perhaps

chkdsk /offlinescanandrepair Driveletter:

CHKDSK [volume[[path]filename]]] [/F] [/V] [/R] [/X] [/I] [/C] [/L[:size]] [/B] [/scan] [/spotfix]

volume Specifies the drive letter (followed by a colon),
mount point, or volume name.
filename FAT/FAT32 only: Specifies the files to check for
fragmentation.
/F Fixes errors on the disk.
/V On FAT/FAT32: Displays the full path and name of every
file on the disk.
On NTFS: Displays cleanup messages if any.
/R Locates bad sectors and recovers readable information
(implies /F, when /scan not specified).
/L:size NTFS only: Changes the log file size to the specified
number of kilobytes. If size is not specified, displays
current size.
/X Forces the volume to dismount first if necessary.
All opened handles to the volume would then be invalid
(implies /F).
/I NTFS only: Performs a less vigorous check of index
entries.
/C NTFS only: Skips checking of cycles within the folder
structure.
/B NTFS only: Re-evaluates bad clusters on the volume
(implies /R)
/scan NTFS only: Runs an online scan on the volume
/forceofflinefix NTFS only: (Must be used with “/scan”)
Bypass all online repair; all defects found
are queued for offline repair (i.e. “chkdsk /spotfix”).
/perf NTFS only: (Must be used with “/scan”)
Uses more system resources to complete a scan as fast as
possible. This may have a negative performance impact on
other tasks running on the system.
/spotfix NTFS only: Runs spot fixing on the volume
/sdcleanup NTFS only: Garbage collect unneeded security descriptor
data (implies /F).
/offlinescanandfix Runs an offline scan and fix on the volume.
/freeorphanedchains FAT/FAT32/exFAT only: Frees any orphaned cluster chains
instead of recovering their contents.
/markclean FAT/FAT32/exFAT only: Marks the volume clean if no
corruption was detected, even if /F was not specified.

The /I or /C switch reduces the amount of time required to run Chkdsk by
skipping certain checks of the volume.

Well, I’m sure I got confused by the many changes in tool naming I went through in the past years :stuck_out_tongue: Sorry!
Anyway, what I meant was the gui tool:
diskpart_scandisk_gui
(italian: “this disk is write protected”)
but also the command line tool gives the same diagnostic message.

The output from DISKPART is:
diskpart_usb
(italian first statement says: “current state of read-only: YES”)

Finally, this is what hdparm gets me:
diskpart_hdparm
together with latest kernel logs from dmesg after plugging in the usb stick.

You should check whether the drive is write-protected, or only the NTFS partition.

from the log: “Write Protect is on”

If you figure this out, I’d be interested in hearing about it. I also have a USB drive that is now in “read only mode” and nothing I’ve tried (including PNY’s own utility) will turn it back to writable.

And, no, there is no physical ‘write-protect’ switch.

https://www.easeus.com/storage-media-recovery/fix-read-only-error-on-hard-drive.html

Alternatively delete the partition in dskmgmt.msc or with diskpart. Failing that you can use DD to DD over beginning of the disk to start with a clean slate.

some flashdisk if failed/mulfunction it become read only…

you can read post here

I followed any of the suggested howtos, with no result.
Moreover, any diagnostics I did run confirmed the drive is write-protected.
Further, when I started a backup copy of the whole drive, some file read errors appeared.
I’m about to think the drive is damaged indeed, and this is totally unrelated to the read-only usage in Haiku.

1 Like

That’s unlikely. But the read errors would seem to indicate the drive has had it…

ChipGenius detected a Phison controller onto the drive, and two Phison utilities confirm it is now write-protected, being not able to unlock or revert this.
Well, most of the files are now safe on a different drive and this is what I care the most.
The USB drive was a present by a bunch of friends and it has served me well since 2014 but… failures happen!
Anyway, thank you all for your support, even if Haiku was not really involved, I really appreciate it.
Sorry for the buzz!

1 Like