[Libguestfs] Cannot login after modification shadow file with guestmount

Richard W.M. Jones rjones at redhat.com
Fri Apr 20 21:49:46 UTC 2012

On Fri, Apr 20, 2012 at 05:48:06PM +0400, Daneel Yaitskov wrote:
> I have a VM with CentOs6.2 on KVM.   I mount an image of the VM when it's
> not working with guestmount:
> root at diehard:~# guestmount -a named-centos.img -i tmp
> vi /etc/shadow

Hopefully you edited the guest's tmp/etc/shadow, not your host's
/etc/shadow ...

> insert comment line into the file (esc yy p 0 i # esc :wq!), save changes,
> unmount the image, turn on the VM, and I cannot login.
> I cannot login even if I recover the shadow file.

Not much information to go on here, but my guess is that /etc/shadow
has the wrong permissions or SELinux context after you edited it.

We recently fixed this bug in virt-edit:
but that doesn't help you if you're using guestmount.

These are what they should be on a RHEL 6 system:

  $ ll -Z /etc/shadow
  ----------. root root system_u:object_r:shadow_t:s0    /etc/shadow

If that doesn't help, have a look for the error (/var/log/messages,
/var/log/secure, or /var/log/audit/audit.log):

  $ guestfish --ro -a named-centos.img -i
  ><fs> less /var/log/messages


Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.

More information about the Libguestfs mailing list