Tuesday, May 19, 2015

Resize qemu (.qcow2) images

Scenario:  You have a working VM (qemu) which is running out of disk space. You need to add more space without destroying its current contents.

The following steps will let you accomplish the task.
  1. Backup the image first.
  2. Check if it is in qcow2 format:
    file winxp.qcow2
  3. Boot the image and take note of the current sizes of the entire disk (use fdisk command) and partitions (use df command).
  4. Resize the image (for example add 10GB of unallocated space):
    qemu-img resize winxp.qcow2 +10GB
  5. Run qemu to boot the gparted[1] live cd:
    qemu-system-i386 -hda winxp.qcow2 -cdrom gparted-live.iso -boot d
  6. From within gparted live resize the nearly full partition to "eat" the unallocated space we added (10 GB). Apply the changes. You may need to move partitions especially if you have many. Exit from gparted live.
  7. Boot the image and check if the changes have been reflected. Again use df and fdisk commands.
[1] http://gparted.org/livecd.php

Thursday, May 14, 2015

Speed up VM startup in OpenStack Juno

By default Nova deletes unused images in compute nodes after 24 hours. If you start an instance in which the image is no longer in the compute node, a transfer of the image from Glance is performed which increases the instance start up time. To override this, simply add the following line in the default section of nova.conf and restart the nova-compute service. The line will disable the removal of unused images from the compute nodes.
remove_unused_base_images = False

Wednesday, April 15, 2015

How to use a proxy for common applications

Global environment
Set the HTTP_PROXY environment variable
export HTTP_PROXY=http://username:password@proxy.server:port/  
apt
Create the file /etc/apt/apt.conf.d/43proxy and place the line below (be sure to provide the appropriate proxy information):
Acquire::http::Proxy "http://username:password@proxy.server:port/";
wget
Set the proxy settings in /etc/wgetrc

http_proxy=http://server_ip:port

git
Use the command below:
git config --global http.proxy http://username:password@proxy.server:port/

Monday, April 13, 2015

SSH without user-known hosts checking

If the IP address of the host you are connecting to frequently changes, as in the case of cloud instances, but you are sure that that you are connecting to the correct host, you can use the following ssh command to disable known host checking (Note: This may lead to MITM attacks).
ssh -o UserKnownHostsFile=/dev/null user@10.0.3.x 

Monday, February 23, 2015

A formula for computing your hourly rate as a consultant


Let S be your regular monthly salary and your work is forty hours per week, then your hourly rate HR can be computed as:

   HR = 2.5 x (S / 160)

For example, if your salary is 12,000.00 PhP, your hourly rate is

   HR
= 2.5 x (14,000.00 / 160)
      = 218.75 PhP


Now, let's say you have a website development project that you estimate will take one month (at 160 hours per month), you can charge your client 35,000.00 PhP.

Tuesday, January 6, 2015

OpenLDAP+Apache

I decided to create an OpenLDAP server[1] for my research group to serve as the central storage for member information (POSIX generic account). This server will be used to authenticate users when they access certain services that should be available to group members only. The group's wiki seems like a good candidate to test the setup.
First, enable LDAP related apache modules.
sudo a2enmod ldap authnz-ldap
Next, edit /etc/apache2/apache2.conf to add the following:
<directory>
        AuthType Basic
        AuthName "This site is for SRG members only. Please use your SRG NetId credentials to access this site."
        AuthBasicProvider ldap
        #AuthzLDAPAuthoritative on
        AuthLDAPURL "ldap://[your ldap server ip addess]:389/dc=srg,dc=ics,dc=uplb,dc=edu,dc=ph?uid"
        AuthLDAPBindDN "cn=admin,dc=srg,dc=ics,dc=uplb,dc=edu,dc=ph"
        AuthLDAPBindPassword [your admin password]
        Require valid-user
</directory>
Finally, restart apache.
sudo service restart apache2