A USB memory stick became Read only, can it be reversed to writable ?
- Reply: Bertrand Petit : "Re: A USB memory stick became Read only, can it be reversed to writable ?"
- Reply: Warner Losh : "Re: A USB memory stick became Read only, can it be reversed to writable ?"
- Reply: Tomek CEDRO : "Re: A USB memory stick became Read only, can it be reversed to writable ?"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 13 Dec 2025 00:55:18 UTC
Hi usb@FreeBSD.org
I have used 2 identical usb memory sticks for years, one just went
Read only, not from any command issued. They have no write protect switch.
Maybe Read Only came from a static discharge. (Sticks were sold
with name Platinum, have aluminium shells, & I wear mostly synthetic
clothing so some static in North hemisphere winter. Question is
whether it can be set back to Read-Write ?
All 4 slices on 1 of the 2 16G sticks became read only.
12.4-RELEASE dmesg:
The bad stick:
kernel: da0 at umass-sim0 bus 0 scbus5 target 0 lun 0
kernel: da0: < USB DISK 2.0 PMAP> Removable Direct Access SPC-2 SCSI device
kernel: da0: Serial Number 070B3114C022D211
kernel: da0: 40.000MB/s transfers
kernel: da0: 14786MB (30283008 512 byte sectors)
kernel: da0: quirks=0x3<NO_SYNC_CACHE,NO_6_BYTE>
kernel: da0: Write Protected
The good stick:
kernel: da0 at umass-sim0 bus 0 scbus5 target 0 lun 0
kernel: da0: < USB DISK 2.0 PMAP> Removable Direct Access SPC-2 SCSI device
kernel: da0: Serial Number 070B3C9A27828828
kernel: da0: 40.000MB/s transfers
kernel: da0: 14786MB (30283008 512 byte sectors)
kernel: da0: quirks=0x3<NO_SYNC_CACHE,NO_6_BYTE>
Filesystem Size Used Avail Capacity Mounted on
/dev/da0s1 4.3G 1.9G 2.5G 43% /media/platinum.dos
/dev/da0s2a 8.3G 1.5G 6.8G 18% /media/platinum.os
/dev/da0s3.bde 2.4G 2.1G 114M 95% /media/platinum.ufs
/dev/da0s4 135k 8.2k 119k 6% /media/platinum.end
Is there a command to clear a Write Protect state ?
Maybe ctladm, or sysctl ? I've tried camcontrol :
On the bad stick I see:
camcontrol inquiry da0
pass3: < USB DISK 2.0 PMAP> Removable Direct Access SPC-2 SCSI device
pass3: Serial Number 070B3114C022D211
pass3: 40.000MB/s transfers
camcontrol readcap da0 # Last Block: 30283007, Block Length: 512 bytes
camcontrol defects da0 -f block # 0 defects
camcontrol defects da0 -f longblock # 0 defects
camcontrol defects da0 -f bfi # 0 defects
camcontrol defects da0 -f extbfi # 0 defects
camcontrol defects da0 -f phy # 0 defects
camcontrol defects da0 -f phys # 0 defects
camcontrol defects da0 -f extphys # 0 defects
camcontrol defects da0 -f block -G # camcontrol: Error returned from read defect data command
camcontrol defects da0 -f block -G # camcontrol: Error returned from read defect data command
camcontrol defects da0 -f longblock -G # camcontrol: Error returned from read defect data command
camcontrol defects da0 -f bfi -G # camcontrol: Error returned from read defect data command
camcontrol defects da0 -f extbfi -G # camcontrol: Error returned from read defect data command
camcontrol defects da0 -f phys -G # camcontrol: Error returned from read defect data command
camcontrol defects da0 -f extphys -G # camcontrol: Error returned from read defect data command
camcontrol defects da0 -f block -P # camcontrol: Error returned from read defect data command
camcontrol defects da0 -f longblock -P # camcontrol: Error returned from read defect data command
camcontrol defects da0 -f bfi -P # camcontrol: Error returned from read defect data command
camcontrol defects da0 -f extbfi -P # camcontrol: Error returned from read defect data command
camcontrol defects da0 -f phys -P # camcontrol: Error returned from read defect data command
camcontrol defects da0 -f extphys -P # camcontrol: Error returned from read defect data command
camcontrol attrib da0 -r attr_values # nothing
camcontrol attrib da0 -r attr_list # nothing
camcontrol attrib da0 -r part_list # nothing
camcontrol attrib da0 -r supp_attr # nothing
camcontrol opcodes da0 # nothing
camcontrol hpa da0
camcontrol: ATA ATA_IDENTIFY via pass_16 failed
camcontrol: ATA ATAPI_IDENTIFY via pass_16 failed
camcontrol modepage da0 -l # 0x05 Flexible Disk
camcontrol modepage da0 -l -l # 0x05 Flexible Disk
all of {
camcontrol modepage da0 -m 5
camcontrol modepage da0 -m 5 -P 0
camcontrol modepage da0 -m 5 -P 1
camcontrol modepage da0 -m 5 -P 2
camcontrol modepage da0 -m 5 -P 3
} produce identical:
Transfer rate: 61440
Number of heads: 255
Sectors per track: 32
Data bytes per sector: 512
Number of cylinders: 3711
Starting cylinder-write precompensation: 0
Starting cylinder-reduced write current: 0
Drive step rate: 0
Drive step pulse width: 0
Head settle delay: 0
Motor on delay: 0
Motor off delay: 0
TRDY: 0
SSN: 0
MO: 0
SPC: 0
Write Compensation: 0
Head load delay: 0
Head unload delay: 0
Pin 34: 0
Pin 2: 0
Pin 4: 0
Pin 1: 0
Medium rotation rate: 0
/usr/share/misc/scsi_modes
0x05 "Flexible Disk"
left me puzzled with uncommented TRDY SSN MO
but didnt obviousky appear to be a read/write V. read only switch.
camcontrol format da0
You are about to REMOVE ALL DATA from the following device:
pass3: < USB DISK 2.0 PMAP> Removable Direct Access SPC-2 SCSI device
pass3: Serial Number 070B3114C022D211
pass3: 40.000MB/s transfers
Are you SURE you want to do this? (yes/no) yes
Current format timeout is 10800 seconds
Enter new timeout in seconds or press
return to keep the current timeout [10800]
Format Complete
camcontrol format da0 -r
Format Complete
fdisk da0
******* Working on device /dev/da0 *******
parameters extracted from in-core disklabel are:
cylinders=1885 heads=255 sectors/track=63 (16065 blks/cyl)
Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=1885 heads=255 sectors/track=63 (16065 blks/cyl)
Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 12 (0x0c),(DOS or Windows 95 with 32 bit FAT (LBA))
start 8064, size 8409996 (4106 Meg), flag 0
beg: cyl 0/ head 128/ sector 1;
end: cyl 523/ head 254/ sector 63
The data for partition 2 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
start 8418060, size 16771860 (8189 Meg), flag 80 (active)
beg: cyl 524/ head 0/ sector 1;
end: cyl 543/ head 254/ sector 63
The data for partition 3 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
start 25189920, size 5092605 (2486 Meg), flag 0
beg: cyl 544/ head 0/ sector 1;
end: cyl 860/ head 254/ sector 63
The data for partition 4 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
start 30282525, size 483 (0 Meg), flag 0
beg: cyl 861/ head 0/ sector 1;
end: cyl 861/ head 7/ sector 42
fsck -t msdosfs /dev/da0s1
Unplugged & replugged
ls -1 /dev/da*
/dev/da0
/dev/da0s1
/dev/da0s2
/dev/da0s2a
/dev/da0s3
/dev/da0s4
reboot
dmesg:
da0 at umass-sim0 bus 0 scbus5 target 0 lun 0
da0: < USB DISK 2.0 PMAP> Removable Direct Access SPC-2 SCSI device
da0: Serial Number 070B3114C022D211
da0: 40.000MB/s transfers
da0: 14786MB (30283008 512 byte sectors)
da0: quirks=0x3<NO_SYNC_CACHE,NO_6_BYTE>
(da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 00 81 11 1c 00 00 08 00
(da0:umass-sim0:0:0:0): CAM status: SCSI Status Error
(da0:umass-sim0:0:0:0): SCSI status: Check Condition
(da0:umass-sim0:0:0:0): SCSI sense: DATA PROTECT asc:27,0 (Write protected)
(da0:umass-sim0:0:0:0): Error 13, Unretryable error
(da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 01 ce 13 cd 00 00 08 00
(da0:umass-sim0:0:0:0): CAM status: SCSI Status Error
(da0:umass-sim0:0:0:0): SCSI status: Check Condition
(da0:umass-sim0:0:0:0): SCSI sense: DATA PROTECT asc:27,0 (Write protected)
(da0:umass-sim0:0:0:0): Error 13, Unretryable error
bsdlabel -w /dev/da0
bsdlabel: cannot open provider /dev/da0 for writing label: Read-only file system
bsdlabel: Try to use gpart(8)
I can still read the data on it. If there's not something else to
try with FreeBSD, I could try plugging into a Microsoft box, & see
if MS offers to format (I expect it would, but might then fail).
Cheers,
--
Julian Stacey http://berklix.org/jhs/mail/ gmail & yahoo block replies.
Arm Ukraine. Contraception & plain text email V. global warming.