使用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 ubuntu@10.0.0.100
Custom login command: /usr/bin/ssh -oStrictHostKeyChecking=no -oConnectTimeout=15 -oServerAliveInterval=10 -i /usr/jails/.ssh/id_rsa ubuntu@10.0.0.100
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的网络接口即可。

相关推荐
李昊哲小课9 分钟前
deepin 安装 zookeeper
大数据·运维·zookeeper·debian·hbase
真真-真真26 分钟前
WebXR
linux·运维·服务器
轩辰~1 小时前
网络协议入门
linux·服务器·开发语言·网络·arm开发·c++·网络协议
wanhengidc1 小时前
短视频运营行业该如何选择服务器?
运维·服务器
雨中rain2 小时前
Linux -- 从抢票逻辑理解线程互斥
linux·运维·c++
-KamMinG2 小时前
Centos7.9安装openldap+phpldapadmin+grafana配置LDAP登录最详细步骤 亲测100%能行
运维·grafana
Bessssss2 小时前
centos日志管理,xiao整理
linux·运维·centos
s_yellowfish2 小时前
Linux服务器pm2 运行chatgpt-on-wechat,搭建微信群ai机器人
linux·服务器·chatgpt
豆是浪个2 小时前
Linux(Centos 7.6)yum源配置
linux·运维·centos
vvw&2 小时前
如何在 Ubuntu 22.04 上安装 Ansible 教程
linux·运维·服务器·ubuntu·开源·ansible·devops