Tag Archives: System crash

[Linux] failed to install libudev dev in Ubuntu 18.04

Recently, when compiling BlueZ source code bluez-5.58, you need to install the dependency library libudev dev.
the log is as follows:

checking for UDEV... no
configure: error: libudev >= 172 is required

The solutions are as follows:

 sudo apt-get install libudev-dev

However, due to the slow download speed of Ubuntu’s default software source, the software source was modified to install libudev dev for Tsinghua’s 20.04 source

The installation process is as follows:

➜  ~ 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)

As can be seen from the above logs, there was a problem with the installation of libudev dev. then I thought it was nothing and ignored it. As a result, the system could not start normally after restart.
later, through log analysis:

Failed to restart udev.service: Unit systemd-udevd.service is not loaded properly: Exec format error.

Guess whether the version of libudev dev does not correspond to the problem, and then remember that the software source was set before for 20.04, so switch to the official default software source and re install it

The installation log is as follows:

➜  ~ 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! Problem fix!!

Summary

In Ubuntu, it is convenient to switch the source. At the same time, we must pay attention to the problems in the process of installing the software. Here we encounter the problem of system crash caused by the failure of installing libudev dev