Preparing VirtualBox images: Difference between revisions

From genomewiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 13: Line 13:


   wget http://hgwdev.soe.ucsc.edu/~max/gbInstall/ubuntu.sh
   wget http://hgwdev.soe.ucsc.edu/~max/gbInstall/ubuntu.sh
  sudo bash
   source ubuntu.sh
   source ubuntu.sh


It's nice to have shared folders:
It's nice to have shared folders:
   sudo addgroup vboxsf
   sudo addgroup vboxsf
   sufo adduser browser vboxsf
   sudo adduser browser vboxsf
   sudo wget http://hgwdev.soe.ucsc.edu/~max/gbInstall/rc.local -O /etc/rc.local
   sudo wget http://hgwdev.soe.ucsc.edu/~max/gbInstall/rc.local -O /etc/rc.local


Once you're finished with everything ubuntu related, you can free 120 MB:
Once you're finished with everything ubuntu related, you can free 120 MB:
    
    
   rm -f /var/lib/apt/lists/*
   sudo wget http://hgwdev.soe.ucsc.edu/~max/browserbox/cleanVm
  chmod a+x cleanVm
  sudo cleanVm


Now compact the disk image: reboot, press shift on boot, selected advanced, repair mode, root shell (different than telinit 1?):
Now zero the disk image:  
 
  sudo wget http://hgwdev.soe.ucsc.edu/~max/browserbox/zeroIt
  mount -o remount,ro /
  sudo chomod a+x zeroIt
  zerofree -v /dev/sda1
  sudo ./zeroIt


To show the IP address on startup, only necessary in bridged mode:
To show the IP address on startup, only necessary in bridged mode:
Line 34: Line 37:
   sudo chmod a+x /etc/network/if-up.d/show-ip-address
   sudo chmod a+x /etc/network/if-up.d/show-ip-address


Leave VirtualBox, shutdown the VM, go to a command line on the host, find the .VDI file and compact it:
Leave VirtualBox, shutdown the VM, go to a command line on the host, find the .VDI or VMDK file(s) and compact it:


   vboxmanage modifyhd –compact browserbox.vdi
   vboxmanage modifyhd –compact browserboxBoot.vdi
  vboxmanage modifyhd –compact browserboxData.vdi


* [[http://ianozsvald.com/2012/07/26/using-zerofree-to-shrink-a-virtualbox-linux-image/ Shrink the disk]]
* see [[http://ianozsvald.com/2012/07/26/using-zerofree-to-shrink-a-virtualbox-linux-image/ Shrink the disk]]


Have a quick look into the .vbox file and make sure that it doesn't list any iso images or other disk images that you attached once to the disk but don't need anymore. They trigger error messages on new host machines.
Have a quick look into the .vbox file and make sure that it doesn't list any iso images or other disk images that you attached once to the disk but don't need anymore. They trigger error messages on new host machines.

Revision as of 10:04, 4 March 2014

Start with a fresh Ubuntu 13.04 image, call the main user "browser".

 apt-get install localepurge zerofree
 # I think we don't need these packages... saves around 300MB 
 apt-get install alpine 
 apt-get remove python3* linux-headers* aptitude man-db perl perl-modules geoip-database language-pack-gnome-en-base manpages ppp acpi iso-codes console-setup dmidecode eject ethtool initramfs-tools pciutils usbutils command-not-found alpine-doc python3.3-minimal apparmor 
 # wanna remove more? show packages by size: dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' | sort -k 2 -n
 apt-get install apache2 mysql-server mysql-client
 # consolkit keeps / open which is annoying for zerofill, acpi-tools doesn't really need I hope
 sudo dpkg -r --force-depends consolekit

Now install the genome browser:

 wget http://hgwdev.soe.ucsc.edu/~max/gbInstall/ubuntu.sh
 sudo bash
 source ubuntu.sh

It's nice to have shared folders:

 sudo addgroup vboxsf
 sudo adduser browser vboxsf
 sudo wget http://hgwdev.soe.ucsc.edu/~max/gbInstall/rc.local -O /etc/rc.local

Once you're finished with everything ubuntu related, you can free 120 MB:

 sudo wget http://hgwdev.soe.ucsc.edu/~max/browserbox/cleanVm
 chmod a+x cleanVm
 sudo cleanVm

Now zero the disk image:

 sudo wget http://hgwdev.soe.ucsc.edu/~max/browserbox/zeroIt
 sudo chomod a+x zeroIt
 sudo ./zeroIt

To show the IP address on startup, only necessary in bridged mode:

 sudo wget http://hgwdev.soe.ucsc.edu/~max/gbInstall/show-ip-address -O /etc/network/if-up.d/show-ip-address
 sudo chmod a+x /etc/network/if-up.d/show-ip-address

Leave VirtualBox, shutdown the VM, go to a command line on the host, find the .VDI or VMDK file(s) and compact it:

 vboxmanage modifyhd –compact browserboxBoot.vdi
 vboxmanage modifyhd –compact browserboxData.vdi

Have a quick look into the .vbox file and make sure that it doesn't list any iso images or other disk images that you attached once to the disk but don't need anymore. They trigger error messages on new host machines.

If you see one, get its UUID first:

 VBoxManage list hdds
 VBoxManage list dvd

The remove it:

 VBoxManage closemedium disk <paste uuid here>

or

 VBoxManage closemedium dvd <paste uuid here>