init=/bin/bashto the kernel boot line in GRUB do not work. The only option left is to boot from a rescue disc, but this is a virtual machine -- there is no DVD drive. Oh, no -- what to do?
NEWS FLASH: I just learned from a colleague that there is a much easier method. It is possible to
chrootdirectly into the VM from the virtualization host. Will post detailed instructions as soon as I get them. Until then, there is always the "long route" described below.
Fortunately, it's not as difficult as it might seem. I already published a related blog entry entitled "KVM: boot VM from PXE or ISO image", but it doesn't quite do the trick. Here is a more complete description of the entire process:
- Obtain an ISO image of my preferred Rescue CD/DVD (pretty much any one will do for this operation)
- On the KVM virtualization server, put this ISO into a directory such as
- Find the XML file with the definition of your VM -- let's say it's
- Open that file in your favorite editor
- In the
<os>section, add a
bootstanza immediately above the existing boot stanzas:
- In the
<devices>section, add a
diskstanza for the ISO:
<disk type 'file' device='cdrom'> <source file='/var/tmp/[FILENAME].iso'/> <target dev='hdc' bus='ide'/> <readonly/> </disk>
virsh shutdown [host]or, failing that,
virsh destroy [host]
# virsh create /home/smithfarm/kvm/host.xml
blkidcommand can be helpful. If there are multiple candidates, just mount them one by one and look for the telltale signs of a root filesystem.
chrootinto the root filesystem like so:
# mount -o rw /dev/sda2 /mnt # mount --bind /dev /mnt/dev/ # mount --bind /proc /mnt/proc/ # mount --bind /sys /mnt/sys/ # chroot /mnt target#
target# exit # umount /mnt/sys # umount /mnt/proc # umount /mnt/dev # umount /mnt
# shutdown -h now
virsh createand enjoy logging in with new root password.