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 systemSo /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 1And 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 clustersI 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 1 Answer
Let us point out one set of facts...
The easy way to "fix" a troublesome device, assuming the content doesn't matter:
- boot from any other device.
- do NOT mount anything from the trouble device
- Convince yourself to be 100% sure you're working with the CORRECT
/dev/name,
usinglsblkand pondering on it's output might be enough. - Start a terminal / bash and type
sudo dd if=/dev/zero bs=1M count=1 /dev/nameat 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).