07 April, 2009

Timing VM Startup Script

In my previous post I eluded to creating a script for timing the starting of a virtual machine.

This is it, use at your leisure:


#!/bin/csh

set i=0
while ( $i < starttime="`date" addr="192.168.2.24" response="1" response ="=">> /dev/null
set response=$status
end
set stopTime=`date +%s`

set secs=`expr $stopTime - $startTime`
echo "startUp: $secs (secs)"

sleep 10
vmrun -T 127.0.0.1 -h 'https://127.0.0.1:8333/sdk' -u vmadmin -p 'vmadminpassword' stop "[standard] JltvWinXp/JltvWinXp.vmx"
set i=`expr $i + 1`
end

The script loops 5 times to get a crude sampling. Each iteration, the virtual machine is started then monitored via a ping until the VM is pingable. It then sleeps some 10 seconds before commanding the virtual machine to shutdown.

06 April, 2009

VmRun Command

I've been recently tailoring a WinXp virtual machine to accelerate the OS initialization. To measure the impacts I've created a script that repeatedly times the starting of the VM. In particular, I'm measuring how long it takes between initiated startup and the time it takes before I can ping the virtual machine.

The first challenge was to decode the vmware-cmd (now vmrun) syntax. The following is an example of how you can start a virtual machine.


vmrun -T 127.0.0.1 -h 'https://127.0.0.1:8333/sdk' -u vmadmin -p 'vmadminpassword' start "[standard] JltvWinXp/JltvWinXp.vmx"

05 April, 2009

Querying Unix Time

Just a quick post of a useful feature of querying the Unix time (seconds since Epoch) that I find useful in various scripts.

I'm posting it because time and again I find the need to use it and repeatedly spend time re-looking up what the syntax consists of.


$ date +%s
1227918465

03 April, 2009

External USB Disk - NTFS Mount

In my last post I eluded to purchasing an Seagate FreeAgent Xtreme external hard-drive and was woefully disappointed in the inability to mount it from Linux and gain write permissions. This is how I resolved it for Debian 4.0 - AMD64 distro.

I 'fixed' this by reformatting the drive as a FAT32 file system which technically resolved the issue, but FAT32 didn't support my needs as I needed to store large files (5+ Gigs) on the drive.

I later found that if I installed the ntfs-3g driver and mounted it using this file system type that I could in fact read and write to the drive.


# vi /etc/apt/sources.list


Adding this line:

deb http://www.backports.org/debian etch-backports main


Followed by:

# apt-get update
# apt-get install ntfs-3g


then, define the mount point and edit the /etc/fstab as follows:

# mkdir /media/usbdisk

and add this line to /etc/fstab

/dev/sdc1 /media/usbdisk ntfs-3g rw,user,noauto 0 0



# mount /media/usbdisk


Ta-Da.

28 March, 2009

Seagate FreeAgent External USB Disk

I should really learn; I had a moment of weakness and impulse purchased a Seagate FreeAgent 500Gb external usb disk drive. I needed an external drive to 'sneaker net' between work and home. I often do significant work at home to avoid the dreaded 'information technology' security policies that prevent any common person from performing their job. If I'm not careful, this will quickly work into a rant about IT.

Anyway, I walked into my neighborhood MicroCenter and debated between a few external usb drives of similar prices. I left with the Seagate not paying any attention to the supported operating systems...hell, they always identify flavors of Windows and an occasional Mac, few vendors recognize Linux but no worries....should work fine.

Well, Linux mounted it read-only because it encountered the following error (from dmesg):

scsi1 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
Vendor: Seagate Model: FreeAgent XTreme Rev: 4113
Type: Direct-Access ANSI SCSI revision: 04
scsi 1:0:0:0: Attached scsi generic sg1 type 0
usb-storage: device scan complete
SCSI device sda: 976773168 512-byte hdwr sectors (500108 MB)
sda: Write Protect is off
sda: Mode Sense: 1c 00 00 00
sda: assuming drive cache: write through
SCSI device sda: 976773168 512-byte hdwr sectors (500108 MB)
sda: Write Protect is off
sda: Mode Sense: 1c 00 00 00
sda: assuming drive cache: write through
sda: sda1
sd 1:0:0:0: Attached scsi disk sda
NTFS driver 2.1.27 [Flags: R/W MODULE].
NTFS-fs warning (device sda1): parse_options(): Option iocharset is deprecated. Please use option nls= in the future.
NTFS volume version 3.1.
NTFS-fs error (device sda1): load_system_files(): $LogFile is not clean. Mounting read-only. Mount in Windows.


I resolved by deleting the NTFS partition, create a new primary partition of FAT32 as follows:

# fdisk /dev/sda1
d 1
n p 1
w
q
# mkdosfs -vF 32 /dev/sda1


No longer NTFS, but at least I can mount it from Windows or Linux. Kept me from throwing it through the window.

Raw Video Conversions

mplayer -demuxer rawvideo -rawvideo w=640:?h=480:y8:size=307200:fps=8 -sb 32 mt01.arf -dumpvideo
ffmpeg -r 8/1 -s 640x480 -f rawvideo -pix_fmt gray -i stream.dump -vcodec rawvideo /tmp/video.avi

Scripting System Beep

Sometimes you want to incorporate an audible cue in your script that something is happening, or an indication that a manual effort is required. Cue system beep:

in Bash,

echo -e "\007"

or

echo -e "\a"


will do the trick, just make sure the system beep is enabled and not set to a visual cue.