Virt-install: error: unrecognized arguments: (but no arguments listed)

centos7kvm-virtualizationvirtualization

Been trying to create my first VM with KVM but getting a cryptic error from virt-install. It's saying I have a 'unrecognized arguments' but does not say which argument:

$ sudo virt-install \
>             --name centos7_vm1 \
>             --memory 1024 \
>             --disk /data/kvm_images/centos7-vm1.qcow2,device=disk \
>             --disk /data/kvm_images/centos7-vm1.iso,device=cdrom \
>             --os-type linux \
>             --os-variant centos7.0 \
>             --virt-type kvm \
>             --graphics none \
>             --network default \
>             --import
usage: virt-install --name NAME --memory MB STORAGE INSTALL [options]
virt-install: error: unrecognized arguments:                                                                                                                        
$

Looking at docs and general googling cant work out what is wrong. Ime running CentOS 7, virt-install 1.5.0.

$ ls -l /data/kvm_images
total 70584
-rw------- 1 qemu qemu 26847870976 May 11 00:06 centos7-docker.qcow2
-rw-r--r-- 1 root root      374784 May 11 14:35 centos7-vm1.iso
-rw-r--r-- 1 root root    68026368 May 11 14:02 centos7-vm1.qcow2
-rw-r--r-- 1 root root         104 May 11 14:33 centos7-vm1.setup.yaml
$

Here are what I did to get this far

The first thing I did was download the image

$ wget wget https://cloud.centos.org/centos/7/images/CentOS-7-ppc64le-GenericCloud-2003.qcow2

Then checked it seemed OK

$ qemu-img info CentOS-7-ppc64le-GenericCloud-2003.qcow2

image: CentOS-7-ppc64le-GenericCloud-2003.qcow2c
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 395M
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false

Then I resized it to twenty-five GB

$ qemu-img resize CentOS-7-ppc64le-GenericCloud-2003.qcow2 25G

And used qemu-img convert

$ sudo qemu-img convert -f qcow2 -O qcow2 CentOS-7-ppc64le-GenericCloud-2003.qcow2 /data/kvm_images/centos7-vm1.qcow2

I then created a file centos7-vm1.setup.yaml

#cloud-config
password: xxxxxxxxxx
chpasswd: { expire: False }
ssh_pwauth: True
hostname: centos7-vm1

and run

$ sudo cloud-localds centos7-vm1.iso centos7-vm1.setup.yaml

Best Answer

Something is weird there for sure. That error comes from python argparse so it's not anything virt-install is doing explicitly. I'm guessing you have some weird whitespace or something on your command line that argparse is interpreting as an explicit command line argument.

Try writing that command out by hand with no line breaks and see if virt-install still complains.