U盘只读文件系统

Linux下使用U盘时,在没有卸载的情况下擅自拔出U盘后,U盘成为只读文件系统,说下修复的办法。

环境:

OS: Linux  3.9.4-1-ARCH
U盘:FAT32

今天向U盘上拷了文件后,没有卸载就拔了U盘,再插上电脑,稍等片刻时,发现成为只读文件系统。尝试使用sudo chmod a+w /U,显示为只读文件系统。只好查看打印的系统信息

查看系统打印信息:

$ demsg | less

看到如下内容:

[29153.253989] usb 2-1.2.3.3: new full-speed USB device number 40 using ehci-pci
[29153.423524] usb 2-1.2.3.3: not running at top speed; connect to a high speed hub
[29153.431450] scsi20 : usb-storage 2-1.2.3.3:1.0
[29154.435792] scsi 20:0:0:0: Direct-Access     Generic  Flash Disk       8.07 PQ: 0 ANSI: 2
[29154.437255] sd 20:0:0:0: [sdb] 8212480 512-byte logical blocks: (4.20 GB/3.91 GiB)
[29154.438207] sd 20:0:0:0: [sdb] Write Protect is off
[29154.438214] sd 20:0:0:0: [sdb] Mode Sense: 03 00 00 00
[29154.438930] sd 20:0:0:0: [sdb] No Caching mode page present
[29154.438934] sd 20:0:0:0: [sdb] Assuming drive cache: write through
[29154.442123] sd 20:0:0:0: [sdb] No Caching mode page present
[29154.442128] sd 20:0:0:0: [sdb] Assuming drive cache: write through
[29154.473636]  sdb: sdb1
[29154.476380] sd 20:0:0:0: [sdb] No Caching mode page present
[29154.476388] sd 20:0:0:0: [sdb] Assuming drive cache: write through
[29154.476404] sd 20:0:0:0: [sdb] Attached SCSI removable disk
[29155.527602] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[29167.626139] FAT-fs (sdb1): error, fat_get_cluster: invalid cluster chain (i_pos 2111071)
[29167.626143] FAT-fs (sdb1): Filesystem has been set read-only
[29167.626154] FAT-fs (sdb1): error, fat_get_cluster: invalid cluster chain (i_pos 2111071)

写的很明白,被不适当的卸载造成有些数据错误,请使用fsck修复。

使用fsck修复:(sdb1是U盘的分区)

$ sudo fsck -fy /dev/sdb1

含义:肯定回答修复损坏的扇区,保险起见可以不加f与y。

修复后,正常卸载U盘,再插上U盘:

$ dmesg | less

看到:

[29665.364058] usb 2-1.2.3.3: new full-speed USB device number 43 using ehci-pci
[29665.543688] usb 2-1.2.3.3: not running at top speed; connect to a high speed hub
[29665.551693] scsi23 : usb-storage 2-1.2.3.3:1.0
[29666.555758] scsi 23:0:0:0: Direct-Access     Generic  Flash Disk       8.07 PQ: 0 ANSI: 2
[29666.557362] sd 23:0:0:0: [sdb] 8212480 512-byte logical blocks: (4.20 GB/3.91 GiB)
[29666.557984] sd 23:0:0:0: [sdb] Write Protect is off
[29666.557987] sd 23:0:0:0: [sdb] Mode Sense: 03 00 00 00
[29666.558605] sd 23:0:0:0: [sdb] No Caching mode page present
[29666.558608] sd 23:0:0:0: [sdb] Assuming drive cache: write through
[29666.561606] sd 23:0:0:0: [sdb] No Caching mode page present
[29666.561609] sd 23:0:0:0: [sdb] Assuming drive cache: write through
[29666.893013]  sdb: sdb1
[29666.895352] sd 23:0:0:0: [sdb] No Caching mode page present
[29666.895357] sd 23:0:0:0: [sdb] Assuming drive cache: write through
[29666.895361] sd 23:0:0:0: [sdb] Attached SCSI removable disk

打开U盘,可以正常读写了。

(完)

坚持原创技术分享,您的支持将鼓励我继续创作!
0%