环境及网卡配置请参考
https://blog.csdn.net/mshxuyi/article/details/98305715
创建镜像目录
mkdir -p /home/vms
virt-install 配置文件
virt-install \
--name=kvm107 --ram 1024 --vcpus=1 \
--disk path=/home/vms/kvm107.qcow2,size=10,format=qcow2,bus=virtio \
--location=/mnt/CentOS-7-x86_64-Minimal-1810.iso --network bridge=br0,model=virtio \
--graphics=none --console=pty,target_type=serial \
--extra-args="console=tty0 console=ttyS0"
-
--graphics 指定是否开启图形
-
--console 定义终端的属性,target_type 则是定义终端的类型
-
--extra-args 定义终端额外的参数
开始安装
Starting installer, one moment...
anaconda 21.48.22.93-1 for CentOS Linux 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
09:40:52 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]: 输入 1 然后回车
[anaconda] 1:main* 2:shell 3:log 4:storage-lo> Switch tab: Alt+Tab | Help: F1
这里选择 1 进入语言设置界面
Available languages
1) Afrikaans 25) Hindi 48) Oriya
2) Amharic 26) Croatian 49) Punjabi
3) Arabic 27) Hungarian 50) Polish
4) Assamese 28) Interlingua 51) Portuguese
5) Asturian 29) Indonesian 52) Romanian
6) Belarusian 30) Icelandic 53) Russian
7) Bulgarian 31) Italian 54) Sinhala
8) Bengali 32) Japanese 55) Slovak
9) Bosnian 33) Georgian 56) Slovenian
10) Catalan 34) Kazakh 57) Albanian
11) Czech 35) Kannada 58) Serbian
12) Welsh 36) Korean 59) Swedish
13) Danish 37) Lithuanian 60) Tamil
14) German 38) Latvian 61) Telugu
15) Greek 39) Maithili 62) Tajik
16) English 40) Macedonian 63) Thai
17) Spanish 41) Malayalam 64) Turkish
18) Estonian 42) Marathi 65) Ukrainian
19) Basque 43) Malay 66) Urdu
20) Persian 44) Norwegian Bokmål 67) Vietnamese
21) Finnish 45) Nepali 68) Chinese
22) French 46) Dutch 69) Zulu
Press ENTER to continue
这里回车后 选择 68 选择 Chinese 中文
Available locales
1) Simplified Chinese 3) Traditional Chinese 4) Simplified Chinese
(China) (Hong Kong) (Singapore)
2) Traditional Chinese
(Republic of China)
Please select language support to install.
这里输入 1 选择 Simplified Chinese (china)简体中文 然后回车
Installation
1) [x] Language settings 2) [!] Time settings
(Simplified Chinese (China)) (Timezone is not set.)
3) [x] Installation source 4) [!] Software selection
(Local media) (Minimal Install)
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]:
回车后重新进入主界面,接下来选择 2 进入 Time settings 时区设置
Time settings
Timezone: not set
NTP servers:not configured
1) Set timezone
2) Configure NTP servers
Please make your choice from above ['q' to quit | 'c' to continue |
'r' to refresh]:
选择 1 设置时区
Available regions
1) Africa 6) Atlantic 10) Pacific
2) America 7) Australia 11) US
3) Antarctica 8) Europe 12) Etc
4) Arctic 9) Indian
5) Asia
Please select the timezone.
Use numbers or type names directly [b to region list, q to quit]: 5
选择 5 Asia 亚洲
Available timezones in region Asia
1) Aden 28) Hovd 54) Pontianak
2) Almaty 29) Irkutsk 55) Pyongyang
3) Amman 30) Jakarta 56) Qatar
4) Anadyr 31) Jayapura 57) Qyzylorda
5) Aqtau 32) Jerusalem 58) Riyadh
6) Aqtobe 33) Kabul 59) Sakhalin
7) Ashgabat 34) Kamchatka 60) Samarkand
8) Baghdad 35) Karachi 61) Seoul
9) Bahrain 36) Kathmandu 62) Shanghai
10) Baku 37) Khandyga 63) Singapore
11) Bangkok 38) Kolkata 64) Srednekolymsk
12) Barnaul 39) Krasnoyarsk 65) Taipei
13) Beirut 40) Kuala_Lumpur 66) Tashkent
14) Bishkek 41) Kuching 67) Tbilisi
15) Brunei 42) Kuwait 68) Tehran
16) Chita 43) Macau 69) Thimphu
17) Choibalsan 44) Magadan 70) Tokyo
18) Colombo 45) Makassar 71) Tomsk
19) Damascus 46) Manila 72) Ulaanbaatar
20) Dhaka 47) Muscat 73) Urumqi
21) Dili 48) Nicosia 74) Ust-Nera
22) Dubai 49) Novokuznetsk 75) Vientiane
Press ENTER to continue
回车后 选择 62 Shanghai 上海 然后回车
1) [x] Language settings 2) [x] Time settings
(Simplified Chinese (China)) (Asia/Shanghai timezone)
3) [x] Installation source 4) [x] Software selection
(Local media) (Minimal Install)
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]:
重新进入主界面,这时选择 5 进入系统安装位置
Probing storage...
Installation Destination
[x] 1) : 10 GiB (vda)
1 disk selected; 10 GiB capacity; 10 GiB free ...
Please make your choice from above ['q' to quit | 'c' to continue |
'r' to refresh]:
这里可以看到 前面创建的虚拟机 10G,输入 C 下一步
Autopartitioning Options
[ ] 1) Replace Existing Linux system(s)
[x] 2) Use All Space
[ ] 3) Use Free Space
Installation requires partitioning of your hard drive. Select what space to use
for the install target.
Please make your choice from above ['q' to quit | 'c' to continue |
'r' to refresh]:
这里默认为 2,使用全部空间,输入 C 进入下一步
Partition Scheme Options
[ ] 1) Standard Partition
[ ] 2) Btrfs
[x] 3) LVM
[ ] 4) LVM Thin Provisioning
Select a partition scheme configuration.
Please make your choice from above ['q' to quit | 'c' to continue |
'r' to refresh]:
这里默认为 3,使用LVM分区,输入 C 进入下一步
nstallation
1) [x] Language settings 2) [x] Time settings
(Simplified Chinese (China)) (Asia/Shanghai timezone)
3) [x] Installation source 4) [x] Software selection
(Local media) (Minimal Install)
5) [x] Installation Destination 6) [x] Kdump
(Automatic partitioning (Kdump is enabled)
selected) 8) [!] Root password
7) [ ] Network configuration (Password is not set.)
(Not connected)
9) [!] User creation
(No user will be created)
Please make your choice from above ['q' to quit | 'b' to begin installation |
'r' to refresh]:
重新返回主界面 ,输入 8 设置 Root 密码
Please select new root password. You will have to type it twice.
Password:
Password (confirm):
================================================================================
================================================================================
Question
The password you have provided is weak: The password is shorter than 8
characters.
Would you like to use it anyway?
Please respond 'yes' or 'no': yes
输入 yes 确认,然后按 b 进入安装界面
Installing boot loader
.
Performing post-installation setup tasks
.
Configuring installed system
.
Writing network configuration
.
Creating users
.
Configuring addons
.
Generating initramfs
.
Running post-installation scripts
.
Use of this product is subject to the license agreement found at /usr/share/centos-release/EULA
Installation complete. Press return to quit
Installation complete 安装完成,按 回车 退出
接下来可以通过 virsh console 登陆GUEST虚拟机
#查看虚拟机
virsh list
Id Name State
----------------------------------------------------
8 kvm107 running
#通过字符界面登陆虚拟机
virsh console kvm107
输入虚拟机的账号跟密码
Connected to domain kvm107
Escape character is ^]
CentOS Linux 7 (Core)
Kernel 3.10.0-957.el7.x86_64 on an x86_64
kvm107 login: root
password:
Last login: Tue Aug 20 21:50:57 from 192.168.0.103
[root@kvm107 ~]#