CentOS7でKVM(仮想環境)を構築③ インストールイメージ作成 で作成したISOイメージを利用して、仮想マシンを作成します。
virt-install
コマンドで仮想マシンを作成します。
# virt-install \
--name vm1 \
--ram 4096 \
--disk size=30 \
--vcpus 2 \
--os-type linux \
--os-variant rhel7 \
--network bridge=virbr1 \
--graphics none \
--console pty,target_type=serial \
--location /work/CenOS7_6.iso \
--extra-args="console=tty0 console=ttyS0,115200n8"
[!]
の各設定画面に入り、[X]
になったことを確認して b
を入力するとインストールが始まります。
Starting installer, one moment...
anaconda 21.48.22.147-1 for CentOS 7 started.
* installation log files are stored in /tmp during the installation
* shell is available on TTY2
* when reporting a bug add logs from /tmp as separate text/plain attachments
08:30:39 Not asking for VNC because we don't have a network
================================================================================
================================================================================
Installation
1) [x] Language settings 2) [!] Time settings
(English (United States)) (Timezone is not set.)
3) [!] Installation source 4) [!] Software selection
(Processing...) (Processing...)
5) [!] Installation Destination 6) [x] Kdump
(No disks selected) (Kdump is enabled)
7) [ ] Network configuration 8) [!] Root password
(Not connected) (Password is not set.)
9) [!] User creation
(No user will be created)
Please make your choice from above ['q' to quit | 'b' to begin installation |
'r' to refresh]:
[anaconda] 1:main* 2:shell 3:log 4:storage-lo> Switch tab: Alt+Tab | Help: F1
virsh
コマンドで仮想マシンの状態が確認できます。
# virsh list --all
Id Name State
----------------------------------------------------
4 vm1 running
サブコマンドconsole
で仮想マシンのコンソールに接続し、Ctrl+]
でコンソールから切断できます。
# virsh console vm1
Connected to domain vm1
Escape character is ^]
CentOS Linux 7 (Core)
Kernel 3.10.0-957.el7.x86_64 on an x86_64
vm1 login:
おまけ。仮想マシンの削除は、shutdownしてからundefineします。
# virsh shutdown vm1
Domain vm1 is being shutdown
# virsh list --all
Id Name State
----------------------------------------------------
- vm1 shut off
# virsh undefine vm1
# virsh list --all
Id Name State
----------------------------------------------------
どうにもならなくなったら、destroyで強制削除します。
# virsh destroy vm1
Domain vm1 destroyed