0

Using ubuntu 15.10, I'm simply trying to create a VM using kvm and followed some instructions on the web, but no success. It seems to fail when running mkfs.ext4 with this error: The file /dev/mapper/loop0p1 does not exist and no size was specified.

I've installed these:

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

Command

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 ;

Output

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.

I know that my CPU supports virtualization:

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

This is related to this this bug, with a fix committed, and a workaround in the bug description. For the workaround edit the disk.py file.

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

Look for the map_partitions method, and add 'time.sleep(3)' to the end of it. The relevant portion should end up like this:

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

    def mkfs(self):

Keep in mind that whitespace has meaning in Python, so do make sure the indention is correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.