使用CBSD克隆复制Ubuntu jail子系统环境

CBSD介绍

CBSD是为FreeBSD jail子系统、bhyve、QEMU/NVMM和Xen编写的管理层。该项目定位为一个综合解决方案的单一集成工具,用于使用预定义的软件集以最少的配置快速构建和部署计算机虚拟环境。

具体安装使用见:jail管理器CBSD实践@FreeBSD_freebsd jail 部署-CSDN博客

为了快速搭建Jail 里的Ubuntu环境,可以采取建好一个jail系统,然后克隆出多个系统的方法。

cbsd克隆复制jail子系统

克隆命令

cbsd jclone old=jail2 new=jail3 host_hostname=jail3.my.domain ip4_addr=10.0.0.22``/24

如原jail名字为focal,新名字为focal_to_jammy,设置好host_hostname主机名,再配置好ip地址,命令如下:

cbsd jclone old=focal new=focal_to_jammy host_hostname=focal_to_jammy.my.domain ip4_addr=10.0.0.2/24

如果原jail子系统还在运行,那么会提示加上checkstate=0 参数

cbsd jclone old=focal new=focal_to_jammy host_hostname=focal_to_jammy.my.domain ip4_addr=10.0.0.2/24 checkstate=0 

只要几秒就克隆好一个新系统了。

运行复制好的jail系统

使用cbsd jstart启动子系统

cbsd jstart focal_to_jammy

登录jail子系统

使用cbsd jlogin 登录

root@fbhost:~ # cbsd jlogin focal_to_jammy
Last login: Mon Jul 15 23:06:59 on pts/1
FreeBSD 14.1-RELEASE (GENERIC) releng/14.1-n267679-10e31f0946d8
focal_to_jammy:/root@[23:09] # chroot /compat/ubuntu/ /bin/bash
root@focal_to_jammy:/# uname -a
Linux focal_to_jammy.my.domain 5.15.0 FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC x86_64 x86_64 x86_64 GNU/Linux

也可以使用jexex命令登录

jexec focal_to_jammy  chroot /compat/ubuntu /bin/bash

jail子系统里升级focal到jammy(失败)

参考Install Ubuntu 22.04 Jammy in FreeBSD Jail | The FreeBSD Forums

进入子系统,使用命令:

jexec focal_to_jammy  chroot /compat/ubuntu /bin/bash

然后,执行升级:

apt install update-manager-core

do-release-upgrade -d

没升级成,后面也没看懂。

这步好像不用再重复了

更新库

root@focal_to_jammy:/lib64# ls -l /lib/x86_64-linux-gnu/ld-2.31.so
-rwxr-xr-x 1 root root 191472 Apr 15 2020 /lib/x86_64-linux-gnu/ld-2.31.so

其它cbsd jail操作

重启子系统

cbsd jrestart focal_to_jammy

删除

cbsd jremove jail1

调试

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的实验失败告终。

相关推荐
blessing。。44 分钟前
I2C学习
linux·单片机·嵌入式硬件·嵌入式
2202_754421541 小时前
生成MPSOC以及ZYNQ的启动文件BOOT.BIN的小软件
java·linux·开发语言
努力的悟空1 小时前
国土变更调查拓扑错误自动化修复工具的研究
运维·自动化
运维&陈同学2 小时前
【zookeeper03】消息队列与微服务之zookeeper集群部署
linux·微服务·zookeeper·云原生·消息队列·云计算·java-zookeeper
旦沐已成舟2 小时前
DevOps-Jenkins-新手入门级
服务器
周末不下雨3 小时前
win11+ubuntu22.04双系统 | 联想 24 y7000p | ubuntu 22.04 | 把ubuntu系统装到1T的移动固态硬盘上!!!
linux·运维·ubuntu
软件技术员3 小时前
Let‘s Encrypt SSL证书:acmessl.cn申请免费3个月证书
服务器·网络协议·ssl
哎呦喂-ll3 小时前
Linux进阶:环境变量
linux
耗同学一米八3 小时前
2024 年河北省职业院校技能大赛网络建设与运维赛项样题四
运维·网络