虚拟机创建网卡与硬盘

qemu-img create -f qcow2 disk.img 20G

 

[root@rootroom9pc01 qemu]# cat node3.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
  virsh edit node3
or other application using the libvirt API.
-->

<domain type='kvm'>
  <name>node3</name>
  <uuid>b8062f75-48c0-433a-86b3-f7709346f413</uuid>
  <memory unit='KiB'>2048000</memory>
  <currentMemory unit='KiB'>2048000</currentMemory>
  <vcpu placement='static'>2</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
    <boot dev='hd'/>
    <bootmenu enable='yes'/>
    <bios useserial='yes'/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode='host-passthrough' check='none'/>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/node3.img'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/disk.img'/>
      <target dev='vdb' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </disk>
    <controller type='usb' index='0' model='piix3-uhci'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:fe:0b:e5'/>
      <source bridge='vbr'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='bridge'>
      <mac address='52:54:00:49:4c:11'/>
      <source bridge='private1'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <channel type='unix'>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </memballoon>
  </devices>
</domain>

[root@rootroom9pc01 networks]# cat private1.xml 

<!--

WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE

OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:

  virsh net-edit private1

or other application using the libvirt API.

-->

 

<network>

  <name>private1</name>

  <uuid>559de4a7-724c-4eec-ba19-3c7c2e69b4ad</uuid>

  <bridge name='private1' stp='on' delay='0'/>

  <mac address='52:54:00:37:78:11'/>

  <domain name='private1'/>

  <ip address='192.168.4.254' netmask='255.255.255.0'>

    <dhcp>

      <range start='192.168.4.100' end='192.168.4.200'/>

    </dhcp>

  </ip>

</network>

 

[root@rootroom9pc01 networks]# cd ../

[root@rootroom9pc01 qemu]# ls

demo.xml  networks  node1.xml  node3.xml  win2008.xml

 

Poweroff -p

 

[root@localhost ~]# lsblk

NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

vda    253:0    0  30G  0 disk 

└─vda1 253:1    0  16G  0 part /

 

[root@rootroom9pc01 images]# virsh 

欢迎使用 virsh,虚拟化的交互式终端。

 

输入:'help' 来获得命令的帮助信息

       'quit' 退出

 

virsh # edit node3

<disk type='file' device='disk'>

      <driver name='qemu' type='qcow2'/>

      <source file='/var/lib/libvirt/images/disk.img'/>

      <target dev='vdb' bus='virtio'/>

    </disk>

 

[root@localhost ~]# halt -p

virsh # start node3

域 node3 已开始

virsh # console node3

连接到域 node3

换码符为 ^]

 

 

CentOS Linux 7 (Core)

Kernel 3.10.0-693.el7.x86_64 on an x86_64

 

localhost login: root

Password: 

Last login: Fri Jul 20 15:41:11 on ttyS0

[root@localhost ~]# lsblk

NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

vda    253:0    0  30G  0 disk 

└─vda1 253:1    0  16G  0 part /

vdb    253:16   0  20G  0 disk 

 

Ctril+l

exit

 

电脑内存是TG>GB>MB>KB>K 1TG=1024GB 1GB=1024MB 1MB=1024KB 1KB=1024K 1K=1024B 1B = 8bit 一个中文2个字节 一个英文为1个字节

 

1KB=10^3=1000, 1MB=10^6=1000000=1000KB,1GB=10^9=1000000000=1000MB,而 1KiB=2^10=1024,1MiB=2^20=1048576=1024KiB

猜你喜欢

转载自blog.csdn.net/weixin_40018205/article/details/81125556
今日推荐