RevRagnarok's blog - Bloghttp://www.revragnarok.com/blog/blog
RevRagnarok's Blogen-USTrac 1.2.2RevRagnarok's bloghttp://www.revragnarok.com/img/license.jpghttp://www.revragnarok.com/blog/blog
RHEL/CentOS/VMWare pissed me offRevRagnarokTue, 02 Feb 2010 02:13:26 GMThttp://www.revragnarok.com/blog/blog/CentOS_Blew_It
http://www.revragnarok.com/blog/blog/CentOS_Blew_It<p>
<em>(Originally posted 25 Oct 09, lost in server mishap, found in Google's cache of this page)</em>
</p>
<p>
I <em>cannot</em> believe that a point release would hose me up so badly...
</p>
<ul><li><a class="ext-link" href="http://bugs.centos.org/view.php?id=3884"><span class="icon">​</span>http://bugs.centos.org/view.php?id=3884</a>
<ul><li>You can see what I did to fix it listed at the bottom
</li></ul></li></ul>rantvmwarelinuxVMWare Client Running on Fedora 9RevRagnarokMon, 27 Oct 2008 17:21:59 GMThttp://www.revragnarok.com/blog/blog/2008/10/27/08.07
http://www.revragnarok.com/blog/blog/2008/10/27/08.07<p>
What a pain! You have to get the latest open-vm-tools from SourceForge. Do a <code>configure</code> and <code>make &amp;&amp; make check</code>. But then you cannot actually <em>install</em> the files or VMWare gets pissy.
</p>
<p>
After the <code>make</code> you need to pack up the kernel files you have created and patch the <em>real</em> VMWare installer with them:
</p>
<pre class="wiki">for i in *; do mv ${i} ${i}-only; tar -cf ${i}.tar ${i}-only; done
cp *tar /usr/lib/vmware-tools/modules/source/
</pre><p>
Then you can run the standard <code>vmware-tools-config.pl</code> and it will use the source you just upgraded.
</p>
<p>
<em>This page was assembled from various net resources...</em>
</p>
vmwarelinuxToday I created a yum repositoryRevRagnarokFri, 01 Aug 2008 05:19:17 GMThttp://www.revragnarok.com/blog/blog/2008/07/31/20.10
http://www.revragnarok.com/blog/blog/2008/07/31/20.10<p>
This is what happens when you are at work and you have ISOs for the 6 CDs of CentOS 5.2 but NOT the DVD, and no connection to the 'net... I couldn't use the 5.2 installer thanks to <a class="ext-link" href="http://bugs.centos.org/view.php?id=2912"><span class="icon">​</span>this bug</a> (it's an embedded Celeron 650). Since I went thru all the work, I also then imported the directory as a "shared folder" under VMWare player and then did the same upgrade path on that machine (I want it to mirror the embedded machine for all versions of everything, except it also has the gcc suite, etc).
</p>
<h2 id="OneTimeOnly">One Time Only</h2>
<p>
(This can be done on any Linux machine with the external drive connected)
</p>
<ul><li>I mounted the external drive under Linux and there are the 6 ISO CDs. I mounted each and then upgraded what was on it that we already had installed.
</li><li><code>cd /media/ext_drive/&lt;install dir&gt;</code>
</li><li><code>mkdir mnt</code>
</li><li><code>mount -o ro,loop &lt;CDFILE&gt;.iso mnt</code>
</li><li><code>cp -urv mnt/CentOS .</code>
<ul><li>If I were doing this again, I may mount the 6 as <code>/mnt1</code> thru <code>/mnt6</code> and then try to use <code>cp -l</code> to make links?
</li><li>(Optionally in another window to watch progress: <code>watch -d 'lsof -c cp -s | cut -c37- | grep rpm '</code> )
</li></ul></li><li><code>umount mnt</code>
</li><li>(Repeat for all 6 - this gives us a CentOS subdir with all the RPMs. If I had the DVD instead of the 6 CDs, this would've been easier)
</li><li>Now we will make this new directory into an "official" repository
</li><li><code>cd CentOS</code>
</li><li><code>rpm -i createrepo*rpm</code> (glad that was there!)
</li><li><code>mkdir repo_cache</code>
</li><li><code>createrepo -v -p -d -c repo_cache --update --skip-stat .</code>
<ul><li>This step takes <em>forever</em> (even longer than the copying above)
</li><li>With a DVD image, this is most likely not even needed!
</li></ul></li></ul><h2 id="EveryTargetMachine">Every Target Machine</h2>
<ul><li>We need to disable all the remote repositories:
<ul><li>Edit <code>/etc/yum.repos.d/CentOS-Base.repo</code> and add <code>enabled=0</code> to every section
</li><li>Edit <code>/etc/yum.repos.d/CentOS-Media.repo</code> and change to <code>enabled=1</code>
<ul><li>Depending on where the external hard drive is, <code>baseurl</code> will need an added path to it
<ul><li>When I did it, it was <code>file:///media/ext_drive/LinuxInstallers/CentOS-5.2-i386-bin-1to6/CentOS/</code>
</li></ul></li><li>There is a <a class="ext-link" href="http://bugs.centos.org/view.php?id=2661"><span class="icon">​</span>known bug in 5.1</a> - the GPG signature key should be <code>RPM-GPG-KEY-CentOS-5</code> (not "<code>beta</code>")
</li></ul></li></ul></li><li><code>yum clean all</code>
</li><li><code>yum install yum-protect-packages</code>
</li><li><code>yum upgrade yum</code>
</li><li><code>yum clean all</code>
</li><li><code>yum upgrade --exclude=kernel\* -y | tee upgrade.log</code>
<ul><li>(Optionally in another window to watch progress: <code>watch -n1 'lsof -c yum -s | cut -c43- | grep rpm '</code> )
</li></ul></li><li><code>grep warn upgrade.log</code>
<ul><li>For this, you need to <code>diff</code> each file with the <code>.rpmnew</code> file or <code>.rpmold</code> file and merge them together.
</li></ul></li><li>Reboot!
</li></ul>vmwarelinuxCompressing VMWare imagesRevRagnarokSun, 16 Mar 2008 07:07:03 GMThttp://www.revragnarok.com/blog/blog/2008/03/15/21.42
http://www.revragnarok.com/blog/blog/2008/03/15/21.42<p>
Wow, I thought I've posted this stuff before but could not find it when searching earlier today.
</p>
<p>
But that's OK because I've done something new today versus the many previous years (the "special case" below).
</p>
<p>
Anyway, the quickest way to reduce the size of a VMWare image (note: I am not talking about the physical space, I mean the size when you compress the image in the host OS, for example with <code>tar</code> with <code>bzip2</code>):
</p>
<h2 id="ReducingVMImageSizeStandard">Reducing VM Image Size (Standard)</h2>
<ol><li><code>telinit 1</code> # Drops you to single user and shuts down most other stuff
</li><li>Delete any files you don't need. This includes most of <code>/tmp/</code>
</li><li><code>dd if=/dev/zero of=delme bs=102400 || rm -rf delme</code> # This will fill the unused space on the hard drive image with zeros. <strong>If you have VMWare set to expand-on-the-fly, it will maximize the size on the host OS, which may not be what you want.</strong> Use <code>mount</code> to show which partitions are being used - you need to do this for each partition (<em>e.g.</em> <code>/boot</code>). This is the "meat" of the issue. Do <strong>not</strong> background this process and then try to do the other partitions in parallel - remember, they are the same <em>physical</em> disk on the host OS and you will thrash your hard drive like crazy (been there).
</li><li>Check where your swap space is defined - it's in <code>/etc/fstab</code>
</li><li><code>swapoff -a</code> # Turns off all swap space (you don't need it right now)
</li><li><code>dd if=/dev/zero of=/dev/yourswappartition bs=1024</code>
</li><li>If <code>/etc/fstab</code> mounted the swap <em>by label</em>:
<ul><li><code>mkswap -L SWAPLabel /dev/yourswappartition</code>
</li></ul></li><li>If <code>/etc/fstab</code> mounted by partition alone:
<ul><li><code>mkswap /dev/yourswappartition</code>
</li></ul></li><li>You don't need to turn the swap back on, on the next boot of the VM it will be handled since you ran <code>mkswap</code>.
</li><li><code>shutdown -h now</code>
</li></ol><h2 id="ReducingVMImageSizeSpecialCase">Reducing VM Image Size (Special Case)</h2>
<p>
The special case is what I ran into today. I backed up my work <em>trac/svn</em> VM server as usual. However, I told another customer that I would give <em>them</em> a server. So I need to remove the subversion repository and trac environment. <strong>Option 1</strong>: Delete them, and then redo all the <code>dd</code> stuff from above, which would be O(free space) vs O(repository). Since "free space" &gt;&gt; "repository", I was trying to avoid that. <strong>Option 2</strong>: Zero out the files that I don't want anymore. This has the advantage of still reclaiming the gigabytes of space while not waiting for all empty space to be removed. The secret was using the <code>shred</code> command:
</p>
<pre class="wiki">find -type f | xargs shred -u -v -n 1 --random-source=/dev/zero
</pre><p>
For those trying to understand it better, that is "find all files (that are files) and then pass the list to <code>shred</code> as parameters along with: delete the file when done (<code>-u</code>), tell me everything you do (<code>-v</code>), overwrite the file only once instead of the usual 25 (<code>-n 1</code>), and instead of using <code>/dev/random</code> for your "random" data, just use <code>/dev/zero</code> (<code>--random-source=/dev/zero</code>). Note that using <code>dd</code> directly would have been a pain because I would have to know the size of each file (hundreds) but also it would truncate-on-write meaning that the data being written is not guaranteed to be the actual data we wanted to blank out. That defeats the purpose!
</p>
<h2 id="MakingThisObsolete">Making This Obsolete</h2>
<p>
I need to check out this <a class="ext-link" href="http://www.koltsoff.com/pub/zerotools/"><span class="icon">​</span>Zerotools</a> package as soon as I can since it seems to do a similar thing <em>all the time.</em>
</p>
vmwarelinuxObnoxious VMWare console beepsRevRagnarokMon, 14 Jan 2008 07:12:03 GMThttp://www.revragnarok.com/blog/blog/2008/01/13/21.04
http://www.revragnarok.com/blog/blog/2008/01/13/21.04<p>
The VMWare machines on my work laptop would chime whenever I did things like filename completion. The problem was, it was BIOS-level super obnoxious beep that was likely pissing off my cube-neighbors (no volume control nor mute worked). I had turned off all sounds in the Windows host OS, which seemed to be the problem. So if your console beeps are out of hand, set the Windows' "<code>Default Beep</code>" to something. That will have Windows re-intercepting the beep and then the system volume control / mute will work again.
</p>
linuxvmwarewinxpShutting down VMWare clientsRevRagnarokTue, 17 May 2005 09:00:00 GMThttp://www.revragnarok.com/blog/blog/2005/05/17/06.58
http://www.revragnarok.com/blog/blog/2005/05/17/06.58<p>
In /etc/services on CLIENT:
</p>
<pre class="wiki"># Local services
shutdown 6666/tcp
</pre><p>
In /etc/inetd.conf on CLIENT:
</p>
<pre class="wiki">shutdown stream tcp nowait root /sbin/shutnow
</pre><p>
In /sbin/shutnow of CLIENT: (you can prolly get rid of this and move this all into inetd.conf above, but I used to do other things too...)
</p>
<div class="wiki-code"><div class="code"><pre><span class="ch">#!/bin/bash
</span>/sbin/shutdown -h now
</pre></div></div><p>
On the CLIENT's iptables rules, I have:
</p>
<pre class="wiki">0 0 DROP tcp -- eth1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:6666
</pre><p>
So nobody can reach that port from eth1 (internet). The host will be hitting the port on eth2 which is the host-only virtual network.
</p>
<p>
Then on the HOST in /etc/init.d/kill_vms (new file):
</p>
<div class="wiki-code"><div class="code"><pre><span class="ch">#!/bin/sh
</span><span class="c1">#
# chkconfig: 4 90 08
# description: Kills VMs on shutdown/reboot
</span>/usr/bin/telnet <span class="m">192</span>.168.90.201 <span class="m">6666</span> &lt; /dev/zero
<span class="nv">PIDS</span><span class="o">=</span>fake
<span class="k">while</span> <span class="o">[</span> <span class="s2">"foo</span><span class="nv">$PIDS</span><span class="s2">"</span> !<span class="o">=</span> <span class="s2">"foo"</span> <span class="o">]</span>
<span class="k">do</span> <span class="o">{</span>
<span class="nb">echo</span> <span class="s2">"Delaying shutdown... VMWare still on </span><span class="nv">$PIDS</span><span class="s2">"</span>
sleep <span class="m">10</span>
<span class="nv">PIDS</span><span class="o">=</span><span class="sb">`</span>pidof vmware-vmx<span class="sb">`</span>
<span class="o">}</span><span class="p">;</span>
<span class="k">done</span>
</pre></div></div><p>
So then on the server you install the "kill_vms" with chkconfig (fix the IP from 192.168.90.201 to your virtual client IP of course!).
</p>
<p>
It won't work the first time you reboot, sorry. If you 'touch' the file /var/lock/subsys/kill_vms (at least on my ancient RH based system) then it should. Also, it will hang forever if you don't have the virtual machine set to 'Close on shutdown' and I think maybe another option in VMWare about closing if all clients close.
</p>
importmiscvmwarelinux