Bonjour Debian.
On m’a chargé de trouver un moyen de récupérer un lot de clés Dell MentorMedia u02-003 qui ne sont plus utiles.
Je trouve plein de réponses sur le Canard mais la plupart des guides sur « comment formater une clé protégée en écriture » sont du genre « faire fdisk /dev/sdX » et ignorent complètement le fait que la clé est protégée en écriture et que donc ni fdisk, ni mkfs ni gparted ne marchent.
J’ai trouvé https://askubuntu.com/questions/101637/usb-turn-write-protection-off et tenté la procédure :
Angel’s answer is good, but the actual commands weren’t so easy for me. This is what worked : Plug in the card (mine is an SD card with a manual write-protect switch on it, but the switch is off and it is writable on a Windows machine). Ubuntu mounted it automatically on /media/andrew/6AB0-1FD91, and dmesg showed the partition to be /dev/sdb1.
Unmount it, and make it writeable
```
sudo umount /dev/sdb1
sudo hdparm -r0 /dev/sdb
```
Create a new mount point and mount it there (my userID from /etc/passwd is 1000)
```
sudo mkdir /media/andrew/temp
sudo mount -o uid=1000 /dev/sdb1 /media/andrew/temp
```
it'll still complain that it's read-only. I don't know why I had to change this flag before AND after mounting, but that's the only way it worked for me. Set it to writeable again, and remount it at the same place
```
sudo hdparm -r0 /dev/sdb1
sudo mount -o remount,rw /dev/sdb1
```
Now I can write to the disk as my normal user. I'm being very careful with it in case it is actually failing, but those commands allowed me to finish what I was doing.
Et ça semble marcher mais en fait ça marche pas (rm -rf ne renvoie aucune erreur mais un ls montre que le fichier est encore là).
J’ai pas tenté celle-là :
1) Plug in the USB device and do an `lsusb` , example:
```
$ lsusb
Bus 002 Device 012: ID 0781:5583 SanDisk Corp.
```
2) Take note of those two codes between the colon (called the `idVendor` and `idProduct` ). Unplug the USB device.
3) Remove the `usb_storage` kernel module (assuming it's compiled as a module)
```
$ sudo modprobe -r $(lsmod | sed -n 's:,: :g ; s,^usb_storage[ 0-9]*,,p') usb_storage
```
4) Now we will put the module back in using a quirks mode setting to override the detection of the device's write-only flag.
From [source/drivers/usb/storage/usb.c#L572](https://elixir.bootlin.com/linux/v4.19/source/drivers/usb/storage/usb.c#L572) taken from v4.19 you can see that the quirks mode setting we're looking for is `w` . Here's how we'll reload the kernel module:
```
$ sudo modprobe usb_storage quirks=0781:5583:w
```
Replace the numbers between the colons with the ones your saw in step (1) from above.
5) plug the usb storage device back in. We can now confirm with dmesg that this worked:
notamment parce que j’ai d’autres trucs branchés en usb et que donc le modprobe est refusé.
Par ailleurs je trouve https://www.quora.com/How-do-I-remove-write-protection-from-a-Dell-Windows-10-pen-drive?share=1 sur des modèles similaires qui renvoie sur https://www.dell.com/community/Storage-Drives-Media/Unable-to-format-Dell-USB/td-p/4659496/page/2 dont tous les liens sont morts et sur https://edge2.blogspot.com/2017/03/how-to-disable-write-protection-on-dell.html qui utilise des logiciels Windows.
Je suis étonné qu’en root il n’y aie pas moyen de faire ce que l’on veut ?
Est-ce qu’il y a une méthode que je n’ai pas trouvée ?