Wednesday, April 13, 2011

Upgrade to CentOS 5.6 and KVM failure

Recently I have upgraded my KVM server from Centos 5.5 to 5.6  I can no longer boot any of virtual machines. While trying to boot VM its gives error...  

Booting from Hard Disk...
Boot failed: not a bootable disk

FATAL: No bootable device

My all VMs are qcow2 format, quick Googling reports its issue with the 'type=raw' in .xml file for the VM.


<driver name='qemu' type='raw'/>

Fixed:
Change the type='qcow2' in xml file, so that its read something like this

<driver name='qemu' type='qcow2'/>

And restart the libvirtd service.

This fixed all the KVM VMs for me.

Linux Tips and Tricks - Display the IPs on interfaces

Using ifconfig

FIBER_ADDR=$(ifconfig $FIBER | grep 'inet addr' | sed 's/^[^:]\+://;s/\([^ \t]\+\).\+$/\1/')
echo $FIBER_ADDR

Same using IP command

ip addr show | awk '/inet[^6]/ { print $2 }' | sed -e 's/\(.\+\)\/.\+/\1/'

Monday, April 11, 2011

Find the disk space used by a user

To find the disk space being used by a single user, you need to combine du with the find command to only report disk usage for a specific user:

$ find . -user username -type f -exec du -k {} \;

To get total disk used

$ find . -user username -type f -exec du -k {} \;|awk '{ s = s+$1 } END { print "Total used: ",s }'

You use the same principle with groups using the -group option to find

find . -group mcslp -type f -exec du -k {} \;|awk '{ s = s+$1 } END { print "Total used: ",s }'

Friday, April 8, 2011

Creating thumbnails on a fly using ImageMagick

To create thumbnails for all the JPG files in the current directory

for img in *.jpg; do convert -resize 200 "$img" thumb_"$img";done

Thursday, April 7, 2011

Linux Tips & Tricks

Removing commented lines '#' from a file
grep -v '^#' squid.conf > squid.conf.new

to remove empty lines from a text file. I've been using sed with
sed '/^ *$/d' squid.conf.new > squid.conf.nospace

Do the same thing with sed in one line
sed '/^#/d' squid.conf.default | sed /^$/d > squid.conf.new

Or
sed -e '/^\(#\|$\)/ d' squid.conf.default > squid.conf.new

Remove comments and blank lines from a file
egrep -v '^(#|$)' squid.conf.default > squid.conf.new

Or
grep '^[^#]' squid.conf > squid.conf.new