Saturday 28 September 2013

Migrating VMs from Redhat to Ubuntu

Recently I have installed Kubuntu onto my PC and had some Virtual Machines that I had used on a Centos machine under Virt-Manager/KVM that I needed to use on the Kubuntu system. I thought this would be a simple enough process but ran into some problems.

When trying to start up VMs in Virt-Manager on Ubuntu I got the following message:-

 error: Failed to start domain blackhat.example.net supported
 machines are 
...

To fix this I initially created a new VM to see what types it supported it does support Redhat VMs. Once this was created I viewed the XML for the image with the following command:-

 virsh dumpxml test

test being the name of the new VM I had created. The following line was relevant:-

 <type arch='x86_64' machine='pc-1.0'>hvm</type>  

In my other VM I saw the following:-

 <type arch='x86_64' machine='rhel6.2.0'>hvm</type>  

So the problem is machine='rhel6.2.0' to change this run the following command:-

 virsh edit blackhat.example.net  

Then change 'rhel6.2.0' to 'pc-1.0' it should then boot

Monday 9 September 2013

ssh in a loop

Using ssh in a loop will break the loop to fix this use the -n flag, i.e:-

while read server
do
   echo $server
   ssh -n $server "ls -l /etc/rc.modules"
   echo
done < servers

Tuesday 3 September 2013

Show vendor when searching through installed RPMs

This is done using the %{VENDOR} tag. For example:-

rpm -qa --qf '%{NAME}-%{VERSION}-%{RELEASE} %{VENDOR}\n'

Monday 2 September 2013

Highlight all occurences of selected word in vi

To do this:-

:set hlsearch

To undo this:-

:nohlsearch

Show line numbers in vi

:set number

Rebuild RPM DB

This may need to be done in instances where simple commands such as rpm -qa hang. Steps:-
  1. Kill all rpm and yum processes
  2. yum clean all
  3. rm -f /var/lib/rpm/__db*
  4. rpm -v --rebuilddb
  5. yum makecache