USB stick write protect

visionhelp

Active Member
Joined
Oct 18, 2023
Messages
122
Reaction score
33
Credits
1,270
(With Search not found. Perhaps in other words. With a note I can post there.
If anybody is curious, I began this topic there (if OK), but stopping it there now http://gparted-forum.surf4.info/viewtopic.php?id=18153)

It appears, it is ´just´ a big topic.
In hope this exchange must not be overloaded, if there is a solution, which works - solves - for all this possible trouble.
Diskpart does not help, GParted not, Linux commands not ...
Stick is being messaged as Read-only.
I post a dosfsck report, in some minutes:

(Sorry, CODE OK, or what please ?)
Code:
Gerät      Boot   Anfang     Ende Sektoren Größe Kn Typ
/dev/sdd1  *        2048 60022783 60020736 28,6G  7 HPFS/NTFS/exFAT
/dev/sdd2       60022784 60088319    65536   32M ef EFI (FAT-12/16/32)
knoppix@Microknoppix:/media/sdb2$ sudo dosfsck -a -v /dev/sdd
fsck.fat 3.0.28 (2015-05-16)
open: Das Dateisystem ist nur lesbar
knoppix@Microknoppix:/media/sdb2$ sudo dosfsck -a -v /dev/sdd1
fsck.fat 3.0.28 (2015-05-16)
Logical sector size is zero.
knoppix@Microknoppix:/media/sdb2$ sudo dosfsck -a -v /dev/sdd2
fsck.fat 3.0.28 (2015-05-16)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "mkfs.fat"
Media byte 0xf8 (hard disk)
       512 bytes per logical sector
       512 bytes per cluster
         1 reserved sector
First FAT starts at byte 512 (sector 1)
         2 FATs, 16 bit entries
    130048 bytes per FAT (= 254 sectors)
Root directory starts at byte 260608 (sector 509)
       512 root directory entries
Data area starts at byte 276992 (sector 541)
     64995 data clusters (33277440 bytes)
63 sectors/track, 255 heads
         0 hidden sectors
     65536 sectors total
Reclaiming unconnected clusters.
/dev/sdd2: 1015 files, 55570/64995 clusters
knoppix@Microknoppix:/media/sdb2$ sudo dosfsck -a -v /dev/sdd
fsck.fat 3.0.28 (2015-05-16)
open: Das Dateisystem ist nur lesbar
 
Last edited:


Stick is being messaged as Read-only.

There's a non-zero chance that the device is broken. Not all USB thumb drives are made equal and some fail pretty quickly.
 
I have had some luck "recovering" USB Thumb drives.

If the data is important, and you can copy it off, make a backup. At least temporarily.
Note some of the commands can lock up your screen. They won't hurt your computer,
but the command might lock up the terminal, so it's a good idea to have two terminals open
so you can kill the process in the other terminal. But keep in mind, some of these commands
can take literally hours to complete.

The first think I usually try is fsck. This may not work depending on what file system you formatted the disk with.

fsck -y /dev/sdX
testdisk /dev/sdX


The second thing I usually try is to rebuild the partition table. sfdisk is a little different from fdisk.

sfdisk /dev/sdX

or

blockdev --rereadpt /dev/sdX

If I can't save the existing parition tables, I try to make a new one from scratch.

fdisk /dev/sdX
g
w


The g creates a GPT partition table, the w writes it to the disk.
You can also use o and w. o creates a MBR type partition table.
It has happened ( very rarely ) that gdisk will work, but I generally have better luck with fdisk.

If none of the steps above work, I then try to dd a known good image to the disk.
This will resize your thumb drive into a smaller device.

dd if=/path/to/mydistro.iso of=/dev/sdX

* NOTE!! * Make absolutely sure that the image you are burning to the USB drive, is actually smaller
than the capacity of the USB drive, otherwise this will create other problems.

I normally use the ibs= and obs= options to speed up burning the images, but if you have a bad USB drive
I would recommend not using these flags while you are trying to recover it.
The gotcha here is, if you have a 16GB or 23GB thumb drive, and you burn a 4GB image to it, now it's effectively
a 4GB USB drive. But it's better than throwing it away.

Finally if nothing else works, try zero'ing out the drive. It there are bad sectors this can take a long time,
( I had a 64GB drive take nearly 5 hours ).

dd if=/dev/zero of=/dev/sdX bs=1G count=31
The good news is, the usually maps any bad sector(s) out.
Notice the "count" flag at the end here. I always use one GB smaller than the advertized size.

For example for a 32GB drive, I use 31GB, for a 64GB drive, I use 63, for 128GB, I use 127, etc...
This is because many USB drives are slightly smaller than the advertized size. It this works, you can
experiment and try increasing the size. For example if 31GB isn't close enough for you, and you want
to try to get 31.5GB, you can try something like...

dd if=/dev/zero of=/dev/sdX bs=1M count=31972

But this can take hours and hours or even and days and days of experimenting to find the best size.

If none of this works... well then you can have a paperweight. Toss it in the trash, it's probably done.
 
sudo dosfsck -a -v /dev/sdd2
Hi, dos2unix. Thanks these lots.
I am working at it the last days. Did You see the "sudo dosfsck -a -v /dev/sdd2" report added in my first post here ?

Currently I am mad doing those jobs.
(2 terminals windows do not help, without knowing to stop a running command.)
Many commands are not possible just from the read-only limited.
Even the ´dd zero´, reducing the size - with count - will not help this.

days and days of experimenting

This can be reduced to for example 16 or 10. It is about to get rid of the read-only.
And this will not.

Did try them. Testdisk is interessting. But all says read-only access.
Next try EaseUS Partition Master Free.
(Here seems to be solutions, but with a *.zip-file with (as attachment there), but not to download. Weired.)
 
Last edited:
2 terminals windows do not help, without knowing to stop a running command.

That is a very good point, maybe @KGIII will do an article on this.
The quick and dirty way to do this is...

lets say you typed a command like fsck or dd
Then in the second console windows, to find it, you would type...

ps -ef | grep dd

or

ps -ef | grep fsck

That will give some output similar to this...

root@tower2:~# ps -ef | grep fsck
root 6970 6725 0 12:23 pts/1 00:00:00 fsck -y /dev/sda1
root 6971 6970 70 12:23 pts/1 00:00:19 fsck.exfat -y /dev/sda1

Even though I only typed in the fsck command one time, some commands spawn sub-processes under them.
In this case, my process ID is '6970'. It spawned a sub-process. It automatically figured out that my disk
eas formatted with exfat. So it automatically started the fsck with the exfat flag for me. So there is another
process with ID '6971'. Note: every single time you run these commands, the process ID will be different.

On the second line, I see a parent process and a child process. 6970 is the parent process.
6971 is the child process. The way I can kill the parent process is like this.

kill 6970

Sometimes processes are stubborn and get hung, kill doesn't always work.
So then you can use the -9 flag.

kill -9 6970

That almost always works.
 
Next try EaseUS
Did not also.

dd if=/dev/zero of=/dev/sdX
Instead of zero could try an *iso-file, smaller than 10 GB or so (the free space there). I have a 60 MB file. But without hope. (But not more now.)

I know exact the origin of this error.
I booted the Ventoy stick, with the Win10-iso on it, for to repair a Win10 ´Bootloader missing´ error.
To this I had to use as last the diskpart (Win10) command ´bcdboot´, but instead of using only to the c: drive, I decided to use ´All´, without any thinking about. This is the point since then this stick does not boot anymore.
(Oh, to mention: the repaired Win10 runs again.)

Thanks the companion.

"(But not more now.)": does not do it, too.)
 
Last edited:
Is this freeware tool known perhaps ?

That sounds like a take on DBAN.

Given a choice and a need, I'd stick with DBAN. They don't have a for-profit motive. The software is free as in beer and free as in liberty. It has also been around for quite a while.
 
They don't have a for-profit motive.

It does seem that by clicking on the link you provided above, they are trying to sell us something. :)
 
are trying to sell
Sorry, at least this is there free, I did not check THIS; (the question was, is it known, sorry)
:
1701714271057.png
 
It does seem that by clicking on the link you provided above, they are trying to sell us something. :)

LOL I'd completely forgotten (I'm sort of remembering it now, but only because someone mentioned it a while back) that they'd added that and didn't actually check the link.

My bad.

I'd still try DBAN first.

Does this mean, in some Linux-variants it is already included with ?
I can really not keep in mind, whether Knoppix or Mint Mate is based on Debian or what, sorry.

It's a dedicated disk image that you can burn. You run DBAN as a live system.

HOWEVER...

DBAN has changed since I last reviewed it and I didn't click through the link. My bad. I probably should have looked.

I doubt you need the pro features and DBAN has existed for a long time but, again, they've changed since I last reviewed their site and now have a for-profit motive.
 
I can really not keep in mind, whether Knoppix or Mint Mate is based on Debian or what, sorry.
It's because you insist on a Linux OS based on Debian but with an outdated file system, and other things that would force you more often than not to bid for v11 "Bullseye" or earlier, rather than later. A few things are moving into "glibc" version/release which could be handled by v12 "Bookworm" base but not v11 "Bullseye" anymore. You might be better off moving on to Linux Mint based on Debian (LMDE).

Now about the subject at hand, I bought a Sandisk Ultra Trek 32GB for about 20USD. About a year later the thing just failed on me, giving me write speeds of less than 1MiB per second. This was only using it on Windows10, a couple of years before I gained Internet access again. I also always plugged it into "SuperSpeed" port of my cheap laptop so that I lost any faith in USB v3 being faster or better than v2.
 
you insist on a Linux OS based on Debian but with an outdated file system
Currently is from interesst, when a Linux variant would have this active killdisk. (Or a similar function, which could be able to handle this.)
And anybody who knows - perhaps - this could help this stick write protect.

Oh, sorry: (https://en.wikipedia.org/wiki/Darik's_Boot_and_Nuke) "DBAN, is a free and open-source project hosted on SourceForge. The program is designed to securely erase a hard disk", now I understand, thank You.

OK, but does a lot not, but now not knowing what would be from meaning: https://dban.org/
 
Last edited:
OK. Active KillDisk looked good. But some functions still in the version not for private.
The free version does not help the problem.

Thanks the companion.
 
Last edited:
Why do you need to wipe a disk to that degree ?
 
The free version does not help the problem.
Sorry, this needs to be told more exact:
The wipe function did begin to work, but with showing a progress-bar for more then some minutes staying at 1 % I did stop this first, because of I had to expect more hours to finish.
And with no hope: this solves the ´read-only´ protection equal with.
I bought now a 32 GB stick for 6.- Euro, for to be able to continue my urgent works, where this stick is at the moment an urgent requirement.
(Despite it looks as a very super professional tool, with that very super high prices. But even not at all for private. Thee unlimited version.)
But I will try again, when I have some space for it.
 


Latest posts

Top