ubuntu-kvm-builder 失败,提示“/dev/mapper/loop0p1 不存在”

ubuntu-kvm-builder 失败,提示“/dev/mapper/loop0p1 不存在”

使用 ubuntu 15.10,我只是尝试使用 kvm 创建虚拟机并按照网络上的一些说明进行操作,但没有成功。运行时似乎失败并出现mkfs.ext4以下错误:The file /dev/mapper/loop0p1 does not exist and no size was specified.

我已经安装了这些:

sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils virt-manager

命令

ubuntu-vm-builder kvm trusty \
                  --domain newvm \
                  --dest newvm \
                  --arch i386 \
                  --hostname hostnameformyvm \
                  --mem 256 \
                  --user john \
                  --pass doe \
                  --bridge br0 \
                  --dns 8.8.8.8 \
                  --mirror http://us.archive.ubuntu.com/ubuntu \
                  --components main,universe \
                  --addpkg acpid \
                  --addpkg vim \
                  --addpkg openssh-server \
                  --libvirt qemu:///system ;

输出

2016-02-05 13:04:27,082 INFO    : logging to file: /tmp/tmpODnkhw
2016-02-05 13:04:27,161 INFO    : Calling hook: preflight_check
2016-02-05 13:04:27,164 INFO    : Calling hook: set_defaults
2016-02-05 13:04:27,165 INFO    : Calling hook: bootstrap
2016-02-05 13:09:00,044 INFO    : Calling hook: configure_os
Extracting templates from packages: 100%
2016-02-05 13:09:58,368 INFO    : invoke-rc.d: policy-rc.d denied execution of start.
2016-02-05 13:09:59,776 INFO    : Creating SSH2 RSA key; this may take some time ...
2016-02-05 13:10:00,332 INFO    : Creating SSH2 DSA key; this may take some time ...
2016-02-05 13:10:00,338 INFO    : Creating SSH2 ECDSA key; this may take some time ...
2016-02-05 13:10:00,352 INFO    : Creating SSH2 ED25519 key; this may take some time ...
2016-02-05 13:10:01,404 INFO    : invoke-rc.d: policy-rc.d denied execution of start.
2016-02-05 13:10:13,530 INFO    :
2016-02-05 13:10:13,531 INFO    : Current default time zone: 'Etc/UTC'
2016-02-05 13:10:13,533 INFO    : Local time is now:      Fri Feb  5 18:10:13 UTC 2016.
2016-02-05 13:10:13,534 INFO    : Universal Time is now:  Fri Feb  5 18:10:13 UTC 2016.
2016-02-05 13:10:13,534 INFO    :
Extracting templates from packages: 100%
2016-02-05 13:10:53,208 INFO    :
2016-02-05 13:10:53,208 INFO    : Current default time zone: 'Etc/UTC'
2016-02-05 13:10:53,210 INFO    : Local time is now:      Fri Feb  5 18:10:53 UTC 2016.
2016-02-05 13:10:53,212 INFO    : Universal Time is now:  Fri Feb  5 18:10:53 UTC 2016.
2016-02-05 13:10:53,212 INFO    : Run 'dpkg-reconfigure tzdata' if you wish to change it.
2016-02-05 13:10:53,212 INFO    :
2016-02-05 13:10:56,277 INFO    : invoke-rc.d: policy-rc.d denied execution of stop.
2016-02-05 13:11:47,834 INFO    : invoke-rc.d: policy-rc.d denied execution of stop.
2016-02-05 13:11:51,507 INFO    : invoke-rc.d: policy-rc.d denied execution of start.
2016-02-05 13:11:52,909 INFO    : invoke-rc.d: policy-rc.d denied execution of restart.
2016-02-05 13:12:01,982 INFO    : invoke-rc.d: policy-rc.d denied execution of start.
2016-02-05 13:12:05,980 INFO    : invoke-rc.d: policy-rc.d denied execution of restart.
2016-02-05 13:12:20,074 INFO    : Cleaning up
2016-02-05 13:12:20,085 INFO    : Calling hook: preflight_check
2016-02-05 13:12:20,609 INFO    : Calling hook: configure_networking
2016-02-05 13:12:20,656 INFO    : Calling hook: configure_mounting
2016-02-05 13:12:20,665 INFO    : Calling hook: mount_partitions
2016-02-05 13:12:20,665 INFO    : Mounting target filesystems
2016-02-05 13:12:20,665 INFO    : Creating disk image: "/tmp/tmpMijS7P" of size: 5120MB
2016-02-05 13:12:20,956 INFO    : Adding partition table to disk image: /tmp/tmpMijS7P
2016-02-05 13:12:21,104 INFO    : Adding type 4 partition to disk image: /tmp/tmpMijS7P
2016-02-05 13:12:21,104 INFO    : Partition at beginning of disk - reserving first cylinder
2016-02-05 13:12:21,111 INFO    : Warning: The resulting partition is not properly aligned for best performance.
2016-02-05 13:12:21,164 INFO    : Adding type 3 partition to disk image: /tmp/tmpMijS7P
2016-02-05 13:12:21,171 INFO    : [0] ../../libparted/filesys.c:148 (ped_file_system_type_get): File system alias linux-swap(new) is deprecated
2016-02-05 13:12:21,205 INFO    : Creating loop devices corresponding to the created partitions
2016-02-05 13:12:21,306 INFO    : Creating file systems
2016-02-05 13:12:21,365 INFO    : mke2fs 1.42.12 (29-Aug-2014)
2016-02-05 13:12:21,365 INFO    : The file /dev/mapper/loop0p1 does not exist and no size was specified.
2016-02-05 13:12:21,367 INFO    : Cleaning up
2016-02-05 13:12:24,493 ERROR   : Process (['mkfs.ext4', '-F', '/dev/mapper/loop0p1']) returned 1. stdout: , stderr: mke2fs 1.42.12 (29-Aug-2014)
The file /dev/mapper/loop0p1 does not exist and no size was specified.

Traceback (most recent call last):
  File "/usr/bin/ubuntu-vm-builder", line 24, in <module>
    uvb.main()
  File "/usr/lib/python2.7/dist-packages/VMBuilder/contrib/cli.py", line 228, in main
    hypervisor.install_os()
  File "/usr/lib/python2.7/dist-packages/VMBuilder/hypervisor.py", line 65, in install_os
    self.call_hooks('mount_partitions', self.chroot_dir)
  File "/usr/lib/python2.7/dist-packages/VMBuilder/distro.py", line 67, in call_hooks
    call_hooks(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/VMBuilder/util.py", line 170, in call_hooks
    getattr(context, func)(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/VMBuilder/hypervisor.py", line 91, in mount_partitions
    disk.mkfs()
  File "/usr/lib/python2.7/dist-packages/VMBuilder/disk.py", line 151, in mkfs
    part.mkfs()
  File "/usr/lib/python2.7/dist-packages/VMBuilder/disk.py", line 306, in mkfs
    self.fs.mkfs()
  File "/usr/lib/python2.7/dist-packages/VMBuilder/disk.py", line 374, in mkfs
    run_cmd(*cmd)
  File "/usr/lib/python2.7/dist-packages/VMBuilder/util.py", line 120, in run_cmd
    raise VMBuilderException, "Process (%s) returned %d. stdout: %s, stderr: %s" % (args.__repr__(), status, mystdout.buf, mystderr.buf)
VMBuilder.exception.VMBuilderException: Process (['mkfs.ext4', '-F', '/dev/mapper/loop0p1']) returned 1. stdout: , stderr: mke2fs 1.42.12 (29-Aug-2014)
The file /dev/mapper/loop0p1 does not exist and no size was specified.

我知道我的 CPU 支持虚拟化:

$ sudo kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

答案1

这与此相关这个错误,并提交了修复,并在错误描述中提供了解决方法。要解决此问题,请编辑 disk.py 文件。

sudo nano /usr/lib/python2.7/dist-packages/VMBuilder/disk.py

找到 map_partitions 方法,并在其末尾添加“time.sleep(3)”。相关部分应该如下所示:

        for (part, mapdev) in zip(self.partitions, mapdevs):
            part.set_filename('/dev/mapper/%s' % mapdev)
        time.sleep(3)

    def mkfs(self):

请记住,空格在 Python 中是有意义的,因此请确保缩进正确。

相关内容