libvirt: Creating a Centos 7 VM: Failed to start Switch Root
I also wondered why /sysroot seemed incomplete as a cause of the failed Switch Root startup. Turned out, ultimately, that once the guest took over the install it could not actually read from the install source. In my case the cause was the network config to virt-install (see below), for you the problem is the same but the cause is different as you are installing from a local source. I think this is the issue (from the virt-install man page):
DIRECTORY
Path to a local directory containing an installable distribution image. Note that the directory will not be accessible by the guest after initial boot, so the OS installer will need another way to access the rest of the install media.
You might try including the path to the install image/dvd/directory using another --disk parameter to virt-install.
--disk=path=/path/to/rhel7-dvd.iso,device=cdrom
For anyone else poking around here with the same problem but trying to install from the network - the problem is the same. A solution required an ip address to be assigned (in my case static) to the guest. However, this did not immediately fix the problem either because of my --location setting using the domain name of the install. I also had to include a dns parameter to --extra-args to finally get this working.
sudo virt-install --name test-c7 --ram 2048 --vcpus=1 --os-type=linux --os-variant=centos7.0 --network bridge=br0 --disk size=4 --location http://linux.mirrors.es.net/centos/7/os/x86_64 --graphics none --extra-args="ip=128.97.60.95::128.97.60.1:255.255.255.0:scylla.idre.ucla.edu:eth0:none dns=128.97.62.3 console=tty0 console=ttyS0,115200n8"
Related videos on Youtube
Sean Leather
Updated on September 18, 2022Comments
-
Sean Leather almost 2 years
I'm trying to create a VM of Centos 7 (1611) on the same distribution using
virt-install
. I'm using an example script from a list by Remy van Elst, which required a few changes:virt-install \ --name centos7 \ --ram 1024 \ --disk path=./centos7.qcow2,size=8 \ --vcpus 1 \ --os-type linux \ --os-variant centos7.0 \ --network default \ --graphics none \ --console pty,target_type=serial \ --location /media/CentOS \ --extra-args 'console=ttyS0,115200n8 serial'
The directory
/media/CentOS
contains a mountedCentOS-7-x86_64-Everything-1611.iso
.The boot process fails with:
[FAILED] Failed to start Switch Root. See 'systemctl status initrd-switch-root.service' for details.
Then, it enters an “emergency mode” shell. The log of the above service is:
:/# systemctl status initrd-switch-root.service -l ● initrd-switch-root.service - Switch Root Loaded: loaded (/usr/lib/systemd/system/initrd-switch-root.service; static; vendor preset: enabled) Active: failed (Result: exit-code) since Fri 2017-04-14 08:17:31 UTC; 19min ago Process: 3981 ExecStart=/usr/bin/systemctl --no-block --force switch-root /sysroot (code=exited, status=1/FAILURE) Main PID: 3981 (code=exited, status=1/FAILURE) systemd[1]: Starting Switch Root... systemctl[3981]: Failed to switch root: Specified switch root path /sysroot does not seem to be an OS tree. os-release file is missing. systemd[1]: initrd-switch-root.service: main process exited, code=exited, status=1/FAILURE systemd[1]: Failed to start Switch Root. systemd[1]: Unit initrd-switch-root.service entered failed state. systemd[1]: Triggering OnFailure= dependencies of initrd-switch-root.service. systemd[1]: initrd-switch-root.service failed.
Looking at
/sysroot
, it's clearly does not haveos-release
anywhere::/# find /sysroot /sysroot /sysroot/var /sysroot/var/lib /sysroot/var/lib/nfs /sysroot/var/lib/nfs/rpc_pipefs /sysroot/var/lib/nfs/rpc_pipefs/gssd /sysroot/var/lib/nfs/rpc_pipefs/gssd/clntXX /sysroot/var/lib/nfs/rpc_pipefs/gssd/clntXX/gssd /sysroot/var/lib/nfs/rpc_pipefs/gssd/clntXX/info /sysroot/var/lib/nfs/rpc_pipefs/nfsd /sysroot/var/lib/nfs/rpc_pipefs/cache /sysroot/var/lib/nfs/rpc_pipefs/nfsd4_cb /sysroot/var/lib/nfs/rpc_pipefs/statd /sysroot/var/lib/nfs/rpc_pipefs/portmap /sysroot/var/lib/nfs/rpc_pipefs/nfs /sysroot/var/lib/nfs/rpc_pipefs/mount /sysroot/var/lib/nfs/rpc_pipefs/lockd /sysroot/boot /sysroot/boot/initramfs-3.10.0-514.el7.x86_64.img
I'm not sure how to proceed from here. I've seen a number of posts around the Internet that describe something similar, but none of them seem to describe my particular problem or any solution to it.
-
Stephen Rauch about 7 yearsGood first answer. I would caution however about thanking the OP in an answer. It can look like a thanks and not an answer. And thanks can end up getting deleted...