027、在Debain上KVM安装Rocky9 2024-11-18 字数统计: 351字 | 阅读时长≈ 1分 在Debain上KVM安装Rocky9 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283#确认是否支持虚拟化sudo cat /proc/cpuinfo | grep vmx#安装虚拟化软件sudo apt updatesudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils#当然可以直接是使用 sudo apt install librit*#增强工具sudo apt install -y virt-manager guestfs-tools net-tools#用户授权sudo usermod -aG kvm $USERsudo usermod -aG libvirt $USERsudo usermod -aG libvirt-qemu $USERsudo usermod -aG libvirt-dnsmasq $USER #安装完成后验证是否安装成功sudo kvm-ok#启动进程sudo systemctl enable libvirtd --now sudo systemctl status libvirtd#查看虚拟机网段(默认)ip add show virbr0#######################################################安装sudo rm -rf /kvm/*sudo mkdir -pv /kvmsudo wget https://mirror.sjtu.edu.cn/rocky/9/images/x86_64/Rocky-9-GenericCloud.latest.x86_64.qcow2 -O /kvm/Rocky9.qcow2sudo chown -Rv kali:kali /kvmsudo chmod -Rv 777 /kvm#确认本初始分区状态sudo virt-filesystems --long -h --all -a /kvm/Rocky9.qcow2#更改密码sudo virt-customize -a /kvm/Rocky9.qcow2 --root-password password:1 \ --run-command 'sed -i "s/#PasswordAuthentication yes/PasswordAuthentication yes/g" /etc/ssh/sshd_config' \ --run-command 'sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config' \ --selinux-relabel \ --timezone "Asia/Shanghai" #确认删除sudo virsh shutdown Rocky9-1sudo virsh destroy Rocky9-1sudo virsh undefine Rocky9-1 #安装sudo virt-install --name Rocky9-1 \ --memory 2048 \ --vcpus 2 \ --import --os-variant centos-stream9 \ --disk path=/kvm/Rocky9.qcow2,bus=virtio \ --network bridge=virbr0,model=virtio \ --noautoconsole#可以使用图形查看virt-manager#查看Kvm虚拟机的ip地址virsh domifaddr Rocky9-1#查看KVM虚拟机的IP地址方法2arp | grep "$(virsh dumpxml Rocky9-1 | grep mac| tail -1 | tr -s " " | cut -d"'" -f2)" Linux