3

I think I have pre-maturely ejected USB during a write operation. Currently I'm trying to use this USB image to write another USB image to it, so whether all the data gets erased from it does not matter.

Whenever I try to dd disk with zeroes, or do any other operation I get error similar to the following:

$ sudo dd if=/dev/zero of=/dev/sdb bs=4096
dd: failed to open '/dev/sdb': Read-only file system

So /dev/sdb (USB) has some problems.

Furthermore, fstab displays remount-ro, indicating that there is some filesystem inconsistency on the drive.

UUID=xxxx        /           ext4    errors=remount-ro 0       1

And when I run fsck on /dev/sdb,

$ sudo fsck -fn /dev/sdb1
fsck from util-linux 2.34
fsck.fat 4.1 (2017-01-24)
0x41: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
 Automatically removing dirty bit.
There are differences between boot sector and its backup.
This is mostly harmless. Differences: (offset:original/backup)
  3:53/6d, 4:59/6b, 5:53/66, 6:4c/73, 7:49/2e, 8:4e/66, 9:55/61, 10:58/74

  ----- about 30 lines of diff emitted -----

Not automatically fixing this.
/sources/install.wim
  File size is 1655058432 bytes, cluster chain length is > 1655062528 bytes.
  Truncating file to 1655058432 bytes.
Free cluster summary wrong (1643786 vs. really 1642747)
  Auto-correcting.
Leaving filesystem unchanged.
/dev/sdb1: 1086 files, 249673/1892420 clusters

I somewhat understand what the problem is, but I have no idea what to do to fix it. For starters I don't know why dd would care about filesystem problems on the device.


Update: dmesg

[91449.265958] scsi 5:0:0:0: Direct-Access     ADATA    USB Flash Drive  1100 PQ: 0 ANSI: 4
[91449.266247] sd 5:0:0:0: Attached scsi generic sg2 type 0
[91449.304557] sd 5:0:0:0: [sdb] Attached SCSI removable disk
[91449.304927] sd 5:0:0:0: [sdb] 30310400 512-byte logical blocks: (15.5 GB/14.5 GiB)
[91449.305336] sd 5:0:0:0: [sdb] Write Protect is on
[91449.305338] sd 5:0:0:0: [sdb] Mode Sense: 43 00 80 00
[91449.305768] sdb: detected capacity change from 0 to 30310400
[91449.306875]  sdb: sdb1
6
  • "I'm trying to use this USB image to write another USB image to it" – So you have booted from the USB and want to write zeros to the very same USB? Commented Dec 17, 2021 at 17:35
  • @KamilMaciorowski Correct
    – bumbread
    Commented Dec 17, 2021 at 17:40
  • Did you boot anew after you pre-maturely ejected the USB? Or did you boot, ejected and re-inserted? Commented Dec 17, 2021 at 17:43
  • I ejected it while writing a file to it. I don't remember exactly, but I can't think of any other scenario where such an error could occur. I do remember pulling out a USB while mounted though.
    – bumbread
    Commented Dec 17, 2021 at 17:52
  • [sdb] Write Protect is on that pretty much indicates it's bricked. There might be a slim chance that you can unbrick it by using some utility that toggles the SCSI Write Protect bit, but I doubt you can succeed anyway.
    – Tom Yan
    Commented Dec 18, 2021 at 10:01

1 Answer 1

1

Let us point out one set of facts...

The easy way to "fix" a troublesome device, assuming the content doesn't matter:

  1. boot from any other device.
  2. do NOT mount anything from the trouble device
  3. Convince yourself to be 100% sure you're working with the CORRECT /dev/name,
    using lsblk and pondering on it's output might be enough.
  4. Start a terminal / bash and type
    sudo dd if=/dev/zero bs=1M count=1 /dev/name at the prompt
    Re-Read what you typed at least twice,
    only when you're entrirely sure it is the correct device - press ENTER

This should work, ... assuming that there is no hardware problem (failing flash-based device, or HDD with IO or surface problems).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .