Navigation

Compact VMWare Image

From Mono

      # Boot up machine and run vmware-tools as root:
      sux
      vmware-tools
      # Shrink '/' filesystem
      # Go to init level 3 to zero out swap partition
      init 3
      swapoff /dev/sda1
      dd if=/dev/zero of=/dev/sda1
      mkswap /dev/sda1
      # Shutdown machine
      shutdown -h now

This method is easier and less error prone. shrinking was tried before but went unnoticed as the swap partition still contained lots of data that didn't compress very well.


Obsolete:

Thanks for Urs C. Muff for the tips on compacting vmware images, which has been adapted for the Mono vmware image.


       # Create a new disk in vmware: 20GB HDD as SCSI 0:1, name after release version
       # Boot into single user mode by adding 'single' to the grub command line 
       #copy boot sector
       dd if=/dev/sda of=/dev/sdb bs=446 count=1
       #partition the main partition and the swap partition (or whatever your layout is)
       fdisk /dev/sdb
       n, p, 1, 1, +512M
       n, p, 2, default, default
       t, 1, 82
       w
       # Create Filesystems (sometimes rebooting is needed in order for the partitions devices to be available)
       mkswap /dev/sdb1
       mke2fs -j /dev/sdb2
       mkdir /new
       mount /dev/sdb2 /new
       df -h # should show a 20G disk with 19G free on /new
       #copy FS over
       rsync -az --delete --exclude '/new/*' --exclude '/proc/*' --exclude '/sys/*' / /new
       mkdir -p /new/proc /new/sys
       umount /new
       # Initialize grub
       echo '(hd1) /dev/sdb' >> /boot/grub/device.map
       grub-install /dev/sdb
       shutdown -h now
       # shutdown & swap HDD's
       # Boot in single user mode
       grub-install /dev/sda
       shutdown -h now
       # remove little HDD

Note: could the same be achieved by using vmware-tools disk shrinker, and reinitializing an empty swap partition?