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

相关推荐
雨中rain2 分钟前
Linux -- 从抢票逻辑理解线程互斥
linux·运维·c++
-KamMinG12 分钟前
Centos7.9安装openldap+phpldapadmin+grafana配置LDAP登录最详细步骤 亲测100%能行
运维·grafana
Bessssss21 分钟前
centos日志管理,xiao整理
linux·运维·centos
s_yellowfish21 分钟前
Linux服务器pm2 运行chatgpt-on-wechat,搭建微信群ai机器人
linux·服务器·chatgpt
豆是浪个23 分钟前
Linux(Centos 7.6)yum源配置
linux·运维·centos
vvw&24 分钟前
如何在 Ubuntu 22.04 上安装 Ansible 教程
linux·运维·服务器·ubuntu·开源·ansible·devops
我一定会有钱26 分钟前
【linux】NFS实验
linux·服务器
王铁柱子哟-29 分钟前
解决 正在下载VS Code 服务器... 问题
运维·服务器
Ven%29 分钟前
如何在防火墙上指定ip访问服务器上任何端口呢
linux·服务器·网络·深度学习·tcp/ip
泰伦闲鱼30 分钟前
nestjs:GET REQUEST 缓存问题
服务器·前端·缓存·node.js·nestjs