Monthly Archives: October 2014

VirtualBox and phpvirtualbox

Headless Virtualbox running on Ubuntu 12.04 server


deb precise contrib

wget -q -O- | apt-key add -
apt-get update
apt-get install linux-headers-$(uname -r) build-essential virtualbox-4.3 dkms
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.10-92957.vbox-extpack
useradd -d /home/vbox -m vbox
passwd vbox
adduser vbox vboxusers



update-rc.d vboxweb-service defaults

phpvirtualbox in Nginx

apt-get install nginx php5-common php5-mysql php5-suhosin php5-fpm php-pear wget


server {
    listen 80;

    return 301 https://$host$request_uri;

server {
    listen 443 ssl;
    client_max_body_size 15M;

    ssl on;
    ssl_certificate /etc/ssl/private/example_org.crt;
    ssl_certificate_key /etc/ssl/private/example_org.key;

    ssl_session_timeout 5m;

    ssl_protocols SSLv3 TLSv1;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;

    root /usr/share/nginx/www/phpvirtualbox;
    index index.php index.html index.htm;

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_index index.php;
            fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;

    location ~ /\.ht {
            deny all;

    access_log /var/log/nginx/virtualbox/access.log;
    error_log  /var/log/nginx/virtualbox/error.log;


cd /usr/share/nginx/www
mv phpvirtualbox-4.3-1 phpvirtualbox
cd /usr/share/nginx/www/phpvirtualbox/
cp config.php-example config.php


var $username = 'vbox';
var $password = 'the password you used when you created vbox user';

cd /etc/nginx/sites-enabled
ln -s /etc/nginx/sites-available/virtualbox.conf /etc/nginx/sites-enabled/virtualbox.conf 
nginx -t
service nginx reload

Login to phpVirtualbox

user: admin
default password: admin
new password: pick your own

Create VM from command line

VBoxManage --help

Create an Ubuntu 12.04 Server VM with 512MB memory and a 10GB hard drive from the Ubuntu 12.04 Server iso image:

$ VBoxManage createvm --name "Ubuntu 12.04 Server" --register
$ VBoxManage modifyvm "Ubuntu 12.04 Server" --memory 512 --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0
$ VBoxManage createhd --filename Ubuntu_12_04_Server.vdi --size 10000
$ VBoxManage storagectl "Ubuntu 12.04 Server" --name "IDE Controller" --add ide
$ VBoxManage storageattach "Ubuntu 12.04 Server" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium Ubuntu_12_04_Server.vdi
$ VBoxManage storageattach "Ubuntu 12.04 Server" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /home/ubuntu-12.04-server-amd64.iso

Importing an existing VM
VBoxManage registervm Machines/examplevm/examplevm.xml

Starting a VM with VBoxHeadless
VBoxHeadless --startvm "Ubuntu 12.04 Server"

Stop a VM
VBoxManage controlvm "Ubuntu 12.04 Server" poweroff

Pause a VM
VBoxManage controlvm "Ubuntu 12.04 Server" pause

Reset a VM
VBoxManage controlvm "Ubuntu 12.04 Server" reset

Postfix server configuration

Postfix server (Debian / Ubuntu) is:

  • configured to primary domain
  • listening on SMTP port 25 on home-server machine
    From Internet it delivers email for following domain:
    From LAN it delivers email for following domain: home.lan

  • Every LAN computer forwards it’s mail for any user to home-server mail server and is processed to users following rules in /etc/postfix/recipient_canonical
  • Sender mapping follows the rules in /etc/postfix/canonical and /etc/postfix/sender_canonical configuration files (not in use now).
  • All mail is forwarded to users in following virtual table /etc/postfix/virtual
  • Any internal email domain is changed following rules in /etc/postfix/generic configuration file
  • Do not forget to use command postmap /etc/postfix/configuration_file every time you change file with ‘hash:‘ prefix
  • After any configuration change you have to reload Postfix service postfix reload
    Postfix installation

    apt-get install postfix
    postmap /etc/aliases
    postmap /etc/postfix/canonical
    postmap /etc/postfix/sender_canonical
    postmap /etc/postfix/generic
    postmap /etc/postfix/virtual



    alias_database = hash:/etc/aliases
    alias_maps = hash:/etc/aliases
    append_dot_mydomain = yes
    biff = no
    config_directory = /etc/postfix
    inet_interfaces =
    mailbox_command = /usr/bin/procmail
    mailbox_size_limit = 0
    mydomain =
    myhostname = mail.$mydomain
    mynetworks =
    myorigin = /etc/mailname
    recipient_delimiter = +
    relayhost =
    smtpd_banner = $myhostname NO UCE ESMTP
    smtpd_delay_reject = no
    smtpd_helo_required = yes
    canonical_maps = hash:/etc/postfix/canonical
    sender_canonical_maps = hash:/etc/postfix/sender_canonical
    recipient_canonical_classes = envelope_recipient
    recipient_canonical_maps = regexp:/etc/postfix/recipient_canonical
    smtp_generic_maps = hash:/etc/postfix/generic
    local_header_rewrite_clients = static:all
    smtpd_recipient_restrictions =
    unknown_address_tempfail_action = $reject_tempfail_action
    reject_tempfail_action = defer_if_permit
    strict_rfc821_envelopes = yes
    virtual_maps = hash:/etc/postfix/virtual
    mydestination = $myhostname, smtp.$mydomain, mail.$mydomain, home.lan, localhost, localhost.localdomain

    /etc/postfix/virtual virtual domain


    postmaster: admin
    webmaster: admin
    www-data: admin
    abuse: admin
    nagios: root





    Chromium v38 sign in problem

    I have installed Chromium v38 from my Debian Jessie repositories and I’m facing the following error “Service unavailable; try again later” when a try to sign in from Chromium.

    Until the new version v38 starts to work correctly, I will stick with previous one v37.

    Download Chromium v37 packages from here.


    apt-get purge chromium chromium-browser
    cd ~/Download/
    dpkg -i chromium_37.0.2062.120-2_amd64.deb chromium-l10n_37.0.2062.120-2_all.deb chromium-inspector_37.0.2062.120-2_all.deb
    apt-mark hold chromium chromium-inspector chromium-l10n

    You have to ‘hold‘ selected Chromium packages not to be updated. If you know new version already works fine, you may ‘unhold‘ those packages with similar command above.

    How I boosted performance of my HTC Desire Z 4.2 custom ROM

    A. Install custom ROM of your choice
    B. Install Smart Launcher 2
    C. Create and enable swap
    D. Install Pim my ROM and tune CPU

    HTC Desire Z (Vision)
    AOSP 4.2.2 – Jelly Baby – v2.0.0
    Smart Launcher 2
    Pim my ROM
    Swapper 2
    Terminal Emulator

    A. Install custom ROM of your choice

    1. Download Android 4.2.2 Jelly Baby ROM and Google Apps for HTC Desire Z (Vision) to your computer.
    2. Connect Your Device to your computer and copy the above downloaded file to your device.
    3. Turn Off your device and disconnect it from PC.
    4. Now to get in the Bootloader Mode. Switch ON the phone while pressing and holding Volume Down + Power buttons together.
    5. Follow the navigation instructions on the screen. Select BOOTLOADER and then go to RECOVERY.
    6. In Clockwork Mode Recovery perform full data wipe, then Scroll down to ‘Flash zip from sd card’ and press the power button to select it.
    7. Now use your volume keys to highlight the Android 4.2.2 ROM zip file and select it using power button,confirm the installation on next screen.
    8. After the installation is complete go back and select ‘Reboot system now’, the phone will boot now and it will take almost 5-minutes to run it for the first time, So Please be Patient

    NOTE: Repeat Step 7 TO Install Google Apps on your device.

    Some useful Android SDK hints:

    cd ~/android-sdk-linux/
    tools/android update sdk
    cd platform-tools
    ./adb kill-server
    sudo ./adb start-server
    ./adb devices
    ./adb shell
    mount /system
    umount /system
    ./adb reboot bootloader

    B. Install Smart Launcher 2

    I really love Trebuchet because it’s simplicity, but there is something much simpler and that’s Smart Launcher 2.

    C. Create and enable swap

    What is Swap?

    A swap file allows an operating system to use hard disk space to simulate extra memory. When the system runs low on memory, it swaps a section of RAM that an idle program is using onto the hard disk to free up memory for other programs. Then when you go back to the swapped out program, it changes places with another program in RAM. I can say Swap file is like Virtual Memory on your PC.

    • Any ROM (Tested on Jelly Baby above)
    • Any _CUSTOM_ Kernel (Tested on Fyodor 3.0.83 Kernel)
    • 300+ MB space on MicroSD HC class 10
    • Terminal Emulator

    1. Download the Swapper 2 and the Terminal Emulator and install them. Make sure you have BusyBox installed too.
    2. Go to Terminal Emulator type “free” without the quotation. Make sure you see “0” on the Swap.
    3. Open Swapper 2 application, go to Setting, Swap size=300 MB, Swappiness=60 (you can play on the numbers as you like). Go Advanced preferences check “Recreate swap file” and “Reformat swap” then exit…
    4. Open Swapper 2 click ON it will show some Fail. Just wait for few secs and it will continue. If not, click the ON again.
    5. Go to Terminal Emulator type “free” and you will see that the “0” has been replaced.

    If you like it hard core, like I do (sometimes), I use swap partition instead of swap file. Just be VERY careful co select your SD card. If you know the size of you SD card (from Android Settings -> Storage), use ‘fdisk /dev/block/mmcblkX’ (replace X mostly with number 1) and (p)rit command to identify it. It will show you the size of the SD card and current partition(s) (mostly only one, type FAT32). As you correctly identified the SD card, you may proceed to create swap partition.

    D. Install Pim my ROM and tune CPU

    The tuning of your device may bring excellent performance, but you have to pay it with the battery which will last less than you were used to.
    Download the application Pimp my ROM from Google Play. Start it, choose TOOLS and Pimp My CPU. Overclock your processor Current max. speed to maximum (or as much as you like) and Current min. to some reasonable low amount. Very important is Governor: interactive and IO Scheduler: deadline. Don’t forget to Set on Boot: ON to keep your settings persistent. Select save and restart your phone. Enjoy the speed! This works for me on my HTC Desire Z and HTC One V. YMMV.

    Some hints:

    My SD card was fully occupied by FAT32 partition. So I removed SD card from my device, connect it to my computer and used GParted to shink the partition (not much hardcore, but I love that GUI).
    In my example below, I’m using partition #3. You may need to replace it.

    fdisk /dev/block/mmcblk1
    (p)rint, (n)ew, (p)rimary, partition number (3), first cylinder (RETURN), last cylinder (+384M), (t)ag, partition number (3), hex code (82), (p)rint, (w)rite
    mkswap /dev/block/mmcblk1p3
    swapon /dev/block/mmcblk1p3

    Configure Swapper 2 according to article above, just in “Settings”, select “Advanced preference”, check “Use swap partition” and point “Swap partition” to ‘/dev/block/mmcblk1p3’. It will show same false positive failures, but don’t worry. Restart you phone, launch Terminal Emulator and type ‘free’. If you see swap usage (not 0), your swap partition works.

    Kernel compilation (Debian Jessie)

    Kernel compilation (Debian Jessie)

    You will need 8-10 GB of free disk space!

    apt-get install fakeroot kernel-package
    wget -c
    tar -xvJf linux-3.14.20.tar.xz
    cd linux-3.14.20
    cp /boot/config-`uname -r` .config

    apt-get install libncurses5-dev
    make menuconfig
    make-kpkg clean
    fakeroot make-kpkg --append-to-version "-customkernel" --revision "1" --initrd kernel_image kernel_headers
    cd ..
    dpkg -i linux-image-3.14.20-customkernel_1_amd64.deb linux-headers-3.14.20-customkernel_1_amd64.deb

    Install Kernel 3.12 stable release on 64 bit Ubuntu


    dpkg -i linux-headers-3.12*.deb linux-image-3.12*.deb

    apt-get purge linux-image-3.12.0-* linux-headers-3.12.0-*