本篇教程引用并改进自:Upgrade systemd on Ubuntu 18.04
使用ansible执行任务时报错FAILED! => {"changed": false, "msg": "Service is in unknown state", "status": {}}
后搜索得知是245.4版本的systemd有bug,参考如下:
sudo apt-get install build-essestial devscripts python3-pip cmake libssl-dev libpcre2-dev libsystemd0:amd64
sudo -H pip3 install --target=/usr/bin --upgrade meson==0.54.0
pip3 install --user meson==0.54.0
sudo reboot
注意:
- 原教程中没有指定0.54.0,但是在 ubuntu20.04中安装的meson版本是0.56.2,与接下来的操作不兼容
sudo sed -e 's/# deb-src/deb-src' -i /etc/apt/sources.list
sudo apt-get --fix-missing -y
注意:若系统已经换成了阿里源,则只需要执行上述第二个命令即可
sudo apt build-dep systemd
截止2021-02-01 systemd最新版为247.1
mkdir systemd
cd systemd
wget -c http://archive.ubuntu.com/ubuntu/pool/main/s/systemd/systemd_247.1.orig.tar.gz
wget -c http://archive.ubuntu.com/ubuntu/pool/main/s/systemd/systemd_247.1-4ubuntu1.debian.tar.xz
wget -c http://archive.ubuntu.com/ubuntu/pool/main/s/systemd/systemd_247.1-4ubuntu1.dsc
官方资源地址:http://archive.ubuntu.com/ubuntu/pool/main/s/systemd/
cd systemd
tar xvzf systemd_247.1.orig.tar.gz
cd systemd-stable-247.1
tar xvJf ../systemd_247.1-4ubuntu1.debian.tar.xz
dpkg-buildpackage -us -uc -d
cd systemd
ll | grep deb
mkdir -v systemd-247-debs
mv -v *.*deb systemd-247-debs
cd systemd-247-debs
sudo dpkg --auto-deconfigure -i *.deb
sudo reboot
注意:
- 若安装过程中有依赖问题,请先解决依赖
忽略systemd-coredump_245-4ubuntu3.11_amd64.deb
错误
systemd --v
systemd 247 (247.1-4ubuntu1)
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 -ZSTD +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid
重新使用ansible执行有关service的任务时就不再报错了。
“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill
标 题:ubuntu20.04升级systemd