【Linux】Ubuntu 18.04安装libudev-dev失败

最近在编译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 udev.service: Unit systemd-udevd.service is not loaded properly: Exec format error.
See system logs and 'systemctl status udev.service' for details.
invoke-rc.d: initscript udev, action "restart" failed.
● systemd-udevd.service - 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:systemd-udevd.service(8)
           man:udev(7)
 Main PID: 611 (systemd-udevd)
   Status: "Processing with 24 children at max"
    Tasks: 1 (limit: 15842)
   CGroup: /system.slice/systemd-udevd.service
           └─611 /lib/systemd/systemd-udevd

Jun 26 11:05:01 t systemd[1]: systemd-udevd.service: Cannot add dependency job, ignoring: Unit systemd-udevd.service is not loaded properly: Exec format error.
Jun 26 11:06:26 t systemd[1]: systemd-udevd.service: Got notification message from PID 611, but reception is disabled.
Jun 26 11:06:57 t systemd[1]: /lib/systemd/system/systemd-udevd.service:26: Executable path is not absolute: udevadm control --reload --timeout 0
Jun 26 11:06:57 t systemd[1]: systemd-udevd.service: Cannot add dependency job, ignoring: Unit systemd-udevd.service is not loaded properly: Exec format error.
Jun 26 11:06:57 t systemd[1]: systemd-udevd.service: Cannot add dependency job, ignoring: Unit systemd-udevd.service is not loaded properly: Exec format error.
Jun 26 11:06:57 t systemd[1]: /lib/systemd/system/systemd-udevd.service:26: Executable path is not absolute: udevadm control --reload --timeout 0
Jun 26 11:06:57 t systemd[1]: systemd-udevd.service: Cannot add dependency job, ignoring: Unit systemd-udevd.service is not loaded properly: Exec format error.
Jun 26 11:06:57 t systemd[1]: systemd-udevd.service: Cannot add dependency job, ignoring: Unit systemd-udevd.service is not loaded properly: Exec format error.
Jun 26 11:06:57 t systemd[1]: /lib/systemd/system/systemd-udevd.service:26: Executable path is not absolute: udevadm control --reload --timeout 0
Jun 26 11:06:57 t systemd[1]: systemd-udevd.service: Cannot add dependency job, ignoring: Unit systemd-udevd.service 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 udev.service: Unit systemd-udevd.service 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 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 udev amd64 237-3ubuntu10.48 [1,103 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libudev1 amd64 237-3ubuntu10.48 [58.0 kB]
Get:3 http://cn.archive.ubuntu.com/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/initrd.img-5.4.0-74-generic

Done! 问题修复!!

总结

在Ubuntu下对于切换源带来方便的同时一定要注意安装软件过程的问题. 在这里就遇到了安装libudev-dev失败导致的系统死机的问题.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值