dpkg和perl的依赖环境出现错误故障解决,磁盘原因

内核:

uname -a

Linux localhost.localdomain 3.4.29-t4 #12 Wed Mar 13 16:50:15 EST 2013 armv7l armv7l armv7l GNU/Linux

dpkg安装应用时遇到问题,提示运行apt-get -f install修复依赖。

apt-get -f install 后提示如下:

debconf: Perl may be unconfigured (Can't locate Debconf/Log.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at (eval 1) line 4.

BEGIN failed--compilation aborted at (eval 1) line 4.

从上面信息看@INC本身并没有什么变化。

既然不能找到Debconf/Log.pm,就安装一下看看,结果perl -MCPAN -e shell “install Debconf::Log” 也出现错误。那到底问题在哪呢?

忽然想起前些天曾在CPAN更新新版perl过程中出现网络中断安装失败,之后又删除了更新半截的~/perl5目录。难道是perl 被错误的switch到一个不存在的路径了?回看了一下@INC并没有我那天删除的那个安装目录。于是想~干脆新装一个perl试试。(最终结果证实这段尝试是一段弯路,不需要安装新版本的朋友可以跳过这段标记=cut......cut的部分)

=cut

安装新的perl,又不想费掉原来的环境,那就做版本共存吧。

实现多个perl版本共存最好的工具是perlbrew,具体操作步骤在我的另外一篇日志里有提到,有不了解perlbrew的朋友,具体可访问http://blog.asiulo.com/post-9.html.

这个安装时间会比较的长,但不需要值守。

装好后记得看下log,没有问题再做switch。具体可参考http://blog.asiulo.com/post-9.html中的流程。

继续之前的apt-get -f install,问题依旧,这个实验倒是证明了我的猜想,既不是版本发生switch的问题,那问题会在哪里呢?

还是仔细再检查下原来的perl环境吧,于是乎执行下列操作切换回旧版perl

source /opt/perl5/perlbrew/etc/bashrc

perlbrew switch-off

cut

perl -V 重新查看perl的详细信息,还是没有发现什么问题。最后我开始把注意力放到了perl的@INC环境变量上。

我开始ls查看他们,

perl -e 'print join "\n",@INC'|awk '{print "ls -l",$0}'|sh

在/usr/share/perl5/发现了问题:

ls: cannot access /usr/share/perl5/Algorithm: Input/output error

ls: cannot access /usr/share/perl5/Net: Input/output error

ls: cannot access /usr/share/perl5/Text: Input/output error

ls: cannot access /usr/share/perl5/Time: Input/output error

ls: cannot access /usr/share/perl5/Debconf: Input/output error

ls: cannot access /usr/share/perl5/Date: Input/output error

ls: cannot access /usr/share/perl5/Debian: Input/output error

ls: cannot access /usr/share/perl5/HTML: Input/output error

ls: cannot access /usr/share/perl5/Class: Input/output error

ls: cannot access /usr/share/perl5/Bundle: Input/output error

ls: cannot access /usr/share/perl5/Git: Input/output error

ls: cannot access /usr/share/perl5/Error: Input/output error

原来是磁盘出现了问题!

dmesg查看了一下系统信息,也发现了nand flash提示CRC校验错误(我把/usr mount到这里了)。

由于是实验环境,以及时间的关系,我最终没有进行fsck.ext4的检查与修复,而是重做了系统,把出现过错误的那块磁盘挂成了备盘。

至此结案!