虚拟机知识

源码安装lxc

```

```

lxc创建容器

lxc源码安装(./configure --prefix=/xx, 是其lxc-ls存放目录)

容器创建后存放目录 ~/.local/share/lxc/,如果是root,存放在 /var/lib/lxc

```
lxc-checkconfig

lxc-create -n test -t none

# 查看当前系统中可用LXC模板容器
ls /usr/share/lxc/templates/

# 会联网下载
lxc-create -n test1 -t /usr/share/lxc/templates/lxc-centos 
lxc-create -t centos -n test4

# 安装libvirtd, 新增网卡virbrt0

# 启动lxc(启动前先chroot)
lxc-start -n test2 -d
lxc-start -n test0 -f ./config --logfile=/tmp/1.log

lxc-attach -n test0
```

qemu创建镜像

```
qemu-img create -f qcow2 fed.img 2G

wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2.xz

qemu-img info CentOS-7-x86_64-GenericCloud.qcow2

qemu-img create fed2.qcow2 2M

qemu-img create -f qcow2 -b CentOS-7-x86_64-GenericCloud.qcow2 bb.qcow2

qemu-img info bb.qcow2


```

virsh创建虚拟机

virsh list --all

Resources