An attempt to use virt-install to create a CentOS 7 guest virtual machine on a CentOS 7 host is generating the following error:
Could not open '/root/CentOS-7-x86_64-Minimal-1611.iso': Permission denied
What specific steps need to be taken to resolve this error, so that the CentOS 7 guest virtual machine can be successfully installed?
The details are as follows:
Steps To Reproduce The Error:
First, I downloaded the iso
file from a centos mirror:
[root@remote-host ~]# wget http://centos.mbni.med.umich.edu/mirror/7/isos/x86_64/CentOS-7-x86_64-Minimal-1611.iso
--2017-03-13 12:52:53-- http://centos.mbni.med.umich.edu/mirror/7/isos/x86_64/CentOS-7-x86_64-Minimal-1611.iso
Resolving centos.mbni.med.umich.edu (centos.mbni.med.umich.edu)... 141.214.186.162
Connecting to centos.mbni.med.umich.edu (centos.mbni.med.umich.edu)|141.214.186.162|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 713031680 (680M) [application/octet-stream]
Saving to: ‘CentOS-7-x86_64-Minimal-1611.iso’
100%[============================================================================================================================>] 713,031,680 14.2MB/s in 50s
2017-03-13 12:53:43 (13.5 MB/s) - ‘CentOS-7-x86_64-Minimal-1611.iso’ saved [713031680/713031680]
Next, I ran the following installation command, which resulted in the error:
[root@remote-host ~]# virt-install \
> --name centos7 \
> --ram 2048 \
> --disk path=/dev/mapper/centos-third,size=242 \
> --vcpus 1 \
> --os-type generic \
> --os-variant generic \
> --network bridge=virbr0 \
> --graphics none \
> --console pty,target_type=serial \
> --cdrom ./CentOS-7-x86_64-Minimal-1611.iso
WARNING CDROM media does not print to the text console by default, so you likely will not see text install output. You might want to use --location. See the man page for examples of using --location with CDROM media
Starting install...
ERROR internal error: qemu unexpectedly closed the monitor: 2017-03-13T19:58:02.701397Z qemu-kvm: -drive file=/root/CentOS-7-x86_64-Minimal-1611.iso,format=raw,if=none,id=drive-ide0-0-1,readonly=on: could not open disk image /root/CentOS-7-x86_64-Minimal-1611.iso: Could not open '/root/CentOS-7-x86_64-Minimal-1611.iso': Permission denied
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect qemu:///system start centos7
otherwise, please restart your installation.
[root@remote-host ~]#
To assess the permission problem, I reviewed the contents of the directory, as follows:
[root@remote-host ~]# ls -al
total 696356
dr-xr-x---. 4 root root 4096 Mar 13 12:52 .
dr-xr-xr-x. 24 root root 4096 Mar 13 12:00 ..
-rw-------. 1 root root 2365 Mar 12 11:14 anaconda-ks.cfg
-rw-------. 1 root root 1091 Mar 13 12:13 .bash_history
-rw-r--r--. 1 root root 18 Dec 28 2013 .bash_logout
-rw-r--r--. 1 root root 176 Dec 28 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 28 2013 .bashrc
drwxr-xr-x. 4 root root 36 Mar 13 12:42 .cache
-rw-r--r--. 1 qemu qemu 713031680 Dec 5 15:44 CentOS-7-x86_64-Minimal-1611.iso
drwxr-xr-x. 3 root root 17 Mar 13 10:52 .config
-rw-r--r--. 1 root root 100 Dec 28 2013 .cshrc
-rw-r--r--. 1 root root 129 Dec 28 2013 .tcshrc
Though I know that root
should be able to access any other user's files, I tried changing the user to root
and re-running the command as follows:
[root@remote-host ~]# chown root:root CentOS-7-x86_64-Minimal-1611.iso [root@remote-host ~]# ls -al
total 696356
dr-xr-x---. 4 root root 4096 Mar 13 12:52 .
dr-xr-xr-x. 24 root root 4096 Mar 13 12:00 ..
-rw-------. 1 root root 2365 Mar 12 11:14 anaconda-ks.cfg
-rw-------. 1 root root 1091 Mar 13 12:13 .bash_history
-rw-r--r--. 1 root root 18 Dec 28 2013 .bash_logout
-rw-r--r--. 1 root root 176 Dec 28 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 28 2013 .bashrc
drwxr-xr-x. 4 root root 36 Mar 13 12:42 .cache
-rw-r--r--. 1 root root 713031680 Dec 5 15:44 CentOS-7-x86_64-Minimal-1611.iso
drwxr-xr-x. 3 root root 17 Mar 13 10:52 .config
-rw-r--r--. 1 root root 100 Dec 28 2013 .cshrc
-rw-r--r--. 1 root root 129 Dec 28 2013 .tcshrc
[root@remote-host ~]# virt-install --name centos7 --ram 2048 --disk path=/dev/mapper/centos-third,size=242 --vcpus 1 --os-type generic --os-variant generic --network bridge=virbr0 --graphics none --console pty,target_type=serial --cdrom ./CentOS-7-x86_64-Minimal-1611.iso
WARNING CDROM media does not print to the text console by default, so you likely will not see text install output. You might want to use --location. See the man page for examples of using --location with CDROM media
Starting install...
ERROR internal error: qemu unexpectedly closed the monitor: 2017-03-13T20:06:07.525792Z qemu-kvm: -drive file=/root/CentOS-7-x86_64-Minimal-1611.iso,format=raw,if=none,id=drive-ide0-0-1,readonly=on: could not open disk image /root/CentOS-7-x86_64-Minimal-1611.iso: Could not open '/root/CentOS-7-x86_64-Minimal-1611.iso': Permission denied
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect qemu:///system start centos7
otherwise, please restart your installation.
[root@remote-host ~]#
[root@remote-host ~]# virsh --connect qemu:///system start centos7
error: failed to get domain 'centos7'
error: Domain not found: no domain with matching name 'centos7'
[root@remote-host ~]#
As you can see, I got the same error. What else needs to be done to resolve this error, so that the guest virtual machine can be installed successfully?
root
? Or If I am not understanding something, what specifically do I try to test your theory?iso
to another user's root folder and change the line to become:--cdrom /home/some_other_username/CentOS-7-x86_64-Minimal-1611.iso
. What else can I try?ls -lZ /tmp/*.iso
to see the SELinux contexts, too./tmp
resolved this error, and moved the problem forward to what is actually a different error. If you want to write yours up as an answer, I would be happy to mark it as accepted.