3

I am using KVM to install a virtual machine, and after that the image will be uploaded to create an OpenStack virtual machine instance. I am using the following commands:

  1. create image:

    qemu-img create -f qcow2 ubuntu.img 20G
    
  2. Install virtual machine (the ubuntu-14.04-server-amd64.iso is in the current directory):

    kvm -cdrom ubuntu-14.04-server-amd64.iso -drive file=ubuntu.img,if=virtio,index=0 -boot d -net nic -net user
    

But when I'm installing the virtual machine I get

mount: mounting /dev/vda on /media failed: Invalid argument
unmount: can't unmount /media: Invalid argument
mount: mounting /dev/fd0 on /media failed: No such device or address

messages in terminal

And at the end, it reported:

An installation step failed. You can try to run the failing item again from the menu, or skip it and choose something else. The failing step is: Load installer components from CD.

dialog popup in terminal

$ ls /dev
autofs           hwrng   loop1             nbd2                ram12   shm       tty21  tty41  tty61      ttyS22   vcs1
block            i2c-0   loop2             nbd3                ram13   snapshot  tty22  tty42  tty62      ttyS23   vcs2
bsg              i2c-1   loop3             nbd4                ram14   snd       tty23  tty43  tty63      ttyS24   vcs3
btrfs-control    i2c-10  loop4             nbd5                ram15   sr0       tty24  tty44  tty7       ttyS25   vcs4
bus              i2c-11  loop5             nbd6                ram2    stderr    tty25  tty45  tty8       ttyS26   vcs5
cdrom            i2c-12  loop6             nbd7                ram3    stdin     tty26  tty46  tty9       ttyS27   vcs6
char             i2c-13  loop7             nbd8                ram4    stdout    tty27  tty47  ttyprintk  ttyS28   vcsa
console          i2c-14  loop-control      nbd9                ram5    tty       tty28  tty48  ttyS0      ttyS29   vcsa1
core             i2c-2   mapper            ndctl0              ram6    tty0      tty29  tty49  ttyS1      ttyS3    vcsa2
cpu              i2c-3   mcelog            net                 ram7    tty1      tty3   tty5   ttyS10     ttyS30   vcsa3
cpu_dma_latency  i2c-4   media0            network_latency     ram8    tty10     tty30  tty50  ttyS11     ttyS31   vcsa4
cuse             i2c-5   mei0              network_throughput  ram9    tty11     tty31  tty51  ttyS12     ttyS4    vcsa5
disk             i2c-6   mem               null                random  tty12     tty32  tty52  ttyS13     ttyS5    vcsa6
dri              i2c-7   memory_bandwidth  port                rfkill  tty13     tty33  tty53  ttyS14     ttyS6    vfio
ecryptfs         i2c-8   nbd0              ppp                 rtc     tty14     tty34  tty54  ttyS15     ttyS7    vga_arbiter
fb0              i2c-9   nbd1              psaux               rtc0    tty15     tty35  tty55  ttyS16     ttyS8    vhci
fb1              input   nbd10             ptmx                sda     tty16     tty36  tty56  ttyS17     ttyS9    vhost-net
fd               kfd     nbd11             pts                 sda1    tty17     tty37  tty57  ttyS18     uhid     video0
full             kmsg    nbd12             ram0                sda2    tty18     tty38  tty58  ttyS19     uinput   zero
fuse             kvm     nbd13             ram1                sda5    tty19     tty39  tty59  ttyS2      urandom
hidraw0          log     nbd14             ram10               sg0     tty2      tty4   tty6   ttyS20     v4l
hpet             loop0   nbd15             ram11               sg1     tty20     tty40  tty60  ttyS21     vcs

How can I fix it and install the virtual machine?

Zanna
  • 70,465
  • I'm not familiar with the Qemu/KVM command-line tools, but I use virt-manager as GUI front-end to create, configure, manage and run those VMs. I don't know if trying that would be an option for you. – Byte Commander Jun 18 '16 at 14:19
  • @ByteCommander, please show your answer, maybe it helps! – GoingMyWay Jun 18 '16 at 14:24
  • 2
    Well, you would just have to sudo apt-get install virt-manager and then launch it. Its graphical user interface is almost self-explaining, you should have no problems with that. What might happen is that you run into permission problems because some files are not owned by the correct users or groups, but usually it should work. I found an expert for the Qemu/KVM command-line interface though and he will post an answer within the next few minutes as well, I think. – Byte Commander Jun 18 '16 at 14:28
  • Have a look at the related area of the Ubuntu Serverguide. – Doug Smythies Jun 18 '16 at 14:54
  • @ByteCommander, thank you very much. The answer is helpful. – GoingMyWay Jun 18 '16 at 15:35

1 Answers1

3

The main problem is that the virtual disk you have created is not formatted, it is just a raw disk without a partition table. Another issue is that you selected the format qcow2 and created an .img file. You have to execute this command : qemu-img create -f qcow2 ubuntu.qcow2 20G.

Download the latest stable version of GParted Live | Direct download link -> GParted 0.26.1-1

Insert the ISO file and the virtual disk, boot from the GParted ISO file, create a new partition table, new partitions and and format them. Here is a presentation on how to prepare a disk.
This is an advanced advice, creating the partition table and format it with ext4 is sufficient.

kvm -hda ubuntu.qcow2 -cdrom gparted-live-0.26.1-1-amd64.iso -boot d -enable-kvm  

After the operation is finished close (poweroff) GParted Live to shutdown the virtual machine. Now insert the Ubuntu Server 14.04 installation media and start the installation of the system.

kvm -hda ubuntu.qcow2 -cdrom ubuntu-14.04-server-amd64.iso -boot d -enable-kvm  

Note : These are the basic commands - choose the paths where the files are located and add additional boot options that fit your needs, for instance the amount of memory (-m 8192).

cl-netbox
  • 31,163
  • 7
  • 94
  • 131
  • Hi, thank you. after typing kvm -hda ubuntu.qcow2 -cdrom gparted-live-0.26.1-1-amd64.iso -boot d -enable-kvm, and enter the default setting, it report end kernel panic - not syncing: vfs: unable to mount root fs on unknown block(2,0). See this http://askubuntu.com/questions/41930/kernel-panic-not-syncing-vfs-unable-to-mount-root-fs-on-unknown-block0-0?rq=1 – GoingMyWay Jun 19 '16 at 02:02
  • I can make openstack mirror now thank you! http://docs.openstack.org/image-guide/index.html – GoingMyWay Jun 19 '16 at 03:17