Thursday, October 04, 2012

I have a Cloudstack VHD template I want to modify - now what?

vdfuse -f virtdisk.vhd /somedir
losetup /dev/loop0 /somedir/Partition2

file Partition2
Partition2: LVM2 PV (Linux Logical Volume Manager), UUID: 20dMth-jvua-lFfN-j1a9-4iar-acFF-xoI3Pa, size: 20949499904
pvscan

lvm vgchange -ay

       2 logical volume(s) in volume group "VolGroup" now active
lvs
  LV      VG       Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  lv_root VolGroup -wi-a- 11.80g                                      
  lv_swap VolGroup -wi-a-  7.70g       
mount /dev/mapper/VolGroup-lv_root /mount/lv_root

when done:
vgchange -an
losetup -d /dev/loop0

DONE!

Monday, October 01, 2012

MySQL Pager Trick

I got tired of always having to set the pager (\P) in mysql cli, so I set up an alias in my bash profile:


alias mysql="mysql --pager='less -niS'"

Now, I get nice tabular formatted output in my queries.

Centos 6.x VMs on CloudStack

If you want to create a template for deploying Centos 6 VMs, you need to do a few things to the VM before snapshotting the root volume and converting it into a template:

  • yum -y update (of course)
  • set the root password to a well known one ("password" comes to mind)
  • delete the SSH keys in /etc/ssh/ so on first boot sshd will generate new keys
  • rm /etc/udev/rules.d/70-persistent-net.rules
  • yum -y install vim :)
  • edit /etc/sysconfig/network-scripts/ifcfg-eth0 to look like:
    • DEVICE=eth0
    • BOOTPROTO=dhcp
    • ONBOOT=yes
    • TYPE=Ethernet
That should get you going.