最近在编译BlueZ源码bluez-5.58,需要安装依赖库libudev-dev.
日志如下:
checking for UDEV... no
configure: error: libudev >= 172 is required
查阅了相关资料,解决办法如下:
sudo apt-get install libudev-dev
但由于ubuntu默认的软件源下载速度慢,于是修改了软件源,用来清华的针对20.04的源进行libudev-dev安装.
安装过程如下:
➜ ~ sudo apt-get autoremove libudev-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
libudev-dev linux-hwe-5.4-headers-5.4.0-42 linux-hwe-5.4-headers-5.4.0-72
0 upgraded, 0 newly installed, 3 to remove and 1693 not upgraded.
1 not fully installed or removed.
After this operation, 142 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 234541 files and directories currently installed.)
Removing libudev-dev:amd64 (245.4-4ubuntu3.7) ...
Removing linux-hwe-5.4-headers-5.4.0-42 (5.4.0-42.46~18.04.1) ...
Removing linux-hwe-5.4-headers-5.4.0-72 (5.4.0-72.80~18.04.1) ...
Setting up udev (245.4-4ubuntu3.7) ...
Failed to restart : Unit is not loaded properly: Exec format error.
See system logs and 'systemctl status ' for details.
: initscript udev, action "restart" failed.
● - udev Kernel Device Manager
Loaded: error (Reason: Exec format error)
Active: active (running) since Fri 2021-06-25 17:03:02 CST; 18h ago
Docs: man:(8)
man:udev(7)
Main PID: 611 (systemd-udevd)
Status: "Processing with 24 children at max"
Tasks: 1 (limit: 15842)
CGroup: //
└─611 /lib/systemd/systemd-udevd
Jun 26 11:05:01 t systemd[1]: : Cannot add dependency job, ignoring: Unit is not loaded properly: Exec format error.
Jun 26 11:06:26 t systemd[1]: : Got notification message from PID 611, but reception is disabled.
Jun 26 11:06:57 t systemd[1]: /lib/systemd/system/:26: Executable path is not absolute: udevadm control --reload --timeout 0
Jun 26 11:06:57 t systemd[1]: : Cannot add dependency job, ignoring: Unit is not loaded properly: Exec format error.
Jun 26 11:06:57 t systemd[1]: : Cannot add dependency job, ignoring: Unit is not loaded properly: Exec format error.
Jun 26 11:06:57 t systemd[1]: /lib/systemd/system/:26: Executable path is not absolute: udevadm control --reload --timeout 0
Jun 26 11:06:57 t systemd[1]: : Cannot add dependency job, ignoring: Unit is not loaded properly: Exec format error.
Jun 26 11:06:57 t systemd[1]: : Cannot add dependency job, ignoring: Unit is not loaded properly: Exec format error.
Jun 26 11:06:57 t systemd[1]: /lib/systemd/system/:26: Executable path is not absolute: udevadm control --reload --timeout 0
Jun 26 11:06:57 t systemd[1]: : Cannot add dependency job, ignoring: Unit is not loaded properly: Exec format error.
dpkg: error processing package udev (--configure):
installed udev package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Errors were encountered while processing:
udev
E: Sub-process /usr/bin/dpkg returned an error code (1)
从以上日志可以看出,libudev-dev安装出了问题,然后我以为这个没什么就忽略了,结果系统重启后就无法正常启动了.
后来通过日志分析:
Failed to restart : Unit is not loaded properly: Exec format error.
猜测到是不是libudev-dev的版本不对应导致的问题,然后想起来了之前设置过软件源,用来20.04的,于是切换为了官方默认的软件源,进行重新安装:
安装日志如下:
➜ ~ sudo apt-get install libudev-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-hwe-5.4-headers-5.4.0-42 linux-hwe-5.4-headers-5.4.0-72
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libudev1 udev
The following NEW packages will be installed:
libudev-dev
The following packages will be upgraded:
libudev1 udev
2 upgraded, 1 newly installed, 0 to remove and 126 not upgraded.
Need to get 1,180 kB of archives.
After this operation, 206 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 /ubuntu bionic-updates/main amd64 udev amd64 237-3ubuntu10.48 [1,103 kB]
Get:2 /ubuntu bionic-updates/main amd64 libudev1 amd64 237-3ubuntu10.48 [58.0 kB]
Get:3 /ubuntu bionic-updates/main amd64 libudev-dev amd64 237-3ubuntu10.48 [19.1 kB]
Fetched 1,180 kB in 6s (214 kB/s)
(Reading database ... 234373 files and directories currently installed.)
Preparing to unpack .../udev_237-3ubuntu10.48_amd64.deb ...
Unpacking udev (237-3ubuntu10.48) over (237-3ubuntu10.46) ...
Preparing to unpack .../libudev1_237-3ubuntu10.48_amd64.deb ...
Unpacking libudev1:amd64 (237-3ubuntu10.48) over (237-3ubuntu10.46) ...
Setting up libudev1:amd64 (237-3ubuntu10.48) ...
Selecting previously unselected package libudev-dev:amd64.
(Reading database ... 234373 files and directories currently installed.)
Preparing to unpack .../libudev-dev_237-3ubuntu10.48_amd64.deb ...
Unpacking libudev-dev:amd64 (237-3ubuntu10.48) ...
Setting up udev (237-3ubuntu10.48) ...
update-initramfs: deferring update (trigger activated)
Setting up libudev-dev:amd64 (237-3ubuntu10.48) ...
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
Processing triggers for systemd (237-3ubuntu10.42) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for initramfs-tools (0.130ubuntu3.9) ...
update-initramfs: Generating /boot/-5.4.0-74-generic
Done! 问题修复!!
总结
在Ubuntu下对于切换源带来方便的同时一定要注意安装软件过程的问题. 在这里就遇到了安装libudev-dev失败导致的系统死机的问题.