忘了从什么时候开始我的那个512M的SD卡在ubuntu下一挂载就是只读的了,使用root帐户更改权限都不好使,尝试了好多办法也没解决,后来买了个U盘就不再用SD卡了,这件事也就忘记了。

今天突然应急使用这个卡,使用读卡器挂载发现依旧是只读,换用本本内置的读卡器,也是一样。没办法了,google一通,看了看ubuntu的中文论坛,发现有人也遇到了同样的问题,但是没有人给出可行的解决方案。只好看看英文的网站了,果然找到了办法,原文在这

产生这个问题的原因是SD卡的文件系统损坏,操作系统为了防止进一步毁坏文件系统,而将其设置成了只读。检查文件系统的方法如下:

在没挂载SD卡的时候在shell中输入:tail -f /var/log/syslog,查看动态日志文件。

然后插入SD卡,可以看到日志文件的变化,大致如下:

Apr 5 
00:24:59 sagi-laptop kernel: [ 1048.660202] FAT: Filesystem panic (dev 
sdb1) Apr 5 00:24:59 sagi-laptop kernel: [ 1048.660214] invalid access 
to FAT (entry 0x0000b30e) Apr 5 00:24:59 sagi-laptop kernel: [ 
1048.660218] File system has been set read-only Apr 5 00:24:59 
sagi-laptop kernel: [ 1048.676591] FAT: Filesystem panic (dev sdb1) Apr 5
 00:24:59 sagi-laptop kernel: [ 1048.676603] invalid access to FAT 
(entry 0x0000d0c9) Apr 5 00:24:59 sagi-laptop kernel: [ 1048.678906] 
FAT: Filesystem panic (dev sdb1) Apr 5 00:24:59 sagi-laptop kernel: [ 
1048.678916] invalid access to FAT (entry 0x00008522) Apr 5 00:24:59 
sagi-laptop kernel: [ 1048.695071] FAT: Filesystem panic (dev sdb1) Apr 5
 00:24:59 sagi-laptop kernel: [ 1048.695081] invalid access to FAT 
(entry 0x0000e673) Apr 5 00:24:59 sagi-laptop kernel: [ 1048.719951] 
FAT: Filesystem panic (dev sdb1) Apr 5 00:24:59 sagi-laptop kernel: [ 
1048.719965] invalid access to FAT (entry 0x0000d751) Apr 5 00:24:59 
sagi-laptop kernel: [ 1048.818747] FAT: Filesystem panic (dev sdb1) Apr 5
 00:24:59 sagi-laptop kernel: [ 1048.818764] fat_get_cluster: invalid 
cluster chain (i_pos 0) Apr 5 00:24:59 sagi-laptop kernel: [ 
1048.818929] FAT: Filesystem panic (dev sdb1) Apr 5 00:24:59 sagi-laptop
 kernel: [ 1048.818931] invalid access to FAT (entry 0x0000bab9)

可以大致看出是/dev/sdb1也就是usb文件系统出错的消息。
OK,接下来开始修复它:

首先卸载设备,然后输入:sudo dosfsck -v -a /dev/sdb1,检查并修复文件系统。
一长串输出大概如下:

dosfsck 
2.11 (12 Mar 2005) dosfsck 2.11, 12 Mar 2005, FAT32, LFN Checking we can
 access the last sector of the filesystem Boot sector contents: System 
ID " " Media byte 0xf8 (hard disk) 512 bytes per logical sector 16384 
bytes per cluster 1 reserved sector First FAT starts at byte 512 (sector
 1) 2 FATs, 16 bit entries 62976 bytes per FAT (= 123 sectors) Root 
directory starts at byte 126464 (sector 247) 512 root directory entries 
Data area starts at byte 142848 (sector 279) 31312 data clusters 
(513015808 bytes) 63 sectors/track, 16 heads 233 hidden sectors 1002263 
sectors total /DcOo CS1.6.rar and /Music share clusters. Truncating 
second to 180387840 bytes. Reclaiming unconnected clusters. Reclaimed 
10723 unused clusters (175685632 bytes) in 1 chain. Performing changes. 
/dev/sdb1: 166 files, 25779/31312 clusters

说明已经检查完毕,重新插上SD卡试试吧,应该已经可以写入了。

Logo

更多推荐