当前位置:首页 > IT

升级Debian12不会?,那么用这个脚本就对了

admin2年前 (2024-11-30)IT335

前言

2023 年 6 月 10 日,Debian 正式发布了其最新的稳定本12(代号 bookworm )。作为一名 Linux 的爱好者,怎能不第一时间升级它。

相对于 Debian 11,Debian 12 包含大量更新的软件包(上一版本中超过 67% 的包)。个人感觉还是可以升级的,不过前期还是不要用在主力机上。

准备工作

除非你是物理服务器,以及没有用过奇奇怪怪定制或修改的内核的 KVM 构架的 VPS 和云主机,否则升级大版本更新内核是有一定机率导致 Grub 加载失败的,切记备份重要数据!

OpenVZ 6 和 LXC 构架的 VPS 是无法升级的,因为他们没有自己独立的内核。

再强调一遍,一定要备份重要数据!

查看自己是那个debian的版本的命令。

cat /etc/debian_version# 或者cat /etc/os-release

更新系统

在安装前,请先更新系统。

apt updateapt upgrade -yapt dist-upgrade -yapt autocleanapt autoremove -y

如果内核更新了,可以重启让最新的内核生效,也可以直接进行升级。

升级系统

手动升级

首先更新 apt 源,替换 bullseye 为 bookworm:

sed -i 's/bullseye/bookworm/g' /etc/apt/sources.listsed -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/*.list

对于 Debian 12 以后的版本,所有 Debian 可以分发的打包的非自由固件二进制文件(non-free),比如某些驱动,都被转移到 Debian Archive 中的一个新组件,称为非自由固件(non-free-firmware)。如果您从旧版的 Debian 升级,并且需要这些固件二进制文件,您应该更新您系统上的 /etc/apt/sources.list,以使用这个新组件(来源):

sed -i 's/non-free/non-free non-free-firmware/g' /etc/apt/sources.list

默认的系统 apt 源文件 /etc/apt/sources.list 应该是类似这样的:

deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware

deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware

deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware

国内服务器可以替换 deb.debian.org 和 security.debian.org 为 mirrors.tuna.tsinghua.edu.cn

然后我们再次执行更新系统:

apt updateapt upgrade -yapt dist-upgrade -y

更新过程种会提示一些软件是否需要自动重启,选 Yes 即可,以及一些软件的配置文件是否需要更新,按照自己的情况选择即可,默认回车即视为使用旧的配置文件,一般会出现在 OpenSSH 等软件的更新上。

在 apt-listchanges: News 界面可以按 q 退出:

6zkX4boedhWO9nR.png

提示是否自动重启服务:

2.png

提示是否更新 OpenSSH 配置文件:

3.png

注意某些软件更新后可能会更新 systemd 服务配置,此时我们可以执行 systemctl daemon-reload 重新加载配置。

如果升级的时候遇到了如下错误:

Setting up dbus-daemon (1.14.6-1) ...
UUID file '/var/lib/dbus/machine-id' should contain a hex string of length 32, not length 0, with no other text
dpkg: error processing package dbus-daemon (--configure):
 installed dbus-daemon package post-installation script subprocess returned error exit status 1dpkg: dependency problems prevent configuration of dbus:
 dbus depends on dbus-daemon (= 1.14.6-1); however:
  Package dbus-daemon is not configured yet.

dpkg: error processing package dbus (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.36-9) ...
Errors were encountered while processing:
 dbus-daemon
 dbus
E: Sub-process /usr/bin/dpkg returned an error code (1)

删除 /var/lib/dbus/machine-id 这个空文件后重新执行命令即可,升级 dbus 时会自动生成这个文件。

rm -rf /var/lib/dbus/machine-id

更新后删除不必要的软件和依赖:

apt autocleanapt autoremove -y

然后我们使用 reboot 命令重启系统,耐心等待后,查看最新的系统版本:

root@debian ~ # cat /etc/debian_version 12.0
root@debian ~ # lsb_release -aNo LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 12 (bookworm)Release:	12Codename:	bookworm
root@debian ~ # uname -aLinux debian 6.1.0-9-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08) x86_64 GNU/Linux

这时我们就已经更新到了最新的 Debian 12 Bookworm 和内核了。

使用一键脚本自动升级

脚本地址:Github

脚本命令:

bash <(curl -sSL https://raw.githubusercontent.com/wikihost-opensource/linux-toolkit/main/system-upgrade/debian.sh)

如果你是 Debian 10 的系统,那么你需要执行两次脚本,因为脚本每次执行只会升级一个版本。

Debian 9 升级到 Debian 10
Debian 10 升级到 Debian 11
Debian 11 升级到 Debian 12

更新过程种会提示一些软件是否需要自动重启,选 Yes 即可,以及一些软件的配置文件是否需要更新,按照自己的情况选择即可,默认回车即视为使用旧的配置文件,一般会出现在 OpenSSH 等软件的更新上。具体请参考上文手动安装。

最后

祝大家玩的开心。

感谢一下文章:

  1. https://ybfl.xyz/sites/258.html

  2. https://sysin.org/blog/debian-12/

  3. https://u.sb/debian-upgrade-12/

原文地址:https://www.cnblogs.com/Eliauk365/p/17475957.html

扫描二维码推送至手机访问。

版权声明:本文由小龙的博客发布,如需转载请注明出处。

本文链接:https://xl.cndyun.com/post/822.html

“升级Debian12不会?,那么用这个脚本就对了” 的相关文章

CNDyun宣传片3

CNDyun宣传片3

当前浏览器不能支持视频播放,请采用chrome或IE9以上浏览器原创内容转载需注明…

Typecho 1.0 Nginx 提示access denied的解决办法。

使用Nginx驱动typecho,刚安装后可以看到首页却不能访问管理登录或伪静态页面,找了好多方法包括修改:/usr/local/php/etc/php-fpm.conf  在后面加上一行:security.limit_extensions = .php .asmx .html .js&n…

第三方团队公布适配安卓8.0列表,多达22个品牌,上百款机型

第三方团队公布适配安卓8.0列表,多达22个品牌,上百款机型

近日,谷歌官方的Andriod 8.0 已经开始推送给手机用户,开放系统源码后,第三方的Lineage 团队是 Android 第三方 ROM CyanogenMod 团队解散后的后继者。 Lineage 团队已经开始着手适配安卓8.0的工作,推出基于Oreo的新版本LineageOS 15.0。官…

牵手公益客户端上线

牵手公益客户端上线

app测试版下载地址:http://app.wlong.pw/qsgy/Qsgy1.apk…

MIP答疑解惑MIP改造常见Q&A集锦

MIP答疑解惑MIP改造常见Q&A集锦

MIP答疑解惑MIP改造常见Q&A集锦关于百度MIPMIP全称Mobile Instant Pages,移动网页加速器,是百度提出的页面加速解决方案。MIP夙昔端渲染和页面网络传输两方面进行优化,杜绝页面渲染中的壅塞题目,提拔页面显现速度。MIP答疑解惑1、MIP化后对其他搜索引擎抓取收录以…

2018年1月2日,我的第一个公益网站正式上线

2018年1月2日,我的第一个公益网站正式上线

2017年的感恩节,我正式开启了“牵手公益”项目,我想做的就是用自己的业余时间帮助更多的有需要的人,同时为公益组织提供免费技术等方面的帮助,目前我已拥有“牵手公益”qianshougongyi.com qianshougongyi.cn等域名。根据国家要求,qianshougongyi.c…