首页 技术 正文
技术 2022年11月21日
0 收藏 345 点赞 4,493 浏览 2186 个字

1.在KVM环境上准备虚拟机磁盘

[root@localhost ~]# qemu-img create -f qcow2 -o size=50G

/opt/CentOS-7-1511-x86_64_50G.qcow2

[root@localhost ~]# qemu-img info CentOS-7-1511-x86_64_50G.qcow2

image: CentOS-7-1511-x86_64_50G.qcow2

file format: qcow2

virtual size: 50G (53687091200 bytes)

disk size: 196K

cluster_size: 65536

Format specific information:

compat: 1.1

lazy refcounts: false

备注:-f指定磁盘格式, -o size=40G 指定磁盘文件大小。创建完成后可以使用qemu-img info命令查看磁盘详细信息。

2.使用virt-manager 图形管理工具修改模板虚拟机属性

2.1从指定磁盘创建虚拟机

centos 7.3镜像制作

2.2选择存储路径

centos 7.3镜像制作

2.3 设置硬件属性

centos 7.3镜像制作

2.4 虚拟机名称

centos 7.3镜像制作

2.5添加ISO文件

centos 7.3镜像制作

2.6 选择磁盘驱动

centos 7.3镜像制作

2.7加载系统ISO

centos 7.3镜像制作

2.8选择网卡驱动

centos 7.3镜像制作

2.9修改键盘属性

centos 7.3镜像制作

3选择光盘引导安装系统

centos 7.3镜像制作

安装系统根据实际需求

安装系统注意事项:

1、 不能有lvm否则无法实现自动扩系统盘

4.修改系统信息

4.1关闭selinux和Firewall

[root@localhost ~]# systemctl stop firewalld.service

[root@localhost ~]# systemctl disable firewalld.service

[root@localhost ~]# sed -i ‘s/SELINUX=enforcing/SELINUX

=disabled/g’ /etc/selinux/config

4.2修改网卡配置文件

[root@localhost ~]# echo ‘NOZEROCONF=yes’ >>/etc/sysconfig/network

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

TYPE=Ethernet

BOOTPROTO=dhcp

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

IPV6_FAILURE_FATAL=no

IPV6_ADDR_GEN_MODE=stable-privacy

NAME=eth0

DEVICE=eth0

ONBOOT=yes

PERSISTENT_DHCLIENT=1

[root@localhost ~]# systemctl stop NetworkManager.service

[root@localhost ~]# systemctl disable NetworkManager.service

[root@localhost ~]# /sbin/chkconfig network on

4.3修改grub.conf

[root@localhost ~]# vim /boot/grub2/grub.cfg

添加 console=ttyS0 console=tty0

centos 7.3镜像制作

4.4 ssh相关配置

修改sshd配置文件 /etc/ssh/sshd_config

将#PermitRootLogin yes的注释去掉

重新启动SSH服务systemctl restart sshd.service

[root@localhost ~]# systemctl enable sshd.service

[root@localhost ~]# mkdir /root/.ssh权限700

[root@localhost ~]# touch /root/.ssh/authorized_keys权限644

4.5 创建dhclient.conf文件

[root@localhost ~]# vi /etc/dhcp/dhclient.conf 添加下面两行

timeout 300;

retry 60;

4.6 安装cloud-init

[root@localhost ~]# yum install cloud-init -y

[root@localhost ~]# vi /etc/cloud/cloud.cfg

centos 7.3镜像制作

添加下面内容:

centos 7.3镜像制作

删除下面红框的两行内容:

centos 7.3镜像制作

4.7 安装qemu-guest-agent

[root@localhost ~]# yum -y install qemu-guest-agent

[root@localhost ~]# systemctl start qemu-guest-agent.service

[root@localhost ~]# systemctl enable qemu-guest-agent.service

4.8 安装cloud-utils-growpart实现云主机启动时可以自动扩展根分区

[root@localhost ~]# yum -y install cloud-utils-growpart

生新生成 initramfs:

[root@localhost ~]# dracut –f

等待30秒左右

清除日志 操作记录 ,最后关机。完成

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,034
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,520
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,368
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,148
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,781
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,862