I attempted to automate the trick described at
http://h0bbel.p0ggel.org/shrinking-vmdk-files
I wrote this script "packit.sh", into one of my jeos based appliances.
It could automatically remove the fragmented pockets, from all the partitions.
When I need to ship and share my appliance, with anybody, I run this script, then I run the VMware utility to defragment, and then tar/gzip the directory that needs to be shipped.
Works pretty well for me so I thought I might share.
Could somebody share a trick, that allows me to call this script automatically, whenever I shutdown my appliance.
### Bash script - packit.sh starts below this line ###
#!/bin/bash
SHRINK_IT ()
{
echo "creating $1, and filling up that partition until there\'s no more space"
cat /dev/zero > $1
sync
echo "deleting $1, so that we have no pockets left in that partition"
rm -f $1
}
ZEROFILL_ALL_DISKS
{
## Description:
# This will "fillup" each partition with a file called zero.fill.
# And then delete that file, to remove fragmented pockets.
DISKS=`df -h`
D=`echo "${DISKS}" | wc -l`
C=`expr $D - 1`
ITEMS=`echo "${DISKS}" | tail -n $C | awk '{print $6}'`
for S in ${ITEMS}
do
SHRINK_IT `readlink -f ${S}/zero.fill`
done
return;
}
MAIN ()
{
# The list of Functions that must be called
ZEROFILL_ALL_DISKS
}
MAIN
### Bash script ends above this line ###
I guess we could similarly automate the other tasks, by adding more functions in the packit.sh script and then including them in the MAIN ()
Shipping and sharing jeos based appliance should also be always accompanied with a note for users to modify vmx file for new eth0 and also change in /etc/udev/rules.d/70-persistent-net.rules
When I get some more time, I think I will add-in functions for security too like removing SSH keys, etc., besides something to fix the changed mac-address. »
Somebody recently egged me to lookup "jeos", as I am looking to build a VM appliance. Like most others, I eventually landed on this page. My advice for anybody who's making a maiden experiment with building VM appliance, THIS is the place guys. Nick & Soren have written a great "step-by-step howto" here.
Jeos, by itself is very well built, and lives upto it's claimed strengths, so if you can accept its admitted lacunae, it definitely is the best platform to build your VM appliance. Jeos is also a great place to begin with, if you are looking to experiment with truly debian lineage of linux.
I have personally checked out the stuff built by others. Most of the Linux OS distributed as a VM appliance, are vulgarly "obese" compared to Jeos. Most irritatingly, you have to install atleast one email server and client (sic) to properly install the base OS! But, Jeos has been built rather intelligently, and the usually required packages have been carefully built to use as few dependencies as possible. This is because, most of the other distros have merely rehashed their existing distros into a VM image, to simply show-case the included goodies. Jeos on the other hand has been carefully built, keeping the VM appliance developers in mind.
So all my votes go to Jeos, alongwith a lot of thanks to the Jeos team.
A few things that Nick & Soren missed out on -
1. Novice developers, who may be migrating from other distros may have been more comfortable with a few links that helped them understand apt-get / aptitude.
2. VM appliance first timers could be a little shocked to note that their eforts of appliance building could result in really huge vmdk files. A few tricks like the one documented here http://h0bbel.p0ggel.org/shrinking-vmdk-files
should help. And the users should take heart, from the fact that, even if post-optimisation, if the vmdk files look rather too huge to upload / download, tar / gzip-ing them will make them comfortably small tar.gz packages. I do wish Nick & Soren do a follow up on this article to include tips and tricks for such things too.
So all of you fellow developers, if you wanted to build your VM appliance, read the above article a couple of times, and calmly go step-by-step. »