Article From:

CentOS 7 install

a. UDisk installation, please select minimal version. (DVD version, later need to put the DVD ISO also in the U disk directory, but DVD over 4G, with NTFS is not good)

b. Make startup disk, Mac can use unetbootin, Win can use the Chinese cabbage that startup U disk production tools, write ISO to the U disk, and copy the original ISO files to the U disk directory

c. Machine insert U disk to start up

d. The Startup menu clicks tab, which appears like vmlinuz initrd = initrd. img inst. stage 2 = hd: LABEL = CentOS x207 x20x86_64 Rd. live. check QuThe words of IET

e. Change from inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 to Linux DD

f. See which Device ISO writes on, such as / dev / sda1 (where unetbootin usually does it), / dev / sda4 (where cabbage is usually).

g. ctrl+alt+delrestart

h. Start menu by tab, change inst. stage 2 = hd: LABEL = CentOS x207 x20x86_64 to inst. stage 2 = hd:/dev/sda1

i. Follow the boot installation can be, remember to choose English language, do not set a password for root, to check the user management of the original option (sudo)

Configuration network card
sudo vi /etc/sysconfig/network-scripts/p4p1

centos6.5Since then, the network card naming method has been modified, using a consistent network device naming method, mainly based on the physical location of the network card, is it integrated or in the PCI slot to name, through this name, network administrators can be very clear about the physical location of the network card?

New name of network card device old name
Integrated network card eth[012…] em[123…]
PCINIC eth[012…] p[slot number]p[network card number]
Virtual NIC eth[012…] p[slot number]p[network card number virtual interface]
This method is implemented by the biosdevname program, which changes the original eth [012.] network card according to certain rules.

Modify ONBOOT=yes, close IPv6

sudo dhclientGet IP and test the network.

Common software package

sudo yum install net-tools lrzsz

centosDefault no ifconfig

kvm,qemuSoftware installation

yum install qemu-kvm qemu-img virt-manager libvirt libvirt-python python-virtinst libvirt-client virt-install virt-viewer
qemu-img:qemuDisk image manager
virt-install:Command line tools for creating virtual machines
libvirt:Provide libvirtd daemon to manage virtual machine and control hypervisor
libvirt-client:Provides client API for accessing server and providing virsh entities for managing virtual machine command line tools.
virt-viewer:Graphic console

Create /data/iso and /data/img, upload /data/iso/CentOS-7-x86_64-Minimal-1611.iso

virt-install –name=dev1 –ram=1024 –vcpus=1 –cdrom=/data/iso/CentOS-7-x86_64-Minimal-1611.iso –os-type=linux –os-variant=rhel7 –network bridge=br0 –graphics=spice –disk path=/data/img/dev1.dsk,size=4

If the following error occurs, ERROR Failed to connect socket to’/ var / run / libvirt / libvirt – sock’: No such file or directorY, please follow the following actions

yum -y install avahi
service messagebus restart
service avahi-daemon restart
service libvirtd restart

First, disable the default network configuration virbr0 of KVM.
virsh net-list #View default KVM network configuration
Delete KVM with default network configuration
virsh net-destroy default
virsh net-undefine default
service libvirtd restart
View network configuration ifconfig

Edit p4p1, VIM ifcfg-p4p1 tail add
Save and exit

Edit ifcfg-br0, VIM ifcfg-br0


Save and exit
After restarting the network service, take effect service network restart

You need to install graphical interfaces, or you can’t see the situation inside the virtual machine, for example, you cannot install CentOS.

yum groupinstall “GNOME DESKTOP”

virt-install –name=dev1 –ram=1024 –vcpus=1 –cdrom=/data/iso/CentOS-7-x86_64-Minimal-1611.iso –os-type=linux –os-variant=rhel7 –network bridge=br0 –graphics=spice –disk path=/data/img/dev1.dsk,size=4
startx,Under gnome, virt-manager is also used for management.

Basic operation of virtual machine
Virtual machine cloning

virt-clone -o dev1 -n dev2 -f /data/img/dev2.dsk

Modify host name

hostnamectl –static set-hostname dev2

Start up

virsh autostart xxx

Destroy virtual machine

virsh undefine xxx

Suspending and restoring virtual machine (when you copy virtual machine, you can use this to suspend the original machine).

virsh suspend xxx
virsh resume xxx

Virtual machine migration
Confirm the virtual machine shutdown state virsh list –all
View the virtual machine case to be migrated virsh domblklist XXX
virsh dumpxml xxx > /root/xxx.xml
scp /root/xxx.xmlTo the new virtual machine
scp dskFile to new virtual machine
In the new virtual machine, place the DSK file in accordance with the location of the previous virsh domblklist XXX.
In the new virtual machine, xxx.xml will be placed in /etc/libvirt/qemu/.
Define virtual machine virsh define /etc/libvirt/qemu/xxx.xml
virsh list –all
virsh start xxx
Virtual machine configuration adjustment
Adjust memory, CPU number.
virsh edit dev1
2. Adjust hard disk size

adjust mirror size.

qemu-img info /data/img/dev1.dsk
qemu-img resize /data/img/dev1.dsk +46G
qemu-img info /data/img/dev1.dsk

> adjust the LVM inside the virtual machine.

fdisk -l

should be able to find a disk name with free space, VM is generally VDA

fdisk /dev/vda
p #View partition
n #Create partitions
p #create primary partition
3 #Create vda3 (fill in numbers according to actual situation)
Using default sector information
t #Modify partition type
3 #Modify vda3
8e #Type modified to 8e
w #Save configuration

configuration effective


pvcreate /dev/vda3
pvs #View the volume and expand according to the VG name.
vgextend cl /dev/vda3
lvs #View volumes
lvextend -l +100%FREE /dev/cl/root

CentOS default use of XFS filesystem (according to DF – H result)

xfs_growfs /dev/mapper/cl-root

Leave a Reply

Your email address will not be published. Required fields are marked *