Month: May 2011

  • HOWTO: Extract Directory from Mercurial Repo with Full History

    Extract a directory out of an existing Mercurial repo into a new, top level repo with full revision history. For example, you have:
    <Project A>/<sub project B>
    and you want to make <sub project B> its own repo.

    # File: HOWTOExtractDirectoryIntoStandaloneRepoMercurial.notes
    # Auth: burly
    # Date: 03/01/2011
    # Refs: http://mercurial.selenic.com/wiki/ConvertExtension
    #       http://www.jmedved.com/2010/09/extracting-part-of-mercurial-repository/
    # Desc: Extract directory out of an existing Mercurial repo into
    #       a new, top level repo with full revision history.
    #       e.g. You have <Project A>/<sub project B> and 
    #       you want to make <sub project B> it's own repo.
    
    #Enable hg convert
    vim ~/.hgrc
    
    ######## BEGIN COPY BELOW THIS LINE ###########
    [extensions]
    convert =
    ########## END COPY ABOVE THIS LINE ############
    
    # Clone the repo you want to extract from
    mkdir ~/tmp
    cd ~/tmp
    hg clone /path/to/yer/repo-to-clone
    
    # Make a filemap of the items you want to keep. 
    vim filemap.txt
    
    ########## BEGIN COPY BELOW THIS LINE #########
    include WindowsPowerEvents
    rename WindowsPowerEvents .
    ############ END COPY ABOVE THIS LINE ########
    
    # Extract the desired folder with the convert extension
    hg convert --filemap filemap.txt repo-to-clone new-repo-name
    
    # (Optionally) Import this repo into the primary location you want it
    cd /path/to/primary/repo/location
    hg pull ~/tmp/new-repo-name
    
  • HOWTO: VMWare Server on CentOS 5.4

    I have a habit of creating .notes files whenever I’m doing system admin type work. I’ve collected a number of these over the years and I refer back to them fairly regularly whether I’m doing something similar or just looking for a specific command. I’ll be placing a bunch of these up here for easier access for me as well as public consumption in case anyone else finds them useful. They will be posted pretty much unedited, so they won’t be in the same “format” as I’ve used in the past, but hopefully they are sufficiently legible :-).

    Installation and Configuration of VMWare Server 2.x on CentOS 5.4 and 5.5. These instructions should mostly work on 5.0-5.6, note however that the glibc workaround is only necessary on 5.4 and 5.5. VMWare Server is no longer supported by VMWare but I continue to use it until I can upgrade my hardware to be ESXi compatible.

    # File: HOWTO_VMwareServer_on_CentOS_5.4.notes
    # Auth: burly
    # Date: 02/28/2010
    # Refs: http://www.cyberciti.biz/tips/vmware-on-centos5-rhel5-64-bit-version.html
    #       http://sanbarrow.com/vmx/vmx-config-ini.html
    #       http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=844
    #       http://pubs.vmware.com/vi301/resmgmt/wwhelp/wwhimpl/common/html/wwhelp.htm?context=resmgmt&file=vc_advanced_mgmt.11.32.html
    # Desc: Installation of VMware Server 2.0.2 on CentOS 5.4 x86-64
    
    # Download VMware Server 2.x
    
    # Install dependencies
    yum install gcc gcc-c++ kernel-headers kernel-devel libXtst-devel libXrender-devel xinetd
    
    # Install VMware server
    rpm -ivh VMware-server-2.x.x-XXXXX.<arch>.rpm
    
    # Configure VMware server
    vmware-config.pl
    
    # Answer the series of questions. My answers are below:
    Networking: yes
    Network Type: Bridge
    Network Name: Bridged
    . vmnet0 is bridged to eth0
    NAT: no
    Host-only: no
    remote connectiosn port: 902
    http connections: 8222
    https connections: 8333
    Different Admin: yes
    Admin user: <my user account>
    VM File Location: /vwmare/vms
    VMware VIX API files: Default locations
    
    # ##########################################################
    # Deal with the hostd/glibc compatilibity issues of VMware 
    # Server 2.x w/ CentOS 5.4 - 5.5 (no issues with CentOS 5.3 
    # and earlier or CentOS 5.6. VMware Server had not addressed
    # this as of VMware Server 2.0.2-203138
    
    # Get the necessary glibc file from 5.3
    mkdir ~/vmwareglibc
    cd ~/vmwareglibc
    wget http://vault.centos.org/5.3/os/x86_64/CentOS/glibc-2.5-34.x86_64.rpm
    rpm2cpio glibc-2.5-34.x86_64.rpm | cpio -ivd
    
    # Stop the vmware service and kill any instances of hostd
    service vmware stop
    killall vmware-hostd
    
    # Move the libc file 
    mkdir /usr/lib/vmware/lib/libc.so.6
    mv lib64/libc-2.5.so /usr/lib/vmware/lib/libc.so.6/libc.so.6
    
    # Edit the VMware hostd process script
    vim /usr/sbin/vmware-hostd
    
    # At line 372, before the program is called, insert an
    # empty line and the following
    export LD_LIBRARY_PATH=/usr/lib/vmware/lib/libc.so.6:$LD_LIBRARY_PATH
    
    # Start the vmware service
    service vmware start
    
    # Set the service to run on startup
    chkconfig vmware on
    
    # -----------------------------------------------------------------------------
    #                           Optional Performance Tunings
    # -----------------------------------------------------------------------------
    
    # -------------------------------------
    #    Server-wide Host VMware Settings
    # -------------------------------------
    
    # The following changes are made in /etc/vmware/config
    
    # Fit memory into RAM whenever possible and don't ballon
    # and shrink memory as needed.
    prefvmx.useRecommendedLockedMemSize="TRUE"
    prefvmx.minVmMemPct = "100"
    
    # By default, VMware will back the guest's main memory with
    # a file the size of  the guest's nominal RAM in the working
    # directory (next to the vmdk). If we turn this off, then in
    # Linux the memory backed file will be created in the 
    # temporary directory while on Windows it will be back by the 
    # host's swap file. On Linux hosts, if we turn off named file
    # backing AND use a shared memory file system in RAM for the 
    # temporary directory, we will miss the disk completely
    # unless we are out of RAM on the host system.
    mainMem.useNamedFile = "FALSE"
    tmpDirectory = "/dev/shm"
    
    # The following changse are made in /etc/sysctl.conf
    # Disabling the kernel from over committing memory and only
    # using swap when physical memory has been exhausted helps
    # overall performance (vm.swapiness). The maximum user 
    # frequency covers how fast a virtual machine can set 
    # it's tick count to. The vm.dirty options tune how the
    # VM subsystem commits I/O operations to disk, you may 
    # not want to tune these values if you do not have a
    # stable power source.
    # http://peterkieser.com/technical/vmware-server-issues/
    vm.swappiness = 0
    vm.overcommit_memory = 1
    vm.dirty_background_ratio = 5
    vm.dirty_ratio = 10
    vm.dirty_expire_centisecs = 1000
    dev.rtc.max-user-freq = 1024
    
    
    # -------------------------------------
    #            Host OS Settings
    # -------------------------------------
    
    # In order for the VMWare configuration to work properly 
    # with shared memory, you'll need to increase the default
    # shared memory size for tmpfs to match the amount of
    # memory in your system. This can be done by
    # editing /etc/fstab
    tmpfs                   /dev/shm                tmpfs   size=8G                    0 0
    
    # In order for the tmpfs changes to take effect, 
    # remount the tmpfs
    mount -o remount /dev/shm
    
    # The following changes are made in /etc/rc.d/rc.local
    
    # Read ahead on the hard drive should be set to an
    # optimal value I have found an optimal value is
    # between 16384 and 32768.
    # http://peterkieser.com/technical/vmware-server-issues/
    blockdev --setra 32768 /dev/md1
    
    # The following items are added as boot-time options
    # to the kernel for the host. To enable these values,
    # add them to /boot/grub/menu.lst at the end of the
    # kernel line.
    
    # On the host operating system, consider using deadline 
    # I/O scheduler (enabled by adding elevator=deadline to
    # kernel boot parameters), and noop I/O scheduler in
    # the guest if it is running Linux 2.6; using the noop 
    # scheduler enables the host operating system to better 
    # optimize I/O resource usage between different virtual machines.
    # http://peterkieser.com/technical/vmware-server-issues/
    elevator=deadline
    
    # -------------------------------------
    #            Per VM Settings
    # -------------------------------------
    
    # The following changes are made to the guest's vmx file
    
    # If we have enough RAM for all the guests to have their
    # memory in physical RAM all the time, then we can avoid 
    # the ballooning (grow/shrinking) to save CPU cycles. 
    # Note this will force the VMware hypervisor to swap
    # rather than balloon if it's in need of memory. 
    # Swapping is less desirable than ballooning.
    sched.mem.maxmemctl = 0
    
    # Disable memory sharing for the VM. This prevents the
    # hypervisor from scanning the memory pages for places
    # to de-dup memory across VMs and save space. This scanning
    # doesn't come free however, and if we have enough physical
    # RAM to support all of our VMs, then we don't really need
    # the savings.
    sched.mem.pshare.enable = "FALSE"
    mem.ShareScanTotal = 0
    mem.ShareScanVM = 0
    mem.ShareScanThreshold = 4096
    
    
    # The VMware clock synchronization features are a bit
    # problematic. If the guest clock gets behind,then VMware
    # will catch it up by trying to issue all of the missed
    # ticks until it is caught up. However, if the guest gets
    # ahead, then the VMware clock will not bring it back. So,
    # I am going to use ntp on the guest machines. If you have
    # a large number of guests, it's best to setup a local ntpd
    # server to offload some of the traffic from the root pools.
    tools.syncTime = "FALSE"
    
    # When I reboot the host, I want to gracefully stop each
    # VM instead of just powering it off:
    autostop = "softpoweroff"
    
    # -------------------------------------
    #            Guest OS Settings
    # -------------------------------------
    
    # The following items are added as boot-time options to 
    # the kernel for the host. To enable these values, add
    # them to /boot/grub/menu.lst at the end of the kernel line.
    
    # On the host operating system, consider using deadline I/O
    # scheduler (enabled by adding elevator=deadline to kernel
    # boot parameters), and noop I/O scheduler in the guest if it 
    # is running Linux 2.6; using the noop scheduler enables the 
    # host operating system to better optimize I/O resource usage
    # between different virtual machines.
    # http://peterkieser.com/technical/vmware-server-issues/
    elevator=noop
    
    # The following kernel boot parameters will help performance 
    # and stability using Linux 2.6 as a guest. APCI/APIC support
    # must be enabled if you plan on using SMP virtualization in
    # the guest.Setting the clock to PIT has shown to have better
    # time keeping than other clock sources, your mileage may vary. 
    # Setting elevator to noop will enable the host operating 
    # system to better schedule I/O as it has an overview of the
    # whole system as opposed to just one virtual machine.
    # http://peterkieser.com/technical/vmware-server-issues/
    
    # The current (March 3, 2010) guidance from VMware is that 
    # clocksource is no longer required in CentOS 5.4 Use this 
    # guide to determine what time keeping settings you need
    # for your Guest OS
    # http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006427
    
    # CentOS 5.4 x86_64 Guest
    divider=10 elevator=noop
    
  • TortoiseSVN Cache (TSVNCache.exe) and Disk I/O

    I’ve had a long standing fight with TortoiseSVN‘s TSVNCache.exe both in terms of disk I/O performance and it holding locks to files/folders I want to work with. Turns out that you can set which directories it watches with an include/exclude list under Settings->Icon Overlays.

    Thanks to Travis Illig for the blog post on this issue: http://www.paraesthesia.com/archive/2007/09/26/optimize-tortoise-svn-cache-tsvncache.exe-disk-io.aspx

    For what it’s worth, my patterns are:

    Exclude: C:\*
    Include:
    C:\Users\<username>\Documents\Visual Studio 2008\Projects\*
    C:\Users\<username>\Documents\Visual Studio 2010\Projects\*

    Note the trailing ‘\*’, which seemed necessary to get it working for me. I killed TSVNCache.exe after saving the preference changes and then went to some SVN working copy folders. I watched TSVNCache.exe briefly in procmon and it seems that it’s only accessing the specified directories now.