如何解除U盘的写保护(或只读)?

如何解除U盘的写保护(或只读)?

我的朋友给了我他的 4 GB USB 闪存盘,因为他无法格式化、删除或复制任何内容。驱动器现在是空的。但我似乎无法解决写保护问题。

Windows 无法格式化磁盘并显示“设备已写保护”。所以我决定从linux上解决这个问题。

我也无法从 linux 解决这个问题。驱动器插入后会自动安装,但由于写保护,我无法对其执行任何操作。

dmesg | tail插入闪存盘瞬间的输出:

$ dmesg | tail
[ 2753.654864] usb-storage 1-1.4:1.0: USB Mass Storage device detected
[ 2753.655207] scsi host4: usb-storage 1-1.4:1.0
[ 2754.668623] scsi 4:0:0:0: Direct-Access     Generic  Flash Disk       8.00 PQ: 0 ANSI: 4
[ 2754.671050] sd 4:0:0:0: [sdd] 8192000 512-byte logical blocks: (4.19 GB/3.91 GiB)
[ 2754.672208] sd 4:0:0:0: [sdd] Write Protect is off
[ 2754.672214] sd 4:0:0:0: [sdd] Mode Sense: 23 00 00 00
[ 2754.673417] sd 4:0:0:0: [sdd] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 2754.690210]  sdd: sdd1
[ 2754.694654] sd 4:0:0:0: [sdd] Attached SCSI removable disk
[ 2755.154487] FAT-fs (sdd1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

然后,我运行gnome-disk-utility并尝试格式化驱动器。 10-20秒后,我明白了

Error formatting volume
Error synchronizing after initial wipe: Timed out waiting for object (udisks-error-quark, 0)

再次运行dmesg | tail给出:

$ dmesg | tail
[ 3157.475963] sd 4:0:0:0: [sdd] tag#0 CDB: opcode=0x2a 2a 00 00 00 08 00 00 00 08 00
[ 3157.475967] blk_update_request: critical target error, dev sdd, sector 2048
[ 3157.475977] Buffer I/O error on dev sdd1, logical block 0, lost async page write
[ 3157.477033] sd 4:0:0:0: [sdd] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[ 3157.477039] sd 4:0:0:0: [sdd] tag#0 Sense Key : 0x7 [current] 
[ 3157.477044] sd 4:0:0:0: [sdd] tag#0 ASC=0x27 ASCQ=0x0 
[ 3157.477049] sd 4:0:0:0: [sdd] tag#0 CDB: opcode=0x2a 2a 00 00 00 08 00 00 00 08 00
[ 3157.477052] blk_update_request: critical target error, dev sdd, sector 2048
[ 3157.477058] Buffer I/O error on dev sdd1, logical block 0, lost async page write
[ 3157.549308] VFS: Dirty inode writeback failed for block device sdd1 (err=-5).

尝试使用 GParted 检查驱动器的分区并得到

GParted 0.27.0 --enable-libparted-dmraid --enable-online-resize

Libparted 3.2

Check and repair file system (fat32) on /dev/sdd1  00:00:00    ( ERROR )

calibrate /dev/sdd1  00:00:00    ( SUCCESS )

path: /dev/sdd1 (partition)
start: 2048
end: 8191999
size: 8189952 (3.91 GiB)
check file system on /dev/sdd1 for errors and (if possible) fix them  00:00:00    ( ERROR )

fsck.fat -a -w -v /dev/sdd1  00:00:00    ( ERROR )

fsck.fat 4.0 (2016-05-06)
open: Read-only file system
libparted messages    ( INFO )

Unable to open /dev/sdd read-write (Read-only file system). /dev/sdd has been opened read-only.
Unable to open /dev/sdd read-write (Read-only file system). /dev/sdd has been opened read-only.

现在,demsg | tail显示

[ 3363.006200] sd 4:0:0:0: [sdd] Write Protect is on
[ 3363.006208] sd 4:0:0:0: [sdd] Mode Sense: 23 00 80 00
[ 3363.008312]  sdd: sdd1

我尝试使用 GParted 将驱动器的唯一分区重新格式化为 FAT32(分区已经是 FAT32),并收到 Libparted 错误:

Can't write to /dev/sdd, because it is opened read-only.

进而

GParted 0.27.0 --enable-libparted-dmraid --enable-online-resize

Libparted 3.2

Format /dev/sdd1 as fat32  00:01:32    ( ERROR )

calibrate /dev/sdd1  00:00:00    ( SUCCESS )

path: /dev/sdd1 (partition)
start: 2048
end: 8191999
size: 8189952 (3.91 GiB)
clear old file system signatures in /dev/sdd1  00:01:32    ( ERROR )

write 512.00 KiB of zeros at byte offset 0  00:01:32    ( ERROR )
libparted messages    ( INFO )

Unable to open /dev/sdd read-write (Read-only file system). /dev/sdd has been opened read-only.
Unable to open /dev/sdd read-write (Read-only file system). /dev/sdd has been opened read-only.
Unable to open /dev/sdd read-write (Read-only file system). /dev/sdd has been opened read-only.
Unable to open /dev/sdd read-write (Read-only file system). /dev/sdd has been opened read-only.
Unable to open /dev/sdd read-write (Read-only file system). /dev/sdd has been opened read-only.
Can't write to /dev/sdd, because it is opened read-only.
Can't write to /dev/sdd, because it is opened read-only.
Can't write to /dev/sdd, because it is opened read-only.

还尝试删除当前分区并创建新分区,但出现相同的错误。

闪存盘上没有硬件开关。我也尝试过使用,hdparm但没有任何效果:

$ sudo hdparm -r0 /dev/sdd

/dev/sdd:
 setting readonly to 0 (off)
 readonly      =  0 (off)

关于闪存盘的一些信息:

$ sudo fdisk /dev/sdd
Welcome to fdisk (util-linux 2.28.2).                                                                                                   
Changes will remain in memory only, until you decide to write them.                                                                     
Be careful before using the write command.


Command (m for help): i

Selected partition 1
         Device: /dev/sdd1
           Boot: *
          Start: 2048
            End: 8191999
        Sectors: 8189952
      Cylinders: 508
           Size: 3.9G
             Id: c
           Type: W95 FAT32 (LBA)
    Start-C/H/S: 1023/255/63
      End-C/H/S: 1023/255/63
          Attrs: 80

另外,fsck给我

$ sudo fsck /dev/sdd
fsck from util-linux 2.28.2
e2fsck 1.43.3 (04-Sep-2016)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/sdd

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
    e2fsck -b 32768 <device>

/dev/sdd contains `DOS/MBR boot sector; partition 1 : ID=0xc, active, start-CHS (0x3ff,255,63), end-CHS (0x3ff,255,63), startsector 2048, 8189952 sectors' data

$ sudo fsck /dev/sdd1
fsck from util-linux 2.28.2
fsck.fat 4.0 (2016-05-06)
open: Read-only file system

当我fsck重新插入驱动器后,我得到了

$ sudo fsck /dev/sdd1
fsck from util-linux 2.28.2
fsck.fat 4.0 (2016-05-06)
0x41: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
1) Remove dirty bit
2) No action
? 1
FATs differ but appear to be intact. Use which FAT ?
1) Use first FAT
2) Use second FAT
? 1
Free cluster summary wrong (1021716 vs. really 1021743)
1) Correct
2) Don't correct
? 1
Perform changes ? (y/n) y
/dev/sdd1: 1 files, 1/1021744 clusters

但这似乎并没有改变任何事情。

那么,如何解除U盘的写保护(或只读)呢?

相关内容