Ubuntu Linux下 "failed to initialize hal"错误解决办法

在Ubuntu Linux下,有不少朋友遇到“failed to initialize hal”错误。
这个错误最直接的表现是:在启动时弹出提示框告诉用户“failed to initialize hal”
这个错误将间接导致一些即插即用硬件使用错误。
比如:网卡本来是即插即用的,你拨掉网线、网络就会不可用,当你再插上网上,系统应该自动恢复网络。但如果出现上述错误就不会这样了。
又比如:U盘和移动硬盘本来是即插即用的,你一插上U盘就会在桌面上显示一个U盘符号并显示卷名称。但如果出现上述错误,就会表现为U盘或移动硬盘不能自动挂载。

出现上述原因的根本在于系统服务dbus和hal的启动顺序。
Ubuntu Linux中采用dbus+hal来管理即插即用设备,关于具体工作方式,大家可以自己用 google搜索一下。
关键要知道的一点就是dbus服务必须在hal之前启动,否则hal就会启动失败。

大多数Linux系统中,所有服务都在/etc/init.d目录下有个启动脚本程序,比如:
acpid checkroot.sh hostname.sh mountdevsubfs.sh readahead udev-finish
acpi-support clamav-freshclam hotkey-setup mountkernfs.sh readahead-desktop umountfs
alsa-utils consolekit hwclockfirst.sh mountnfs-bootclean.sh README umountnfs.sh
anacron console-screen.sh hwclock.sh mountoverflowtmp reboot umountroot
apmd console-setup keyboard-setup mtab.sh rmnologin urandom
apparmor cron killprocs networking rsync usplash
apport cupsys klogd nvidia-kernel screen vbesave
atd dbus laptop-mode pcmciautils sendsigs vmware
avahi-daemon dhcdbd libpam-foreground powernowd single waitnfs.sh
bluetooth dns-clean linux-restricted-modules-common powernowd.early skeleton wpa-ifupdown
bootclean gdm loopback pppd-dns stop-bootlogd x11-common
bootlogd glibc.sh makedev procps.sh stop-bootlogd-single xserver-xorg-input-wacom
bootmisc.sh hal module-init-tools rc stop-readahead
brltty halt mountall-bootclean.sh rc.local sysklogd
checkfs.sh hdparm mountall.sh rcS udev

对于不同的启动级别(比如级别N)需要启动的服务,在/etc/rcN.d目录下有相应的链接指向/etc/init.d目录下相应的脚本,比如:
lrwxrwxrwx 1 root root 13 2007-12-24 22:28 gdm30S -> ../init.d/gdm
lrwxrwxrwx 1 root root 18 2008-01-18 21:21 K08vmware -> /etc/init.d/vmware
-rw-r--r-- 1 root root 556 2007-10-04 19:17 README
lrwxrwxrwx 1 root root 17 2007-12-24 22:28 S05vbesave -> ../init.d/vbesave
lrwxrwxrwx 1 root root 25 2007-12-24 22:28 S10powernowd.early -> ../init.d/powernowd.early
lrwxrwxrwx 1 root root 34 2007-12-24 22:28 S10xserver-xorg-input-wacom -> ../init.d/xserver-xorg-input-wacom
lrwxrwxrwx 1 root root 14 2007-12-24 19:33 S12dbus -> ../init.d/dbus
lrwxrwxrwx 1 root root 13 2007-12-24 22:28 S12hal -> ../init.d/hal
lrwxrwxrwx 1 root root 22 2007-12-24 22:28 S18avahi-daemon -> ../init.d/avahi-daemon
lrwxrwxrwx 1 root root 26 2008-01-18 21:12 S20clamav-freshclam -> ../init.d/clamav-freshclam
lrwxrwxrwx 1 root root 17 2007-12-24 22:28 S20makedev -> ../init.d/makedev
lrwxrwxrwx 1 root root 23 2007-12-24 22:28 S20nvidia-kernel -> ../init.d/nvidia-kernel
lrwxrwxrwx 1 root root 15 2007-12-24 22:28 S20rsync -> ../init.d/rsync
lrwxrwxrwx 1 root root 20 2007-12-24 22:28 S22consolekit -> ../init.d/consolekit
lrwxrwxrwx 1 root root 16 2007-12-24 22:28 S24dhcdbd -> ../init.d/dhcdbd
lrwxrwxrwx 1 root root 15 2008-01-19 16:58 S50acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root 20 2008-01-19 16:56 S50alsa-utils -> ../init.d/alsa-utils
lrwxrwxrwx 1 root root 17 2008-01-19 16:58 S50anacron -> ../init.d/anacron
lrwxrwxrwx 1 root root 14 2008-01-19 16:58 S50apmd -> ../init.d/apmd
lrwxrwxrwx 1 root root 13 2008-01-19 16:58 S50atd -> ../init.d/atd
lrwxrwxrwx 1 root root 16 2008-01-19 16:58 S50brltty -> ../init.d/brltty
lrwxrwxrwx 1 root root 16 2008-01-19 16:58 S50cupsys -> ../init.d/cupsys
lrwxrwxrwx 1 root root 13 2008-01-18 21:00 S50gdm -> ../init.d/gdm
lrwxrwxrwx 1 root root 16 2008-01-19 16:57 S50hdparm -> ../init.d/hdparm
lrwxrwxrwx 1 root root 22 2008-01-19 16:57 S50hotkey-setup -> ../init.d/hotkey-setup
lrwxrwxrwx 1 root root 15 2008-01-19 16:57 S50klogd -> ../init.d/klogd
lrwxrwxrwx 1 root root 19 2008-01-19 16:58 S50powernowd -> ../init.d/powernowd
lrwxrwxrwx 1 root root 18 2008-01-19 16:57 S50sysklogd -> ../init.d/sysklogd
lrwxrwxrwx 1 root root 14 2007-12-24 22:28 S89cron -> ../init.d/cron
lrwxrwxrwx 1 root root 18 2008-01-18 21:21 S90vmware -> /etc/init.d/vmware
lrwxrwxrwx 1 root root 17 2007-12-24 22:28 S98usplash -> ../init.d/usplash
lrwxrwxrwx 1 root root 22 2007-12-24 22:28 S99acpi-support -> ../init.d/acpi-support
lrwxrwxrwx 1 root root 21 2007-12-24 22:28 S99laptop-mode -> ../init.d/laptop-mode
lrwxrwxrwx 1 root root 18 2007-12-24 22:28 S99rc.local -> ../init.d/rc.local
lrwxrwxrwx 1 root root 19 2007-12-24 22:28 S99rmnologin -> ../init.d/rmnologin
lrwxrwxrwx 1 root root 24 2007-12-24 22:28 S99stop-readahead -> ../init.d/stop-readahead

这里S开头的服务将在启动时加载,S后面的数字代表了服务的启动顺序,数字小的服务将在数字大的服务之前启动,比如S90vmware服务将在S90usplash之前启动。之后再按字母顺序启动各服务。

出现“failed to initialize hal”错误就是因为hal服务在dbus之前启动。可能为:
S12hal S50dbus


要纠正这一错误,只需要把dbus前面的S50改成比hal前面的S12小或相等就可以了。比如:
sudo mv S50dbus S12dbus

你可能感兴趣的:(Ubuntu Linux下 "failed to initialize hal"错误解决办法)