Re: USB flash drive opens read only -- how to fix?

2019-10-03 Thread tomas
On Thu, Oct 03, 2019 at 07:30:19AM +0200, Pascal Hambourg wrote:

[...]

> On the contrary. The usb-storage module has a parameter "quirks"
> which allows to ignore the write-protect flag for a specific vid:pid
> device (I do not remember the exact syntax). I was afraid that it
> could be used to by-pass the write-protect switch so I tested it
> with my only flash drive with a write-protect switch on. Although
> the kernel considered the drive as writable, any write attempt
> resulted to an error.

Ah, that's interesting... now one could imagine a bug in the flash
drive "OS", where it says "no, you can't write me" but accepts and
performs write commands...

> It is my understanding that Tomas meant that the write-protect
> switch does not cut the transmission of the electrical write signal
> to the flash memory chips and that the USB mass storage protocol
> also includes rejecting write commands, not only advertising the
> write-only flag.

Thanks, you put my (as usual) babblings into actually intelligible
words :-)

Cheers
-- tomás


signature.asc
Description: Digital signature


Re: USB flash drive opens read only -- how to fix?

2019-10-02 Thread Pascal Hambourg

Le 03/10/2019 à 05:05, David Christensen a écrit :

On 10/1/19 11:51 PM, to...@tuxteam.de wrote:

Yep. Never forget -- there's a whole computer with its own OS in
your flash drive. That "write protect" (sometimes) available as a
physical switch is just communicated to your drivers via some
protocol over USB.

(...)
It was my expectation that the write-protect switch is read by the flash 
drive controller, and that the flash drive controller will enforce 
read-only behavior (e.g. prohibiting writes).  Do you have information 
indicating otherwise?


On the contrary. The usb-storage module has a parameter "quirks" which 
allows to ignore the write-protect flag for a specific vid:pid device (I 
do not remember the exact syntax). I was afraid that it could be used to 
by-pass the write-protect switch so I tested it with my only flash drive 
with a write-protect switch on. Although the kernel considered the drive 
as writable, any write attempt resulted to an error.


It is my understanding that Tomas meant that the write-protect switch 
does not cut the transmission of the electrical write signal to the 
flash memory chips and that the USB mass storage protocol also includes 
rejecting write commands, not only advertising the write-only flag.




Re: USB flash drive opens read only -- how to fix?

2019-10-02 Thread David Christensen

On 10/1/19 11:51 PM, to...@tuxteam.de wrote:

Yep. Never forget -- there's a whole computer with its own OS in
your flash drive. That "write protect" (sometimes) available as a
physical switch is just communicated to your drivers via some
protocol over USB.


I have two such drives, both old and small (128 MB).  But, I have 
contemplated buying new drives with the write protect switch.  For example:


https://www.kanguru.com/storage-accessories/kanguru-ss3.shtml


It was my expectation that the write-protect switch is read by the flash 
drive controller, and that the flash drive controller will enforce 
read-only behavior (e.g. prohibiting writes).  Do you have information 
indicating otherwise?



David



Re: USB flash drive opens read only -- how to fix?

2019-10-02 Thread David Wright
On Wed 02 Oct 2019 at 10:06:21 (-0400), Ken Heard wrote:
> On 2019-10-01 11:03 p.m., David Christensen wrote:
> 
> > I have read that some USB flash drives will revert to read-only
> > mode when they detect an internal error.
> 
> Makes sense I suppose, but in a negative way. I did not know that
> flash drives (some? all?) do have this feature.
> 
> > This gives the user a chance to copy out their data.
> 
> I would have had to do so if the data there I needed to keep.
> 
> > My limited experience with failing USB flash drives is that they go
> > from read-write to read-only to useless in a matter of minutes or
> > seconds.
> 
> Strange.  I had two other flash drives fail at about the same time;
> both I was able to resuscitate with luksformat. Neither of those had
> the ro marker.

“All happy families are alike; each unhappy family is unhappy in its own way.”
Leo Tolstoy, Anna Karenina (1878)

Cheers,
David.



Re: USB flash drive opens read only -- how to fix?

2019-10-02 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2019-10-02 2:51 a.m., to...@tuxteam.de wrote, in part:

> Yep. Never forget -- there's a whole computer with its own OS in 
> your flash drive. That "write protect" (sometimes) available as a 
> physical switch is just communicated to your drivers via some 
> protocol over USB.

Interesting point.  So it is likely a permanent hardware failure after
all.

Ken

-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXZSvcQAKCRCU2UnM6QmZ
N8P0AJ0bUEKWkFA3+jK7BDN5nOIEo9TwlgCfZJdf7QYj2vVh449m9F0HZnqmTiI=
=JF3Z
-END PGP SIGNATURE-



Re: USB flash drive opens read only -- how to fix?

2019-10-02 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2019-10-01 11:03 p.m., David Christensen wrote:

> I have read that some USB flash drives will revert to read-only
> mode when they detect an internal error.

Makes sense I suppose, but in a negative way. I did not know that
flash drives (some? all?) do have this feature.

> This gives the user a chance to copy out their data.

I would have had to do so if the data there I needed to keep.

> My limited experience with failing USB flash drives is that they go
> from read-write to read-only to useless in a matter of minutes or
> seconds.

Strange.  I had two other flash drives fail at about the same time;
both I was able to resuscitate with luksformat. Neither of those had
the ro marker.

> What happens if you insert the USB drive into a Windows machine and
> try to format it (cancel out before doing the actual format)?
> macOS? FreeBSD?  Other?

I will have to try using it with other versions of the Turing machine
as soon as I have access to same.

Ken



-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXZSu1wAKCRCU2UnM6QmZ
N1n+AJ9Nixu4KhokPJNYbDES+fGakzDCiQCfWYa9G038uQMwB81/rD1f0BpQdOE=
=ml+2
-END PGP SIGNATURE-



Re: USB flash drive opens read only -- how to fix?

2019-10-01 Thread tomas
On Tue, Oct 01, 2019 at 08:03:50PM -0700, David Christensen wrote:

[...]

> >How could this drive be physically protected from writing to it when
> >there is no switch on the drive itself to unable (or release) such
> >physical protection?
> >
> >Regards, Ken
> 
> I have read that some USB flash drives will revert to read-only mode
> when they detect an internal error [...]

Yep. Never forget -- there's a whole computer with its own OS in
your flash drive. That "write protect" (sometimes) available as a
physical switch is just communicated to your drivers via some
protocol over USB.

Cheers
-- t


signature.asc
Description: Digital signature


Re: USB flash drive opens read only -- how to fix?

2019-10-01 Thread David Christensen

On 10/1/19 4:32 PM, Ken Heard wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2019-10-01 5:33 p.m., Pascal Hambourg wrote:

Le 01/10/2019 à 23:09, Ken Heard a écrit :


- - after unmounting and closing encryption running as root
'wipefs -a -f /dev/sdd' returns 'wipefs: error: /dev/sdd: probing
initialization failed: Read-only file system'.


The USB flash drive is probably physically write-protected. Check
the kernel logs juste after inserting it for confirmation.


Here are the kern.log entries created the most recent time this drive:

Oct  1 19:25:21 SOL kernel: [28463.821015] usb 9-4: new SuperSpeed USB
device number 15 using xhci_hcd
Oct  1 19:25:21 SOL kernel: [28463.844007] usb 9-4: New USB device
found, idVendor=0951, idProduct=1666
Oct  1 19:25:21 SOL kernel: [28463.844010] usb 9-4: New USB device
strings: Mfr=1, Product=2, SerialNumber=3
Oct  1 19:25:21 SOL kernel: [28463.844012] usb 9-4: Product:
DataTraveler 3.0
Oct  1 19:25:21 SOL kernel: [28463.844014] usb 9-4: Manufacturer: Kingst
on
Oct  1 19:25:21 SOL kernel: [28463.844016] usb 9-4: SerialNumber:
000AEB91EC07BD41230C0068
Oct  1 19:25:21 SOL kernel: [28463.845810] usb-storage 9-4:1.0: USB
Mass Storage device detected
Oct  1 19:25:21 SOL kernel: [28463.845973] scsi host9: usb-storage 9-4:1
.0
Oct  1 19:25:23 SOL kernel: [28464.861194] scsi 9:0:0:0: Direct-Access
 Kingston DataTraveler 3.0 PMAP PQ: 0 ANSI: 6
Oct  1 19:25:23 SOL kernel: [28464.861817] sd 9:0:0:0: [sdd] 61226496
512-byte logical blocks: (31.3 GB/29.2 GiB)
Oct  1 19:25:23 SOL kernel: [28464.862088] sd 9:0:0:0: [sdd] Write
Protect is off
Oct  1 19:25:23 SOL kernel: [28464.862090] sd 9:0:0:0: [sdd] Mode
Sense: 45 00 00 00
Oct  1 19:25:23 SOL kernel: [28464.862248] sd 9:0:0:0: Attached scsi
generic sg4 type 0
Oct  1 19:25:23 SOL kernel: [28464.862365] sd 9:0:0:0: [sdd] Write
cache: disabled, read cache: enabled, doesn't support DPO or FUA
Oct  1 19:25:23 SOL kernel: [28465.042599] sd 9:0:0:0: [sdd] Write
Protect is on
Oct  1 19:25:23 SOL kernel: [28465.042604] sd 9:0:0:0: [sdd] Mode
Sense: 45 00 80 00
Oct  1 19:25:23 SOL kernel: [28465.043086] sd 9:0:0:0: [sdd] Attached
SCSI removable disk
Oct  1 19:25:37 SOL kernel: [28479.639563] EXT4-fs (dm-7): mounting
ext2 file system using the ext4 subsystem
Oct  1 19:25:37 SOL kernel: [28479.642175] EXT4-fs (dm-7): mounted
filesystem without journal. Opts: (null)

One entry says that Write protect is off, but a later entry says that
is is on.

How could this drive be physically protected from writing to it when
there is no switch on the drive itself to unable (or release) such
physical protection?

Regards, Ken


I have read that some USB flash drives will revert to read-only mode 
when they detect an internal error.  This gives the user a chance to 
copy out their data.  My limited experience with failing USB flash 
drives is that they go from read-write to read-only to useless in a 
matter of minutes or seconds.



What happens if you insert the USB drive into a Windows machine and try 
to format it (cancel out before doing the actual format)?  macOS? 
FreeBSD?  Other?



David



Re: USB flash drive opens read only -- how to fix?

2019-10-01 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2019-10-01 5:33 p.m., Pascal Hambourg wrote:
> Le 01/10/2019 à 23:09, Ken Heard a écrit :
>> 
>> - - after unmounting and closing encryption running as root
>> 'wipefs -a -f /dev/sdd' returns 'wipefs: error: /dev/sdd: probing
>> initialization failed: Read-only file system'.
> 
> The USB flash drive is probably physically write-protected. Check
> the kernel logs juste after inserting it for confirmation.

Here are the kern.log entries created the most recent time this drive:

Oct  1 19:25:21 SOL kernel: [28463.821015] usb 9-4: new SuperSpeed USB
device number 15 using xhci_hcd
Oct  1 19:25:21 SOL kernel: [28463.844007] usb 9-4: New USB device
found, idVendor=0951, idProduct=1666
Oct  1 19:25:21 SOL kernel: [28463.844010] usb 9-4: New USB device
strings: Mfr=1, Product=2, SerialNumber=3
Oct  1 19:25:21 SOL kernel: [28463.844012] usb 9-4: Product:
DataTraveler 3.0
Oct  1 19:25:21 SOL kernel: [28463.844014] usb 9-4: Manufacturer: Kingst
on
Oct  1 19:25:21 SOL kernel: [28463.844016] usb 9-4: SerialNumber:
000AEB91EC07BD41230C0068
Oct  1 19:25:21 SOL kernel: [28463.845810] usb-storage 9-4:1.0: USB
Mass Storage device detected
Oct  1 19:25:21 SOL kernel: [28463.845973] scsi host9: usb-storage 9-4:1
.0
Oct  1 19:25:23 SOL kernel: [28464.861194] scsi 9:0:0:0: Direct-Access
Kingston DataTraveler 3.0 PMAP PQ: 0 ANSI: 6
Oct  1 19:25:23 SOL kernel: [28464.861817] sd 9:0:0:0: [sdd] 61226496
512-byte logical blocks: (31.3 GB/29.2 GiB)
Oct  1 19:25:23 SOL kernel: [28464.862088] sd 9:0:0:0: [sdd] Write
Protect is off
Oct  1 19:25:23 SOL kernel: [28464.862090] sd 9:0:0:0: [sdd] Mode
Sense: 45 00 00 00
Oct  1 19:25:23 SOL kernel: [28464.862248] sd 9:0:0:0: Attached scsi
generic sg4 type 0
Oct  1 19:25:23 SOL kernel: [28464.862365] sd 9:0:0:0: [sdd] Write
cache: disabled, read cache: enabled, doesn't support DPO or FUA
Oct  1 19:25:23 SOL kernel: [28465.042599] sd 9:0:0:0: [sdd] Write
Protect is on
Oct  1 19:25:23 SOL kernel: [28465.042604] sd 9:0:0:0: [sdd] Mode
Sense: 45 00 80 00
Oct  1 19:25:23 SOL kernel: [28465.043086] sd 9:0:0:0: [sdd] Attached
SCSI removable disk
Oct  1 19:25:37 SOL kernel: [28479.639563] EXT4-fs (dm-7): mounting
ext2 file system using the ext4 subsystem
Oct  1 19:25:37 SOL kernel: [28479.642175] EXT4-fs (dm-7): mounted
filesystem without journal. Opts: (null)

One entry says that Write protect is off, but a later entry says that
is is on.

How could this drive be physically protected from writing to it when
there is no switch on the drive itself to unable (or release) such
physical protection?

Regards, Ken




-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXZPiFQAKCRCU2UnM6QmZ
N5LyAJ90ESCk5g0fJa6tnqPeCClmjhXX+wCfb7feHPTKEm6dkAxOpb1yT8nU5VA=
=3RCx
-END PGP SIGNATURE-



Re: USB flash drive opens read only -- how to fix?

2019-10-01 Thread Pascal Hambourg

Le 01/10/2019 à 23:09, Ken Heard a écrit :


- - after unmounting and closing encryption running as root 'wipefs -a -f
   /dev/sdd' returns 'wipefs: error: /dev/sdd: probing initialization
   failed: Read-only file system'.


The USB flash drive is probably physically write-protected.
Check the kernel logs juste after inserting it for confirmation.



USB flash drive opens read only -- how to fix?

2019-10-01 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Messieurs et mesdames:

Command 'mount' returns among other things the following two lines:

/dev/mapper/fde on /media/fde type ext2\
(rw,nosuid,nodev,noexec,noatime,block_validity,barrier,user_xattr,acl)

/dev/mapper/fdc on /media/fdc type ext2\
(ro,nosuid,nodev,noexec,noatime,block_validity,barrier,user_xattr,acl)

The first line above (divided into two here) is what 'mount' shows for
all my encrypted USB flash drives when opened -- they are all opened
with 'rw'.

The second lino above is what is shown for only one of my incrypted
USB flash drives; it opens with 'ro'.  When this drive is opened and
mounted the message returned is 'mount: /dev/mapper/fdc is
write-protected, mounting read-only'.

This situation is very strange.  Something somewhere causes this drive
to be opened 'ro' instead of the 'rw' specified for this mount point
in file /etc/fstab.

Not only can I not find out where I cannot find a way make this drive
'rw'. It is consequently useless.  Among the workarounds I tried are:

- - the commands 'sudo chmod' to change permissions.  (I own the
  directories and files in the drive.)

- - after dismounting the drive but keeping the encryption open running
 'sudo mount -o remount,rw /media/fdc' which returns the same message
  mentioned above: 'mount: /dev/mapper/fdc is write-protected, mounting
  read-only'.

- - after unmounting and closing encryption running as root 'wipefs -a -f
  /dev/sdd' returns 'wipefs: error: /dev/sdd: probing initialization
  failed: Read-only file system'.

- - 'sudo luksformat -t ext2' /dev/sdd after going through the
  preliminaries returns 'Could not create LUKS device /dev/sdd
  at /usr/sbin/luksformat line 91,  line 30'

- - 'sudo mkfs.ext2 /dev/sdd' after asking if I really want to go ahead
   with this command returns '/dev/sdd: Read-only file system while
   setting up superblock'.

After some on line searches it appears that to regain use of this
flash drive (it contains no essential data) I will have to go through
several steps to erase LUKS and then use the 'dd' command to wipe the
drive clean.  I am still afraid to use that command because of the
potential damage that can be caused by one or more bad 'if' and 'of'
settings if there is not an easier way.  Does anyone here know of one?
 In any event I would surely know how this situation would arise in
the first place.

Regards, Ken Heard

-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXZPAiAAKCRCU2UnM6QmZ
N5HJAJ9S/haC6nE8/EkuhXtCETZimi8mzQCeO7BmV2pKWO4TuPMkcJTH/71nMDY=
=04oO
-END PGP SIGNATURE-