Ubuntu focal是20.04 ,jammy版本是22.04,本次的目的就是将FreeBSD jail子系统里的Ubuntu 从20.04升级到22.04 。这个focal 子系统是通过cbsd克隆得到的。使用CBSD克隆复制Ubuntu jail子系统环境-CSDN博客
do-release-upgrade升级没成功,用debootstrap重装升级成功!
说明,有三个系统:FreeBSD宿主机,FreeBSD jail子系统, Ubuntu jail 子系统
安装好后,可以从宿主机进入FreeBSD或Ubuntu jail子系统。在FreeBSD jail子系统里可以安装多个Ubuntu jail子系统,并进入该子系统。
Ubuntu jail子系统里升级focal到jammy
使用do-release-upgrade升级(失败)
参考Install Ubuntu 22.04 Jammy in FreeBSD Jail | The FreeBSD Forums
在FreeBSD宿主机进入Ubuntu jail 子系统,使用命令:
jexec focal_to_jammy chroot /compat/ubuntu /bin/bash
子系统是以前克隆的focal版本,依次执行升级命令:
apt install update-manager-core
do-release-upgrade -d
没升级成功。
用-d选项的话没有错误信息,去掉-d选项,有报错信息,见后面调试部分。最终没有用这种方法升级成功。
使用debootstrap升级
使用cbsd jlogin focal_to_jammy 进入FreeBSD jail子系统,这时候是处于FreeBSD系统下,有pkg指令,所以:
先pkg安装debootstrap
pkg install debootstrap
执行debootstrap 下载jammy
debootstrap jammy /compat/jammy
这样FreeBSD jail子系统里的操作就结束了,后面就是进入jammy jail子系统进行操作了。
进入jammy jail子系统
从FreeBSD jail子系统执行chroot进入jammy子系统
focal_to_jammy:/root@[9:37] # chroot /compat/jammy/ /bin/bash
groups: cannot find name for group ID 0
groups: cannot find name for group ID 5
I have no name!@focal_to_jammy:/#
如果顺利,到了这一步就可以结束了,但是:
发现这个jammy子系统里又没有apt
怎么老碰到这个问题?
debootstrap安装jammy时的输出,有apt这个包啊
I: Retrieving apt 2.4.5
I: Validating apt 2.4.5
I: Extracting base-files...
I: Extracting base-passwd...
I: Extracting bash...
发现确实没有解开apt的包
第二次使用--include=apt选项
debootstrap --include=apt jammy /compat/jammy
I: Validating adduser 3.118ubuntu5
I: Validating apt 2.4.5
I: Validating apt-utils 2.4.5
还是没有Extracting解开apt 包。话说debootstrap就这么节俭吗? 连个apt包都不给? 还是说只有FreeBSD下的这个debootstrap不给?
看看jammy里的/usr/bin 目录,里面就是没有apt !
jammy jail子系统里手工安装apt
以前手工安装apt,会碰到依赖库的问题,操作很繁琐,这回找到了一个最方便的方法
dpkg --force-depends -Ei /var/cache/apt/archives/*.deb
jammy jail子系统里所有的deb包放在/var/cache/apt/archives目录,
只要使用这一条命令就能装好apt包,使用命令
dpkg --force-depends -Ei /var/cache/apt/archives/*.deb
过程中问到键盘设置啥的, 还有pam的配置改变要不要覆盖:
One or more of the files │
│ /etc/pam.d/common-{auth,account,password,session} have been locally │
│ modified. Please indicate whether these local changes should be │
│ overridden using the system-provided configuration. If you decline this │
│ option, you will need to manage your system's authentication │
│ configuration by hand. │
│ │
│ Override local changes to /etc/pam.d/common-*? │
│ │
│ <Yes> <No>
因为是新系统,本地没啥,所以选择了Yes覆盖
后面还有设置时区shanghai 等
安装完成后,终于有了APT
但是刚开始使用apt会报错
apt update 报错问题解决
apt update
Get:1 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
0% [Working]/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
E: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Err:1 http://archive.ubuntu.com/ubuntu jammy InRelease
gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Reading package lists... Done
W: GPG error: http://archive.ubuntu.com/ubuntu jammy InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://archive.ubuntu.com/ubuntu jammy InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
看里面讲到 /dev/null: Permission denied,就给它666权限:
执行chmod 666 /dev/null
将/dev/null设为666
chmod 666 /dev/null
然后update 搞定,但是upgrade报错
apt upgrade
Reading package lists... Done
Building dependency tree... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
dash : Depends: dpkg (>= 1.19.1) but it is not installed
grep : Depends: dpkg (>= 1.15.4) but it is not installed or
install-info but it is not installed
gzip : Depends: dpkg (>= 1.15.4) but it is not installed or
install-info but it is not installed
perl-base : PreDepends: dpkg (>= 1.17.17) but it is not installed
python3-minimal : Depends: dpkg (>= 1.13.20) but it is not installed
readline-common : Depends: dpkg (>= 1.15.4) but it is not installed or
install-info but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
尝试apt --fix-broken install修复apt upgrade报错问题
按照报错提示,输入
apt --fix-broken install
修复完成,apt install wget ,成功!
现在看看版本:
lsb_release -a
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy
成功升级到jammy版本!
总结
本来想用下面两条执行将focal升级到jammy,但是没有成功。
apt install update-manager-core
do-release-upgrade -d
最终还是使用了debootstrap 老办法升级成功。
debootstrap安装jammy
pkg install debootstrap
debootstrap jammy /compat/jammy
chroot /compat/jammy/ /bin/bash
chmod 666 /dev/null
dpkg --force-depends -Ei /var/cache/apt/archives/*.deb
apt update
apt --fix-broken install
apt upgrade
# 看版本
lsb_release -a
调试
do-release-upgrade -d提示set Prompt=norma
do-release-upgrade -d
Checking for a new Ubuntu release
There is no development version of an LTS available.
To upgrade to the latest non-LTS development release
set Prompt=normal in /etc/update-manager/release-upgrades.
在/etc/update-manager/release-upgrades文件里,将Prompt=lts修改成Prompt=normal
结果执行后没什么反应:
root@focal_to_jammy:/# do-release-upgrade -d
Checking for a new Ubuntu release
Upgrades to the development release are only
available from the latest supported release.
将do-release-upgrade -d的-d去掉后提示
do-release-upgrade
Checking for a new Ubuntu release
Get:1 Upgrade tool signature [833 B]
Get:2 Upgrade tool [1270 kB]
Fetched 1271 kB in 0s (0 B/s)
authenticate 'jammy.tar.gz' against 'jammy.tar.gz.gpg'
extracting 'jammy.tar.gz'
Reading cache
Checking package manager
A fatal error occurred
Please report this as a bug and include the files
/var/log/dist-upgrade/main.log and /var/log/dist-upgrade/apt.log in
your report. The upgrade has aborted.
Your original sources.list was saved in
/etc/apt/sources.list.distUpgrade.
Traceback (most recent call last):
File "/tmp/ubuntu-release-upgrader-fdy6hyrf/jammy", line 8, in
<module>
sys.exit(main())
File
"/tmp/ubuntu-release-upgrader-fdy6hyrf/DistUpgrade/DistUpgradeMain.py",
line 241, in main
if app.run():
File
"/tmp/ubuntu-release-upgrader-fdy6hyrf/DistUpgrade/DistUpgradeController.py",
line 2042, in run
return self.fullUpgrade()
File
"/tmp/ubuntu-release-upgrader-fdy6hyrf/DistUpgrade/DistUpgradeController.py",
line 1807, in fullUpgrade
if not self.prepare():
File
"/tmp/ubuntu-release-upgrader-fdy6hyrf/DistUpgrade/DistUpgradeController.py",
line 414, in prepare
self._sshMagic()
File
"/tmp/ubuntu-release-upgrader-fdy6hyrf/DistUpgrade/DistUpgradeController.py",
line 273, in _sshMagic
is_child_of_process_name("sshd")):
File "/tmp/ubuntu-release-upgrader-fdy6hyrf/DistUpgrade/utils.py",
line 118, in is_child_of_process_name
with open(stat_file) as stat_f:
FileNotFoundError: [Errno 2] No such file or directory:
'/proc/35020/stat'
发现source.list文件只有一行,不知道是否这个原因
/etc/apt# cat sources.list
deb http://archive.ubuntu.com/ubuntu focal main
添加了清华源,问题依旧。查看报错,发现/proc下没有东西,且ps报错
在ps -aux的时候报错Error, do this: mount -t proc proc /proc
ps -aux
Error, do this: mount -t proc proc /proc
按照提示mount -t proc proc /proc
结果报错
mount -t proc proc /proc
mount: /proc: permission denied.
root@focal_to_jammy:/# mount
mount: failed to read mtab: No such file or directory
root@focal_to_jammy:/# df
df: cannot read table of mounted file systems: No such file or directory
在/etc/fstab里加上配置:
devfs /compat/linux/dev devfs rw,late 0 0
tmpfs /compat/linux/dev/shm tmpfs rw,late,size=1g,mode=1777 0 0
fdescfs /compat/linux/dev/fd fdescfs rw,late,linrdlnk 0 0
linprocfs /compat/linux/proc linprocfs rw,late 0 0
linsysfs /compat/linux/sys linsysfs rw,late 0 0
问题依旧。
这样在FreeBSD的jail里,想要focal升级到jammy Ubuntu的实验失败告终。
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » jail子系统里升级Ubuntu focal到jammy
发表评论 取消回复