Monday, December 11, 2017

Setting root password on qcow2 image

In case of necessity to inject root password in qcow2 image file to OpenStack or KVM virtualization environtment this is easy/simple way to do:

# yum install libguestfs-tools-c
# virt-customize -a <image.qcow2> --root-password password:<password>

* Obs.: OS RHEL 'like'.

Thursday, June 1, 2017

Setting up DNS resolution for KVM/libvirt guests locally

I decide write this post after realize a few labs in my notebook for poc's purposes, this very useful in case what you don't need setup a complex DNS server (bind), So, Bellow there all steps what I've done to take advantage from 'dnsmasq' which already running over the RHEL7 host with libvirt/kvm to configure a DNS Server using /etc/hosts to register all of my guests hosts.

In this example I'm using "" as fictitious domain name locally for kvm environment.

From the hypervisor/host(perspective), steps:

# virsh net-dumpxml default
<network connections='1'>
  <forward mode='nat'>
      <port start='1024' end='65535'/>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='51:53:00:bc:17:5b'/>
  <domain name='' localOnly='yes'/> 
  <ip address='' netmask=''>
      <range start='' end=''/>

Still in hypervisor KVM, adding names to the instances in the "/etc/hosts" file, all these names will be used for the vms:
# vi /etc/hosts   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6   vm3   vm4   vm5   vm6
# vi /etc/NetworkManager/conf.d/localdns.conf 
# vi /etc/NetworkManager/dnsmasq.d/libvirt_dnsmasq.conf 
* Restart all relative services like, NetworkManager, dnsmasq, libvirtd.
After deploy/provisioning instances in the KVM(virt-mananger/virsh), just point out 
resolv.conf to the IP of the hypervisor host server(KVM) in my case ( 

Wednesday, May 31, 2017

Mounting basic filesystem's for RHEL7 troubleshooting

Mounting basic 'fs' to realize Linux troubleshooting in the rescue/recovery/maintenance mode, RHEL>7, CentOS>7.
When grub pop-up set up the kernel to initialize in single mode(1), editing the 'vmlinuz' line adding 'init=/sysroot/bin/bash'.

Bellow all the fs should be mounted to help in the maintenance mode, before 'chroot' the root fs "/".

# mount -t proc none /sysroot/proc
# mount -t sysfs none /sysroot/sys
# mount -t devtmpfs none /sysroot/dev
# mount -t devpts none /sysroot/dev/pts
# mount -t tmpfs none /sysroot//dev/shm
# mount -t tmpfs none /sysroot//run

And then 

# chroot /sysroot/