CentOS 7 cloud image login failed after yum upgrade

General support questions
Post Reply
User avatar
LubinLew
Posts: 3
Joined: 2022/08/02 08:03:26

CentOS 7 cloud image login failed after yum upgrade

Post by LubinLew » 2022/08/03 00:35:46

Hi,
I want to make a new centos7 cloud image based on offical image. But when I did the yum update, I got login failed.
Please help !

1.download image

Code: Select all

wget https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2
2.do yum update and set root password

Code: Select all

virt-sysprep -a CentOS-7-x86_64-GenericCloud-2009.qcow2 --network --update --root-password password:root
3.load the image with kvm

centos7.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<domain type="kvm">
  <name>centos7</name>
  <memory unit="GiB">8</memory>
  <vcpu>4</vcpu>
  <os>
    <type arch="x86_64" machine="pc">hvm</type>
    <boot dev="hd"></boot>
  </os>
  <clock offset="localtime"></clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2"></driver>
      <source file="/home/lubin/CentOS-7-x86_64-GenericCloud-2009.qcow2"></source>
      <target dev="vda" bus="virtio"></target>
     </disk>
    <interface type="bridge">
      <source bridge="virbr0"></source>
      <model type="virtio"></model>
     </interface>
    <input type="tablet" bus="usb"></input>
    <input type="mouse" bus="ps2"></input>
    <graphics type="vnc" port="5936" listen="0.0.0.0" autoport="no" keymap="en-us"></graphics>
   </devices>
</domain>

Code: Select all

vrish define centos7.xml
virsh start centos7
4.login in the VNC Viewer Terminal, failed.

/var/log/secure

Code: Select all

Aug  2 16:30:59 localhost sshd[822]: Server listening on 0.0.0.0 port 22.
Aug  2 16:30:59 localhost sshd[822]: Server listening on :: port 22.
Aug  2 09:21:24 localhost login: pam_systemd(login:session): Failed to create session: Access denied
Aug  2 09:21:24 localhost login: pam_unix(login:session): session opened for user root by LOGIN(uid=0)
Aug  2 09:21:24 localhost login: ROOT LOGIN ON tty1
Aug  2 09:21:24 localhost login: pam_unix(login:session): session closed for user root
/var/log/messages

Code: Select all

Aug  2 09:21:26 localhost systemd-logind: Failed to start user slice user-0.slice, ignoring: Access denied (org.freedesktop.DBus.Error.AccessDenied)
Aug  2 09:21:26 localhost systemd-logind: Failed to start session scope session-2.scope: Access denied
Aug  2 09:21:26 localhost systemd: getty@tty1.service has no holdoff time, scheduling restart.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: CentOS 7 cloud image login failed after yum upgrade

Post by TrevorH » 2022/08/03 12:18:31

virt-sysprep -a CentOS-7-x86_64-GenericCloud-2009.qcow2 --network --update --root-password password:root
At a guess, this has corrupted the selinux context on the /etc/passwd and shadow files. Either boot with enforcing=0 on the kernel command line then restorecon -RFv /etc/passwd /etc/shadow or touch /.autorelabel and reboot.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
LubinLew
Posts: 3
Joined: 2022/08/02 08:03:26

Re: CentOS 7 cloud image login failed after yum upgrade

Post by LubinLew » 2022/08/08 00:43:58

TrevorH wrote:
2022/08/03 12:18:31
virt-sysprep -a CentOS-7-x86_64-GenericCloud-2009.qcow2 --network --update --root-password password:root
At a guess, this has corrupted the selinux context on the /etc/passwd and shadow files. Either boot with enforcing=0 on the kernel command line then restorecon -RFv /etc/passwd /etc/shadow or touch /.autorelabel and reboot.
@TrevorH

touch /.autorelabel works.

Thanks you very much !

Post Reply