I just experienced this error during a normal update while using 21.10. The update failed and using apt install --fix-broken systemd-sysv or apt install --fix-broken systemd triggered the error as shown above.
I found that the binary systemd-machine-id-setup, which causes the error was installed two times on my system, in /usr/bin and in /bin. The version in /usr/bin included the dependency on libsystemd-shared-247.so, which is not available. The version in /bin has the correct dependency on libsystemd-shared-248.so. In my PATH /usr/bin is before /bin. After removing /usr/bin/systemd-machine-id-setup I was able to do apt install systemd systemd-sysv When doing this I got additional warnings concerning the binaries: /usr/bin/journalctl /usr/bin/systemd-tmpfiles related to libsystemd-shared-247.so. Again both are available in /usr/ as well and are correct there. So I removed them too. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1952191 Title: package systemd 248.3-1ubuntu8 failed to install/upgrade: installed systemd package post-installation script subprocess returned error exit status 127 To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1952191/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs