Saturday, July 16, 2011

How to Install Bugzilla in Debian

Here we are going install bugzilla 3.6.3 in Debian testing (all in one host). By the time of this writing bugzilla package was not available in testing release and one from stable failed to run in testing release. The option is to use it from sid release.

Install

  1. Since we are going install everything on one box we need two essential components: a web server and database server, apache and mysql serve this purpose quite well (if you have mysql already somewhere in the network you need mysql-client package instead).
    apt-get -y install apache2 mysql-server
    
  2. Add sid repository to your apt sources list and update package list:
    echo "deb http://ftp.debian.org/debian sid main" \
        >> /etc/apt/sources.list
    apt-get update
    # You should be able to find bugzilla3 package now
    apt-cache search bugzilla3
    
  3. Install bugzilla:
    apt-get install bugzilla3
    
    Configure database for bugzilla3 with 
    dbconfig-common? Yes
    
  4. Comment out sid repository in apt sources file
  5. You can now navigate to your bugzilla home page by simply entering:
    http://bugzilla-server-name/bugzilla3
    

Serving from Web Server Root

Default installation of bugzilla install it into bugzilla3 virtual directory. You can change it to be server from root directory:
  1. Set urlbase in /etc/bugzilla3/params:
    'urlbase' => ''
    
    or even better (this url is the common initial leading part of all Bugzilla urls):
    'urlbase' => 'http://bugzilla-server-name/'
    
  2. Disable default site in apache:
    a2dissite default
    
  3. Ensure the following in /etc/apache2/conf.d/bugzilla3.conf:
    <VirtualHost *:80>
        #Alias /bugzilla3 /usr/share/bugzilla3/web
        DocumentRoot /usr/share/bugzilla3/web
        SetEnv X_BUGZILLA_WEBPATH "/" 
    
        ...
    
    </VirtualHost>
    
  4. Let apache know about the changes we made:
    /etc/init.d/apache2 reload
    

Database backup/restore

During installation of bugzilla it creates a new database with name bugzilla3.
  1. Here is a small script to backup database:
    # Backup bugzilla database
    /etc/init.d/apache2 stop
    mysqldump -p bugzilla3 > backup.sql
    /etc/init.d/apache2 start
    
  2. ... and restore.
    # Restore bugzilla database
    /etc/init.d/apache2 stop
    mysql -p bugzilla3 < backup.sql
    /etc/init.d/apache2 start
    
Read more about bugzilla here.

Monday, July 11, 2011

How to shrink qcow2 file

While working with kvm/qemu virtual environment you might encounter need to shrink image file after a removal of unnecessary files, etc. You will be surprised that the space you freed in guest virtual machine is not actually released in host file. It's size remain the same. Here you will know how to shrink it to minimum.

Windows Guest

The idea here is simple, there are few things you have to do:
  1. Delete all unnecessary files, empty recycle bin
  2. Defragment drive (you might need to do this several times, until you see it "compacted" well)
  3. Use sdelete to zero free disk space. Please note that this operation will cause that all drive free space will be filled by zero, so the virtual machine image will grow to the maximum size.
    sdelete -c c:
    

Linux/FreeBSD Guest

dd if=/dev/zero of=./zero bs=1M
sync
rm -f ./zero
Note, the bs parameter is important, since it greatly reduce time necessary to complete this task.

Host

Convert image to the same format that is currently is (e.g. qcow2 => qcow2)... during this procedure it will release unused space.
qemu-img convert -O qcow2 w2k3.qcow2 \
 w2k3-shrinked.qcow2
The process is time consuming and each phase greatly depends on physical disk IO performance and available free space.