嵌套虚拟机的搭建
- 在vmware 虚拟机设置中,打开处理器的虚拟化Intel VT-x/EPT 或AMD-V/RVI(v)
- 配置虚拟机yum 源,安装qemu、qemu-kvm、libvirt
- 从阿里镜像源下载centos iso 阿里源 centos-7-x86
- 准备虚拟机创建所需xml,centos.xml
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'><name>centos-test</name><memory unit='KiB'>8388608</memory><currentMemory unit='KiB'>8388608</currentMemory><vcpu placement='static'>4</vcpu><os><type arch='x86_64' machine='rhel6.5.0'>hvm</type><boot dev='hd'/><boot dev='cdrom'/><bootmenu enable='yes'/><bios useserial='yes' rebootTimeout='0'/></os><features><acpi/><apic/><pae/></features><cpu mode='host-model'><model fallback='allow'/></cpu><clock offset='utc'/><on_poweroff>destroy</on_poweroff><on_reboot>restart</on_reboot><on_crash>restart</on_crash><devices><emulator>/usr/libexec/qemu-kvm</emulator><disk type='file' device='disk'><driver name='qemu' type='qcow2' cache='none'/><source file='/home/test/test.qcow2'/><target dev='vda' bus='virtio'/></disk><disk type='file' device='cdrom'><driver name='qemu' type='raw' cache='none'/><source file='/home/test/CentOS-Stream-9-20231218.0-x86_64-boot.iso'/><target dev='sda' bus='scsi'/></disk><controller type='ide' index='0'></controller><controller type='virtio-serial' index='0'></controller><controller type='usb' index='0'></controller><interface type='bridge'><source bridge='virbr0'/><mac address='52:54:00:e0:d9:e9'/><model type='virtio'/></interface><console type='pty'></console><input type='mouse' bus='ps2'/><graphics type='vnc' autoport='yes' listen='0.0.0.0'><listen type='address' address='0.0.0.0'/></graphics><video><model type='cirrus' heads='1'/></video><memballoon model='virtio'></memballoon></devices><qemu:commandline><qemu:env name='SPICE_DEBUG_ALLOW_MC' value='1'/></qemu:commandline>
</domain>
- 创建系统盘
qemu-img create -f qcow2 test.qcow2 10g
- 创建虚拟机,并进行系统安装
virsh create centos.xml #创建虚拟机
virsh list #查看虚拟机
virsh vncdisplay centos-test #查看虚拟机vnc端口号
vncviewer 0.0.0.0:0 #通过vnc进行虚拟机系统安装
linux 系统启动流程
PC机上电——>加载BIOS——>加载MBR到内存——>GRUB引导——>加载内核
bios是固化在主板上的ROM,掉电仍能保存,主要用于完成cpu、主板、内存检测和初始化。BIOS程序的最后会指向计算机硬盘的MBR主引导扇区(Master Boot Record,启动盘的第一个扇区),然后将MBR中的内容加载到内存(RAM)中,并将控制权转交给MBR。
硬盘上的MBR包含基本的Boot Loader(446字节)和一个小的分区表(64字节)以及分隔标识(2字节),MBR的前446个字节存放的是GRUB(GRand Unified Bootloader 一个多重操作系统引导其,用来引导不同的系统)程序的一部分。