Extending an existing LVM on a virtual machine

Quick and dirty steps, this  work on all hypervisor.

1a. Add more space to the existing disk. On VMware, if the drive is thin provisioned, grow it to the new additional space.
1b. If the drive is thick, or you don’t know how to grow the disk. Add an additional disk drive.
2a. I like to move to runlevel one where nothing should be running. Use lsblk to find where the disk is mounted, dismount the directory(ies) and run fdisk against the physical disk drive (fdisk /dev/sdb for instance)
2b. If I had to add a drive we’ll need to scan for the drive, use:
/usr/bin/rescan-scsi-bus.sh or echo “- – -” > /sys/class/scsi_host/hostX/scan
Once you have that, you’ll be able to view the disk with fdisk. Use lsblk to ID the new device and use fdisk /dev/sdX to create a new partition on it.
3a. I know this sounds crazy, but delete the partition on the disk containing the mount point you want to extend. Now recreate the partition using the default values to use up all the new space. Set the partition type to 8e for LVM. Write the changes.
3b. With our new drive we need to give it a partition, select creating a new partition in fdisk. Set the format type to LVM with 8e. Write the changes
4a. Use pvextend to grow the disk. Use pvextend /dev/sdX# to grow the partition
4b. Add this new disk to the volume group with vgextend vgname /dev/sdX#
5. Finally, grow the logical volume with lvextend -r -l +100%FREE /dev/mapper/vgname

In the final command, -r will execute resize2fs for you automatically. Don’t forget the plus sign in front of the 100% otherwise it will not grow the partition even if the command executes successfully.


SVN blues – committing a file that doesn’t appear to have changed

So recently I had an issue where I needed to commit a Truecrypt file in SVN, but as you probably already know, when you save content in Truecrypt, the file appears to be untouched to SVN. The modified date doesn’t change, nor does the size of the file. So, how to we check-in our changes?

A co-worker generously gave me this tip, so I’m passing it on to you:

from the CLI

#svn propset dummyproperty 1
#svn commit

By changing the properties of the file with useless info we can fool SVN into letting us check-in our file!


Using sips on Mac OSX for cli image manipulation

So in my last post I on the Cisco ASA I wanted to insert a screen shot I had taken on my Mac. The problem was that capture saves images as .tiff And, I know you can change this default from the cli, but there are other times when I really just need to convert an image from one format to the next quickly.

Sips lets you do that. So, that unhelpful .tiff file can become a jpeg or png file in a jiffy. Also, this works on PDFs.

Here’s the magic:
mbp$ sips -s format jpeg .tiff –out .jpeg

Specify your desired file format after format. That’s it kids! Good to go. If you want to be really fancy, you can make a cronjob or automator job to do this every so often against the directory you keep your screen shots in.

VMware ESXi 4.1 and the lost host

So, came in today, and fire alarms are going off, people are planning evacuations, ‘VMware is down’ I hear someone mutter as a enter the room.

Sure enough, last night at some point one of my ESXi 4.1 boxes lost it’s mind and disconnected from vSphere. Several hours later I got it back and here is what I learned:

I logged into vCenter and one of the boxes was connected, the other was not. I tried to reconnect it from vCenter, and that failed. So began the process ever system admin goes though when stuff is broke, we go to our hierarchy of problems, I think most of us have this stored in our brains.

  • Can I ping it? Yes
  • Can I ssh to it? Yes
  • Can I log into it vSphere Client? No Hum…
  • Are servers on that box still running? Unknown (I couldn’t get this work from the cli: vim-cmd vmsvc/getallvms )
  • Can I ping servers that where on that box running? No

So off to Google I went and I’ll leave links below for the pages that help me get to the solution.

First Error Message: Call “Datacenter.QueryConnectionInfo” for object “<DataCenter name>” on vCenter Server “<vCenter name>” failed.


Ok, so at this point we can probably assume the box is jacked up really good. But, we don’t know if the VMs are running, rebooting the box would be rude for the guest.
We could try restarting the management agents >  /sbin/services.sh restart
Ok, still can’t connect, someone else mentions starting > /etc/opt/init.d/vmware-vpxa restart
Still no dice, getting frustrated didn’t work and says something about like “Failed to login” when I run vim-cmd vmsvc/getallvms or any other commands

Finally came across some things to test:

ls -l /etc/vmware/hostd/proxy.xml if this returns 0 for the file size, that’s your problem. Replace this file from another ESX server and you should be good.


Shoe Drop:


Other Links:





scanning for scsi devices in CentOS 6




Recently I ran into a situation where passing the “- – -” values to iscsi_host/host#/scan didn’t work for me. I was sure that I had run this before on CentOS6, but to no avail I could not find a value in the /host portion.


So, this what I discovered! The friendly folks at Red Hat have created a script for dealing with this.


Do this:


1. yum install sg3_utils
2. run rescan-scsi-bus.sh (they added it to the path 😉 booyah!)


Now you should have your drive all discovered and ready for fdisk!


Here’s the original link for this info: https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/rescan-scsi-bus.html


Script to delete files on a Windows 7 or 2008 box

So recently I found myself needing to do some log management of some custom logs I was writing to disk. Put this guy in a .bat file and use task manager to keep things in check:

forfiles -p “c:\logs\nginx” -s  -m *.* -d  -1 /C “cmd /c del @PATH”

Two important things to watch out for. After the path CAN NOT include a backslash ‘\’ That will stop it from running. Second, after the -d is the number of days old that you want it to delete. 

Maybe next I’ll create a script to zip the logs and ship them off somewhere.