35+ stories, thoughts and ideas.35+ stories, thoughts and ideas.


stories, thoughts and ideas.

ubuntu 批量无交互升级大版本

Ubuntu 22.04.1 LTS版本已经发布,手里有一批20.04版本的机器需要升级。

升级方法

  1. 检查必需的软件包

lspci命令为ubuntu升级必需软件包。

 sudo apt install -y pciutils
  1. 升级到当前OS最新版本
sudo apt update
sudo apt upgrade -y 

部分机器可能需要重启

  1. 无交互升级到 ubuntu 22

机器多的时候,使用命令sudo do-release-upgrade -f DistUpgradeViewNonInteractive 无交互升级。
如果遇到下面情况,提示extracting 'jammy.tar.gz'后直接退出,升级过程出错了,需要手动执行sudo do-release-upgrade 观察日志,解决出错的问题。

$ sudo do-release-upgrade -f DistUpgradeViewNonInteractive
Checking for a new Ubuntu release
Get:1 Upgrade tool signature [819 B]                                                                                                                                                                                                  
Get:2 Upgrade tool [1267 kB]                                                                                                                                                                                                          
Fetched 1268 kB in 0s (0 B/s)                                                                                                                                                                                                         
authenticate 'jammy.tar.gz' against 'jammy.tar.gz.gpg' 
extracting 'jammy.tar.gz'
$

升级完成会自动推出,需要仔细观察输出日志,判断是否有出错.

正常的退出:

No schema files found: removed existing output file.
(Reading database ... 106687 files and directories currently installed.)
Purging configuration files for session-migration (0.3.6) ...
Purging configuration files for libpython3.8-minimal:amd64 (3.8.10-0ubuntu1~20.04.5) ...
Purging configuration files for at (3.2.5-1ubuntu1) ...
Purging configuration files for libssl1.1:amd64 (1.1.1f-1ubuntu2.16) ...
Purging configuration files for popularity-contest (1.71ubuntu3) ...
Purging configuration files for ltrace (0.7.3-6.1ubuntu6) ...
Purging configuration files for bsdmainutils (12.1.7+nmu3ubuntu2) ...
Purging configuration files for python3.8-minimal (3.8.10-0ubuntu1~20.04.5) ...
Purging configuration files for language-selector-common (0.219) ...
Purging configuration files for crda (3.18-1build1) ...
Purging configuration files for accountsservice (22.07.5-2ubuntu1.3) ...
Processing triggers for dbus (1.12.20-2ubuntu4) ...
$ 

异常退出,根据提示,是nginx升级过程出错了,但是不是致命错误,升级最后还是成功了。对于有异常的升级,可能还需要使用 sudo apt autoremove --purge -y 删除无用的软件包。

invoke-rc.d: release upgrade in progress, error is not fatal
Setting up nginx (1.18.0-6ubuntu14.1) ...

$ sudo apt autoremove --purge -y
  1. 重启生效,检查升级后是否正常。
本原创文章未经允许不得转载 | 当前页面:35+ stories, thoughts and ideas. » ubuntu 批量无交互升级大版本

评论