使用cbsd指令快速创建bhyve Ubuntu虚拟机实践

首先查看当前的模板

ls -la /usr/jails/etc/defaults/

可以看到Ubuntu的20 22 23 24都有模板

复制代码
ls  /usr/jails/etc/defaults/vm-linux-ubuntuserver-amd64-2*
/usr/jails/etc/defaults/vm-linux-ubuntuserver-amd64-20.conf
/usr/jails/etc/defaults/vm-linux-ubuntuserver-amd64-22.conf
/usr/jails/etc/defaults/vm-linux-ubuntuserver-amd64-23.conf
/usr/jails/etc/defaults/vm-linux-ubuntuserver-amd64-24.conf

看下所有的cloud云模板

复制代码
ls  /usr/jails/etc/defaults/vm-linux-cloud-*
/usr/jails/etc/defaults/vm-linux-cloud-Alma-9-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-Arch-x86-2022.conf
/usr/jails/etc/defaults/vm-linux-cloud-CentOS-7-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-CentOS-stream-8-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-CentOS-stream-9-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-Debian-x86-10.conf
/usr/jails/etc/defaults/vm-linux-cloud-Debian-x86-11.conf
/usr/jails/etc/defaults/vm-linux-cloud-Debian-x86-12.conf
/usr/jails/etc/defaults/vm-linux-cloud-Debian-x86-9.conf
/usr/jails/etc/defaults/vm-linux-cloud-Devuan-x86-5.conf
/usr/jails/etc/defaults/vm-linux-cloud-Euro-9-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-Fedora-37-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-Fedora-38-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-Fedora-39-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-Fedora-40-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-FreePBX-16-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-HomeAssistantOS-2024.conf
/usr/jails/etc/defaults/vm-linux-cloud-Kali-2022-amd64.conf
/usr/jails/etc/defaults/vm-linux-cloud-Oracle-7-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-Oracle-8-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-Oracle-9-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-Parrot-5-amd64.conf
/usr/jails/etc/defaults/vm-linux-cloud-Rocky-8-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-Rocky-9-x86_64.conf
/usr/jails/etc/defaults/vm-linux-cloud-firestarter-debian-11.conf
/usr/jails/etc/defaults/vm-linux-cloud-kubernetes-27.conf
/usr/jails/etc/defaults/vm-linux-cloud-ubuntudesktop-amd64-22.04.conf
/usr/jails/etc/defaults/vm-linux-cloud-ubuntuserver-amd64-20.conf
/usr/jails/etc/defaults/vm-linux-cloud-ubuntuserver-amd64-22.04.conf
/usr/jails/etc/defaults/vm-linux-cloud-ubuntuserver-amd64-23.04.conf
/usr/jails/etc/defaults/vm-linux-cloud-ubuntuserver-amd64-24.04.conf

对于模板,可以忽略vm-linux的前缀,因此在命令里vm-linux-cloud-CentOS-stream-9-x86_64.conf写做cloud-CentOS-stream-9-x86_64 ,那么vm-linux-cloud-ubuntuserver-amd64-22.04.conf 写作cloud-ubuntuserver-amd64-22.04

云和普通模板两者的不同点在于:vm-linux-ubuntu这个需要自己安装系统,而vm-linux-cloud 云模板则使用了已有的云系统。vm-linux-cloud云里面Centos的云系统很好用,网络也是好的,但是么有相关的ping等命令,而Ubuntu的云系统,启动后网络不通,也没有ping、netstat等命令,调试起来非常麻烦。

使用云Centos模板创建虚拟机

执行命令:

cbsd bcreate jname=cent1 vm_ram=1g vm_cpus=1 imgsize=10g vm_os_type="linux" vm_os_profile="cloud-CentOS-stream-9-x86_64" ci_ip4_addr="10.0.0.100" ip4_gw="10.0.0.1" interface="cbsdvale_vale1" astart=0 runasap=1

使用云Ubuntu 22版本的模板创建虚拟机

执行命令

cbsd bcreate jname=ub1 vm_ram=1g vm_cpus=1 imgsize=10g vm_os_type="linux" vm_os_profile="cloud-ubuntuserver-amd64-22.04" ci_ip4_addr="10.0.0.100" ip4_gw="10.0.0.1" interface="cbsdvale_vale1" astart=0 runasap=1

网络配置

因为模板中都用到了cbsdvale_vale1接口,所以要创建vale接口:

复制代码
cbsd valecfg

结果提示:Please set valecfg: mode

原来要用这条命令:

复制代码
cbsd valecfg-tui

创建一个叫vale1的网络接口即可。

因为对centos不熟,所以后面以ubuntu为例说明。

启动虚拟机

创建完虚拟机后,启动虚拟机,如

cbsd bstart ub1

然后登录虚拟机

cbsd blogin ub1

这时候就进入Ubuntu 22虚拟子系统了

复制代码
cbsd blogin ub1
blogin.conf: /usr/bin/ssh -oStrictHostKeyChecking=no -oConnectTimeout=15 -oServerAliveInterval=10 -i /usr/jails/.ssh/id_rsa [email protected]
Custom login command: /usr/bin/ssh -oStrictHostKeyChecking=no -oConnectTimeout=15 -oServerAliveInterval=10 -i /usr/jails/.ssh/id_rsa [email protected]
Last login: Thu Aug 22 21:09:54 2024 from 10.0.0.1

------------------: System Data :-------------------------------
Hostname:     ub1 (10.0.0.100 )
Kernel:       5.15.0-67-generic (Ubuntu 22.04.2 LTS)
Uptime:       21:30:43 up 23 min,  1 user,  load average: 0.08, 0.05, 0.05
CPU:          Intel(R) Celeron(R) CPU @ 1.99GHz  (1 cores)
Memory(Mb):   968 Mb total / 670 Mb free
Env info:     
------------------------: Logged as: [ubuntu]  ------------------------------


  This image was created for ClonOS/CBSD/MyBee Project.
  Please Support Us:      https://www.patreon.com/clonos

ubuntu@ub1:~$ 

调试

执行cbsd valecfg提示:Please set valecfg: mode

cbsd valecfg

Please set valecfg: mode

原来要用这条命令:

复制代码
cbsd valecfg-tui

创建一个叫vale1的网络接口即可。

相关推荐
宁zz5 小时前
乌班图安装jenkins
运维·jenkins
大丈夫立于天地间5 小时前
ISIS协议中的数据库同步
运维·网络·信息与通信
cg50175 小时前
Spring Boot 的配置文件
java·linux·spring boot
暮云星影6 小时前
三、FFmpeg学习笔记
linux·ffmpeg
rainFFrain6 小时前
单例模式与线程安全
linux·运维·服务器·vscode·单例模式
GalaxyPokemon6 小时前
Muduo网络库实现 [九] - EventLoopThread模块
linux·服务器·c++
mingqian_chu7 小时前
ubuntu中使用安卓模拟器
android·linux·ubuntu
Zero_to_zero12348 小时前
解决docker的ubuntu系统中文乱码问题
ubuntu·docker·容器
@郭小茶8 小时前
docker-compose方式部署docker项目
运维·docker·容器