天天看點

使用圖形與指令行方式安裝GuestOS

作者:黑馬金牌程式設計

1、使用圖形方式安裝GuestOS

#打開虛拟系統管理器

virt-manager           

選擇建立虛拟機

使用圖形與指令行方式安裝GuestOS
使用圖形與指令行方式安裝GuestOS
使用圖形與指令行方式安裝GuestOS
使用圖形與指令行方式安裝GuestOS
使用圖形與指令行方式安裝GuestOS
使用圖形與指令行方式安裝GuestOS

然後開始進入安裝界面

2、使用指令行模式安裝

虛拟機組成部分

1、虛拟機配置檔案

[root@localhost ~]# ls /etc/libvirt/qemu
networks  vm1.xml           

2、存儲虛拟機的媒體

[root@localhost ~]# ls /var/lib/libvirt/images/
vm1.qcow2
[root@localhost ~]#           

根據配置檔案配置虛拟機

1.需要拷貝之前的磁盤鏡像檔案

[root@localhost qemu]# cd /var/lib/libvirt/images/
[root@localhost images]# cp vm1.qcow2 vm2.img
[root@localhost images]# ll
總用量 10487812
-rw-------. 1 root root 5369757696 5月   2 11:11 vm1.qcow2
-rw-------  1 root root 5369757696 5月   2 11:19 vm2.img           

2.需要拷貝之前的配置檔案

[root@localhost ~]# cd /etc/libvirt/qemu/
[root@localhost qemu]# cp vm1.xml vm2.xml
[root@localhost qemu]#           

3.配置檔案需要修改必要的記憶體

[root@localhost images]# vim /etc/libvirt/qemu/vm2.xml           
使用圖形與指令行方式安裝GuestOS
使用圖形與指令行方式安裝GuestOS
使用圖形與指令行方式安裝GuestOS

4.建立虛拟機

[root@localhost images]# virsh define /etc/libvirt/qemu/vm2.xml
定義域 vm2(從 /etc/libvirt/qemu/vm2.xml)
[root@localhost images]#           

5.重新開機一下kvm服務

[root@localhost images]# systemctl restart libvirtd
[root@localhost images]#           

6.主控端開啟路由轉發

#vim /etc/sysctl.conf
net.ipv4.ip_forward = 1    #添加這一行           

儲存退出後,啟動

[root@localhost images]# sysctl -p
net.ipv4.ip_forward = 1
[root@localhost images]#           

7.驗證

#打開虛拟系統管理器

virt-manager           

檢視是否顯示建立的虛拟機vm2?

使用圖形與指令行方式安裝GuestOS

打開虛拟機檢視是否可用

使用圖形與指令行方式安裝GuestOS

結果:指令行建立的虛拟機可用并且可以ping通外網,如果ping不通記得激活一下網卡

繼續閱讀