0

I have an USB flash drive which is a gift from a company event. It was formatted into two partitions and one of it is locked to read-only. The company includes advertising documents in this partition. I would like to unlock it and return it into one good usb. I tried disk management utility, diskpart in cmd, but failed.

First I tried right-click format disk, and windows repond with "unable to complete the format".

Then I tried disk management utility but failed because of "write-protected usb".

Then I enter diskpart tried "clean", "create partition primary", "attributes disk clear readonly", "format FS=NTFS label=Data quick". "attribute disk" still tells me disk is in "read-only state" and "format" command failed due to media is write-protected.

mrr010
  • 107
  • 2
    Under the hood it may be a USB hub with a flashdrive and (emulated) CD-ROM. Or the firmware of the memory controller inside may not allow you to alter certain areas of the memory. What exact commands/actions did you try? What was the output? How did it fail? Any error messages? Please respond by [edit]ing the question. – Kamil Maciorowski Sep 02 '19 at 10:49

2 Answers2

0

As long as you don't have any sensitive information on the drive, you can boot into a Linux LiveCD, and image the disk with zeros if you want to be hardcore about it with:

sudo dd if=/dev/zero of=/dev/sdX bs=4M status=progress

Where X is the number of your USB drive.

It's also simpler to just format it from a Linux LiveCD using a utility like GParted. Sometimes that does not work, if it doesn't, then it is best to just do the above.

If you do decide to format the drive with zeros, create a new partition table (GPT is the best) and create a new FAT32 (best for portability) partition or a new NTFS (if you're only using it for Windows) partition.

  • tried GParted, it says "cant write because opened read only" – mrr010 Sep 03 '19 at 13:52
  • Then try dd'ing the entire drive; that works on read-only partitions –  Sep 03 '19 at 14:03
  • dd:failed to open '/dev/sdf': Read-only file system – mrr010 Sep 03 '19 at 14:21
  • Run mount, then unmount any partitions on the drive shown, then dd it again: maybe also use sudo if you haven't been –  Sep 03 '19 at 14:23
  • GDisk doesn't really care too much about mounted partitions, so you may want to use that as well –  Sep 03 '19 at 14:28
  • There is no mount/unmount options for that disk shown in GParted. – mrr010 Sep 03 '19 at 14:50
  • Have you tried running the "sudo mount" command? That lists all the mounted partitions. Unmount from the terminal using "sudo umount /dev/sdXY" Also try using fsck on both partitions. If that doesn't work, try running "sudo hdparm -r0 /dev/sdX" or seeing if there's a hardware switch on the drive preventing writing to the drive. There aren't really any solutions besides that. –  Sep 03 '19 at 14:55
  • I have picture showing before GParted is loaded but not sure if it helps. https://imgur.com/BB8dFgm and this after loaded https://imgur.com/gZJ7yBx – mrr010 Sep 03 '19 at 15:01
  • I tried "sudo mount" but I cant find the partition "/dev/sdf" then I tried "sudo hdparm -r0 /dev/sdf" and here is the output https://imgur.com/jKDi1mq (there is no hardware switch by the way) – mrr010 Sep 03 '19 at 15:15
  • Try creating a different file system. Go do a "sudo mkfs.btrfs /dev/sdf1 -f" and put a new BTRFS file system on there, and if it is successful, then make another NTFS file system with "sudo mkfs.ntfs /dev/sdf1" –  Sep 03 '19 at 16:44
  • "error: unable to open /dev/sdf1 read only file system" – mrr010 Sep 03 '19 at 17:04
  • It is possible that if it's a SanDisk drive, the drive detected a potential "fault" and put itself on write-protect mode. Try Googling your flash drive model and see if it has that problem. It could be a permanent one-time switch that makes it unwritable. I would only say that because the kernel claims that the whole device is unwriteable, not just the partition. –  Sep 03 '19 at 21:41
  • It is sticked with a company name as a gift. I tried take away the casing but the pcb board has no sign for its manufacturer. But I can write in /dev/sdg which is the same usb device but the second partition. – mrr010 Sep 04 '19 at 07:34
  • That's quite odd; if there's a completely different device letter, that only means that there's two USB drives rather than partitions. It could possibly be that the second part that you can't write to is a CDROM emulator like Kamil said above in response to your question. –  Sep 04 '19 at 13:27
0

if it's ready only, you can't format in anyway, but there's a trick and that's your chance if it works or not. I tried it and it worked for me on my Sony 16GB flash drive.most times usb get "ready only" if it's pulled out without ejecting properly or safely removing it from your OS.this enables hardware write protection of your usb. To remove this, plug usb and unplug it fast! yeah same wrong action should be repeated! remove not safely.hope in this way the write protection will be disabled.then go to formatting process through command line! good luck

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – Community Sep 23 '22 at 04:03