sdcard损坏

参考

  • 磁盘分区管理和坏道修复
    Linux 命令大全
    (badblocks,fsck,cfdisk命令在一些嵌入式设备中无效)
    使用badblocks命令检测、修复硬盘坏道
    linux 中fdisk 和 mkfs.vfat命令的使用总结

过程

  • mount sdcard出错,df出现“error -110 transferring data”
~ # mount /dev/mmcblk0p1 /app/sd/
FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
~ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                16384     10904      5480  67% /
devtmpfs                 53608         4     53604   0% /dev
hisd_irq:1867: R/W CMD18 error, qstat:0x90020 rstat:0x204
mmc0: req failed (CMD18) cmd 0 data -110 cmd resp:900
mmcblk0: error -110 transferring data, sector 8628, nr 114, cmd response 0x900, card status 0x0
mmc0: error, req abort
blk_update_request: I/O error, dev mmcblk0, sector 8628
hisd_irq:1867: R/W CMD17 error, qstat:0x20e0020 rstat:0x204
mmc0: req failed (CMD17) cmd 0 data -110 cmd resp:900
mmcblk0: error -110 transferring data, sector 8628, nr 1, cmd response 0x900, card status 0x0
mmc0: error, req abort
blk_update_request: I/O error, dev mmcblk0, sector 8628
FAT-fs (mmcblk0p1): FAT read failed (blocknr 436)
df: /app/sd: Input/output error
~ # umount /app/sd/

已损坏,没救了,换卡吧
注意
别把sdcard插到电脑操作
插入pc会把电脑文件管理器搞崩了。
插入ubuntu会把虚拟机搞崩了(我差点导致虚拟机损坏,最后搞半天才解决)。

不想换?
那就往下看

  • mkfs.vfat /dev/mmcblk0p1
~ # himci: card disconnected!
mmc0: card e624 removed
himci: card connected!
mmc0: cannot verify signal voltage switch
himci: tuning mmc0: valid phase shift [9, 6] Final Phase 15
mmc0: new ultra high speed SDR104 SDHC card at address aaaa
mmcblk0: mmc0:aaaa SM16G 14.8 GiB 
 mmcblk0: p1

~ # mkfs.vfat /dev/mmcblk0p1 
hisd_irq:1867: R/W CMD18 error, qstat:0x20e0020 rstat:0x22c
mmc0: req failed (CMD18) cmd 0 data -110 cmd resp:900
mmcblk0: error -110 transferring data, sector 24752, nr 8, cmd response 0x900, card status 0x0
mmc0: error, req abort
blk_update_request: I/O error, dev mmcblk0, sector 24752
mkfs.vfat: short write
~ # mount /dev/mmcblk0p1 /app/sd/
~ # mount
rootfs on / type rootfs (rw)
proc on /proc type proc (rw,nosuid,nodev,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,relatime)
/dev/mmcblk0p1 on /app/sd type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
~ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                16384     10864      5520  66% /
devtmpfs                 53608         4     53604   0% /dev
/dev/mmcblk0p1        15538864        32  15538832   0% /app/sd
~ # fdisk -l
...
Disk /dev/mmcblk0: 15.9 GB, 15931539456 bytes
255 heads, 63 sectors/track, 1936 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

        Device Boot      Start         End      Blocks  Id System
/dev/mmcblk0p1               1        1937    15554048   c Win95 FAT32 (LBA)

能正常挂载,ls查看乱码。
并且在电脑上可以识别,但是磁盘中文件乱码,之前的数据全部丢失。

  • mkfs.ext4 /dev/mmcblk0p1
~ # mkfs.ext4 /dev/mmcblk0p1 
mke2fs 1.42.13 (17-May-2015)
/dev/mmcblk0p1 contains a ext2 file system
        last mounted on Thu Jan  1 00:55:37 1970
Proceed anyway? (y,n) y
Creating filesystem with 3888512 4k blocks and 972944 inodes
Filesystem UUID: dc554589-c474-40cf-8681-d3568bd3afa9
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

~ # mount /dev/mmcblk0p1 /app/sd/
EXT4-fs (mmcblk0p1): couldn't mount as ext3 due to feature incompatibilities
EXT4-fs (mmcblk0p1): couldn't mount as ext2 due to feature incompatibilities
EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
~ # mount
rootfs on / type rootfs (rw)
proc on /proc type proc (rw,nosuid,nodev,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,relatime)
/dev/mmcblk0p1 on /app/sd type ext4 (rw,relatime,data=ordered)
~ # ls /app/sd/
lost+found
~ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                16384     10856      5528  66% /
devtmpfs                 53608         4     53604   0% /dev
/dev/mmcblk0p1        15178708     37984  14346640   0% /app/sd
~ # umount /app/sd/

磁盘为空,看着好像还是把磁盘清空了。

  • 卸载掉插电脑看一下
    电脑上半天没有反应,多插几次后在文件管理器列表中看到了盘符,激动(差点又以为搞挂文件管理器了)。
    点击盘符提示需要格式化,按提示来。
    格式化后就可以正常使用了,磁盘是空的。
    插入设备中查看
~ # mount
rootfs on / type rootfs (rw)
proc on /proc type proc (rw,nosuid,nodev,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,relatime)
/dev/mmcblk0p1 on /app/sd type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
~ # 

应该是在电脑上格式化时,被改成了vfat格式了。
以上方法会把整个卡格式化掉,里面的数据都会被清空。不清楚是否有更好的方法进行修复,希望知道的告知一下。
另外,格式化过的损坏sdcard,运行一段时间后又损坏了,说明此方法只能应急时使用,并不能完全解决问题。

你可能感兴趣的:(sdcard损坏)