diff --git a/content/post/incus-install.md b/content/post/incus-install.md index 5ab5bf1..6980edf 100644 --- a/content/post/incus-install.md +++ b/content/post/incus-install.md @@ -114,24 +114,6 @@ categories: ["kvm", "container"] Would you like a YAML "init" preseed to be printed? (yes/no) [default=no]: ``` -### 简单使用 -- 拉取 alpine lxc 镜像 - ```BASH - incus image list tuna: alpine amd64 # 查看清华源里存在的 alpine amd64 镜像 - incus image copy tuna:alpine/3.21 local: - ``` - -- 启动一个系统级容器 alpine-lxc - ```BASH - incus launch local:alpine/3.21 alpine-lxc - ``` - -- 进入 alpine-lxc - ```BASH - incus shell alpine-lxc - # 进入容器后,会发现虚拟机已有 ip,可以正常上网 - ``` - --- ## 集群环境 @@ -253,18 +235,87 @@ incus3 | eth0: 192.168.1.3 | 10.10.10.3 | Rocky9 | /dev/sdb | 10.10.10.3 incus - **之前创建的受管网络 incusbr99 虽然没用,但不建议删除,否则后面向该集群增加其他 incus 节点还会失败** -### 简单使用 -- 拉取 alpine lxc 镜像,与单机环境对应操作一样 -- 在 incus2 节点中启动一个系统级容器 alpine-lxc +--- + +## 简单使用 +### lxc 容器 +- 拉取 alpine lxc 镜像 + ```BASH + incus image list tuna: alpine amd64 # 查看清华源里存在的 alpine amd64 镜像 + incus image copy tuna:alpine/3.21 local: + ``` + +- 启动一个系统级容器 alpine-lxc + ```BASH + # 单机环境 + incus launch local:alpine/3.21 alpine-lxc + + # 集群环境中的 incus2 节点 ```BASH incus launch local:alpine/3.21 alpine-lxc \ --network incusbr --storage pool1 --target incus2 ``` -- 进入 alpine-lxc,配置网络 +- 进入 alpine-lxc 容器 ```BASH incus shell alpine-lxc + + # 单机环境的网络是 incus 管理的,此时会发现该虚拟机已有 ip,可以正常上网 + # 集群环境的服务器网络中,如果有 dhcp 服务,该虚拟机也会分到 ip + # 如果没有 dhcp 服务,可以手动配置一个临时 ip ip a add 192.168.1.123/24 dev eth0 ping 192.168.1.254 # 正常情况网关网络可达 ``` +### qemu 虚拟机 +- Windows 客户机需要安装 xmanager,Linux 和 Mac 客户机需要安装 virt-viewer +- 下载 RockyLinux8 操作系统镜像文件:Rocky-8.10-x86_64-minimal.iso +- 创建 iso 存储卷 + ```BASH + incus storage volume import pool1 \ + /root/Rocky-8.7-x86_64-minimal.iso \ + rocky8-iso-volume --type=iso + # pool1: 存储池 + # /root/Rocky-8.7-x86_64-minimal.iso:本地 iso 镜像文件 + # rocky8-iso-volume:创建的 iso 存储卷的名字 + ``` + +- 创建一个空的虚拟机,并设置系统盘大小和 boot 优先级 + ```BASH + incus create vm1 --empty --vm -d root,size=6GiB -s pool1 + # vm1:虚拟机名字 + # root,size=6GiB:虚拟机中的系统盘设备名是 root,大小是 6G + # pool1: 存储池 + + incus config device set vm1 root boot.priority=20 + # boot.priority=20:boot 优先级,数字越大,优先级越高 + ``` + +- 为虚拟机增加 iso 存储卷,并设置 boot 优先级 + ```BASH + incus config device add vm1 iso-cd disk \ + pool=pool1 source=rocky8-iso-volume boot.priority=10 + # vm1:虚拟机名字 + # iso-cd:虚拟机中的 iso 只读盘设备名 + # pool1:存储池 + # rocky8-iso-volume:创建的 iso 存储卷的名字 + # boot.priority=10:boot 优先级,数字越大,优先级越高 + ``` + +- 启动虚拟机,这里会调用客户机的 virt-viewer 或 xmanager + ```BASH + incus start vm1 --console=vga + ``` + +- 在弹出的窗口中开始安装 RockyLinux8 +- 安装完成(点击“重新启动”)后,窗口自动关闭,此时虚拟机正在重启中 +- 打开已运行虚拟机的 console 终端 + ```BASH + incus console vm1 --type=vga + ``` + +- 系统安装完成后,虚拟机不再需要 iso 只读盘设备,可以卸载 + ```BASH + incus config device remove vm1 iso-cd + ``` +