我一直在尝试使用cloud-init和qemu。这就是我启动VM的方式:
qemu-system-x86_64 \
--enable-kvm \
-nographic \
-m 2G -smp 4 \
-drive file=/disks/mustafa.img,if=virtio \
-cdrom /disks/my-seed.img \
-device virtio-net,netdev=network0,mac=52:55:00:d1:55:01 \
-netdev tap,id=network0,ifname=tap0,script=no,downscript=no
尊重的元数据和用户数据文件是:
instance-id: 49380625-37c5-48b0-8a2b-60bd1392519a
network:
version: 2
ethernets:
interface0:
match:
macaddress: 52:55:00:D1:55:01
set-name: eth0
addresses:
- 172.17.0.2/255.255.0.0
gateway4: 172.17.0.1
这是用户数据,不是真正相关,而是无论如何。
#cloud-config
password: passw0rd
chpasswd: { expire: False }
ssh_pwauth: True
但它挂起以下输出:
[ OK ] Started Network Time Synchronization.
[ OK ] Reached target System Time Synchronized.
[ 6.148261] blk_update_request: I/O error, dev fd0, sector 0
[ 6.168261] blk_update_request: I/O error, dev fd0, sector 0
[ OK ] Started Update UTMP about System Boot/Shutdown.
[ 6.188260] blk_update_request: I/O error, dev fd0, sector 0
[ OK ] Started Set console font and keymap.
[ OK ] Created slice system-getty.slice.
[ 6.044744] cloud-init[417]: Cloud-init v. 0.7.9 running 'init-local' at Sat, 13 May 2017 14:49:10 +0000. Up 5.67 seconds.
[ OK ] Started Initial cloud-init job (pre-networking).
[ OK ] Reached target Network (Pre).
[ OK ] Started LSB: AppArmor initialization.
Starting Raise network interfaces...
[ *** ] A start job is running for Raise ne... interfaces (2min 25s / 5min 1s)
我做错了什么?我看过https://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v2.html
顺便说一句,以下工作完美:
instance-id: 49380625-37c5-48b0-8a2b-60bd1392519a
network-interfaces: |
auto ens3
iface ens3 inet static
address 172.17.0.2
netmask 255.255.0.0
gateway 172.17.0.1
但我不想使用静态接口名称,并使它们与主机匹配。