OpenStack制作CentOS6.7镜像

1.下载镜像
直接访问官方镜像地址下载,注意选择中国的镜像源,相对国外镜像下载速率比较快,进入后选择版本为6.7,在isos目录下下载x86_64的Minimal镜像.

2.创建虚拟机
首先需要创建一个qcow2格式镜像文件,用于作为虚拟机的磁盘,大小20G.
root@UKVM-IMG:/var/lib/libvirt/images# qemu-img create -f qcow2CentOS-6.7.qcow2 20G
Formatting 'centos-6.7.qcow2', fmt=qcow2 size=21474836480 encryption=offcluster_size=65536 lazy_refcounts=off refcount_bits=16
快速创建并启动虚拟机:
root@UKVM-IMG:/var/lib/libvirt/images# virt-install --virt-type kvm --namecentos-6.7 --ram 1024  --diskcentos-6.7.qcow2,format=qcow2  --networknetwork=default  --graphicsvnc,listen=0.0.0.0 --noautoconsole  --os-type=linux --os-variant=rhel6  --cdrom=CentOS-6.7-x86_64-minimal.iso
 
Starting install...
Creating domain...                                                                    |    0 B  00:00:00   
Domain installation still in progress. You can reconnect to
the console to complete the installation process.
启动完成后,使用vnc client连接,可以直接使用virt-manager或者virt-viewer直接连接。

3. 安装OS
进入虚拟机控制台可以看到Centos的启动菜单,选择Install or upgrade an existing system,继续选择语言,选择键盘格局,选择Basic Storage Devices,开启网络,设置主机名为默认,设置时区Asia/Shanghai,设置root密码,选择“Create Custom Layout”,只需要一个根分区即可,不需要swap分区,文件系统选择ext4,存储驱动选择Virtio Block Device,如图:

OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

完成安装配置工作,最后点击右下角的reboot重启退出虚拟机.

4. 配置OS
安装好系统后,还需要进行配置才能作为glance镜像使用,启动虚拟机:
root@UKVM-IMG:~# virsh list --all
 Id    Name                          State
----------------------------------------------------
 -    centos-6.7                    shut off
 -    centos7.2.1511-L              shut off
 -    centos72-L                    shut off
 
root@UKVM-IMG:~# virsh start centos-6.7
Domain centos-6.7 started

4.1 配置yum仓库
 
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Vault.repo
[root@localhost yum.repos.d]# rm CentOS-Debuginfo.repo
rm: remove regular file `CentOS-Debuginfo.repo'? y
[root@localhost yum.repos.d]# rm CentOS-fasttrack.repo
rm: remove regular file `CentOS-fasttrack.repo'? y
[root@localhost yum.repos.d]# rm CentOS-Media.repo
rm: remove regular file `CentOS-Media.repo'? y
[root@localhost yum.repos.d]# rm CentOS-Vault.repo
rm: remove regular file `CentOS-Vault.repo'? y
[root@localhost yum.repos.d]# ls
CentOS-Base.repo
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-6.7-Base.repo
 
[root@localhost yum.repos.d]# cat CentOS-6.7-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://vault.centos.org/6.7/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
 
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=http://vault.centos.org/6.7/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=http://vault.centos.org/6.7/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[root@localhost yum.repos.d]#
 
[root@localhost yum.repos.d]# yum install epel-release
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:6-8 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
====================================================================================================================
 Package                        Arch                      Version                  Repository                Size
====================================================================================================================
Installing:
 epel-release                    noarch                    6-8                      extras                    14 k
 
Transaction Summary
====================================================================================================================
Install      1 Package(s)
 
Total download size: 14 k
Installed size: 22 k
Is this ok [y/N]: y
Downloading Packages:
epel-release-6-8.noarch.rpm                                                                |  14 kB    00:00   
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de:NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6Official Signing Key) <[email protected]>
 Package:centos-release-6-7.el6.centos.12.3.x86_64 (@anaconda-CentOS-201508042137.x86_64/6.7)
 From  : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing :epel-release-6-8.noarch                                                                          1/1
  Verifying  : epel-release-6-8.noarch                                                                        1/1
 
Installed:
  epel-release.noarch 0:6-8                                                                                       
 
Complete!
[root@localhost yum.repos.d]#

相关推荐