Linux Sysadmin Blog

Xen: Add Extra Partitions to Guest OS

- | Comments

Here’s one way to add and mount additional LVM partition in xen guest machines.

1.) Create logical partition and format it. Example below creates “40GB” partition and “ext3” format in “vg0” volume group.

lvcreate -L 40G -n extra_storage vg0
mkfs -t ext3 -v /dev/vg0/extra_storage

2.) Update xen config to add new partition to guest os. Assign device name to it, example “xvda3”. Then re-create the VM to recognize the new partition/device. Note: reboot doesn’t read the new xen configuration.

disk        = [

3.) After you reboot, login to VM and mount the new partition. New drive or partition shoud be in “/dev/xvda3.”

  mount /dev/xvda3 /extra_space

Add it to “/etc/fstab” to automount on reboot.

  /dev/xvda3 /extra_space ext3 noatime,nodiratime,errors=remount-ro 0 1

HowTo: Bulk Import DNS Zones to Softlayer DNS Using Cpanel

- | Comments

This guide covers the process for doing bulk import of existing DNS zones from a Cpanel or BIND server to Softlayer’s DNS servers (ns1/ This is useful if you need to add hundreds of zones, if for example you are moving your DNS hosting servers to Softlayer’s free DNS hosting. Currently, Softlayer doesn’t have a tool to do bulk import of zones with existing records. Although you can create a default zone template and bulk add zones but this doesn’t fit for existing zones.


1.) DNS zones on a Cpanel server (WHM or DNSOnly).

If you are not using a Cpanel server then you can stand up a Cpanel VPS this process and install Cpanel DNSOnly as it is free or install Cpanel WHM and automatically it will have 15-day trial license, or you can get a one month WHM VPS license for $15/month. DNSOnly should be fine and easier/faster to install but you cannot view the DNS zones from its UI, although you can view or edit the zone files directly (ex: /var/named/domain.db). Then import your zones to Cpanel server. There are lots of guides or discussions online in doing this. Some mentioned that you can move the named.conf and zone files as-is and adjust the formatting to match Cpanel’s. In our case we were running Cpanel server so we copied straight our “/var/named/*.db” files to Cpanel DNSOnly to import zones.

2.) Softlayer API key for your account.

You will need this later to connect your Cpanel DNS server in a cluster setup with Softlayer’s DNS servers. Cpanel have DNS cluster functionality with SoftLayer and VPS.NET.

The Import Process:

1.) Configure your Cpanel DNS cluster to connect to Softlayer’s DNS servers.

Integrate Sendgrid With Redmine

- | Comments

One thing everybody wants when deploying applications is integrating them with other applications or services. Two popular apps and services out there for small businesses that manage project management and email are Redmine and SendGrid.


  1. A working Redmine install.
  2. A sendgrid email address. Let’s say we have something like that we want Redmine to send emails from.
  3. Here are a few gems I put on sporatically when researching email integration, so make sure you have them. Jump to where your redmine install is located (e.g. /var/www/redmine) and do the following:
# gem install mail json sendgrid

The core of this funcionality is provided by the sendgrid gem which originates from here:

Redmine Configuration File

If your Redmine install is something like /var/www/redmine, your configuration file will be /var/www/redmine/config/configuration.yml. If you have a relatively clean Redmine install, chances are you might not have one or it’s a default template with a lot of examples. You might find an example detailing how to integrate with GMail in the example file. Our set up will be similar. Paste the following into your configuration.yml file and change the necessary parameters.

Rsback: Task X Is Locked and Cannot Be Executed

- | Comments

Rsback Error:

  rsback: [date/time] *** task 'x' is locked and cannot be executed.

I got the above error when I was trying to re-run the rsback task that I previously killed its schedule backup process. I had issue with the server being backup so I had to terminate the process.

This error shows up and prevents the backup task from running because the lock file is still present, which indicats that a process could still be running. In order to fix this you need to remove the lock file and re-run the backup task. Look at your rsback config (/etc/rsback/rsback.conf) to find out the location of your rsback lock files, default is ”lock_dir = /var/lock/subsys”. In there you will see rsback lock files as ”rsback.backup_task_name.lock”, and just delete that file.

For those who doesn’t know or heard of rsback below is a short description from sourceforge.

rsback makes rotating backups using the common rsync program combined with hard-link copies on Unix-based backup hosts. This results in a fast and disk space saving backup technique.

Restore Xen VM From LVM Snapshot Backups

- | Comments

What’s the use of backups if you can’t restore from them? ;)

In the previous post on “Backup Xen with LVM and Rsnapshot” we worked on creating backups of Xen (guest/domain) VMs with LVM, and here we’ll cover the process of restoring from these backups.

What is covered here:

Restoring specific files or directories Doing “bare-metal” type of restore. We will re-create the VM from our rsnapshot backups. Restore Process:

1.) Restoring specific files or directories only

While this restore scenario is a no-brainer, still I’ll just want to mention it here as well. Basically this one is the usual copying of files (via cp, scp, ftp, rsync, etc) from your source or backup server to the destination server.

2.) “Bare-metal” restore (creates complete vm image from backup).

Overview of “bare-metal” restore process:

create, format, and mount logical volumes to use on the vm that you want to restore or re-create, based on its original vm disk properties such as size, names, etc. copy all files from backup location to the newly mounted lvm disk

Debian 6: Backup Xen With LVM and Rsnapshot

- | Comments

This is a draft of my installation process which is mainly based from this blog: Efficient Xen Backups Using LVM and Rsnapshot.

Our setup is on Debian 6 server with 2TB disk running 10 vpses. We followed the above guide with notes on errors we encountered, mostly rsnapshot related. We are keeping daily backup locally, on a separate partition, and copies them to our remote server every week.

The Setup (mostly defaults): vg path is /dev vg name is vg0

Setup Process:

Create logical partition to store backups locally. Size is 100GB and named it backups. Format it with ext3 and mounted it to /backups.

lvcreate -L 100G -n backups vg0
mkfs -t ext3 -v /dev/vg0/backups
mkdir /backups
mount /dev/vg0/backups /backups

Install and configure rsnapshot. Make sure you use TAB correctly as it will complain or give you an error if you don’t.

aptitude install rsnapshot
vi /etc/rsnapshot.conf

Here’s my rsnapshot config changes and/or additions:

Gitolite: Add, Edit, or Delete Git Repository Name

- | Comments

I can’t find commands in gitolite to manage repository or project name, so here’s what I got from other sources.

Add or create repository

  • Add entry for new project or repository in your gitolite config (conf/gitolite.conf)
  • Commit and push your changes. this will create and initialize your new repo.

Rename a repository

  • Modify the name of repo in your gitolite config (conf/gitolite.conf)
  • Move or rename the actual directory (depending on where you install it, ex: /home/git/repositories) to match your changes in gitolite config.
  • Commit and push your changes.

Note: Obviously, this changes the remote url of your repo, so don’t forget to change your git remote url config in your project clones.

Delete a repository:

  • Open your gitolite config and remove the project from there. commit and push your changes.
  • Then delete its git directory (ex: /home/git/repositories/projectname.git)
  • You can also remove users/keys that are no longer used

Install Vsftpd Server With Virtual User and Directory

- | Comments

Here’s a summary for vsftpd setup with virtual user and directory in Debian. It’s probably the same process on other Debian-based distros as well as Redhat-based distros. No need to define what’s vsftpd and what’s virtual users - let’s just proceed to the setup. :)

Install VSFTPD:

aptitude install vsftpd

Choose what method to use for virtual user authentication. Let’s use pam passwd module (libpam-pwdfile), I guess this is the most common and easy to setup. You can also use libpam-mysql if you want to manage your ftp users via mysql database, like if you want integrate it with your application that’s using mysql as backend.

aptitude install libpam-pwdfile

Next create your password file (example: /etc/vsftpd_users.conf) which contain the list of virtual users and password hash. You can use htpasswd that’s included in Apache or go to this website, to generate the list of users and passwords.

YUM: There Are Unfinished Transactions Remaining. You Might Consider Running Yum-complete-transaction First to Finish Them.

- | Comments

Yum Error:

There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.

With unfinished transactions, yum refers to any incomplete or aborted transactions, such as package installations or updates. Obviously, yum wants you to run yum-complete-transaction command to fix the problem. If you can’t find yum-complete-transaction on your system, probably you don’t have the package ”yum-utils” installed, so install it first with yum install yum-utils.

If you run yum-complete-transaction command, it will find and resolve the latest corrupted/aborted transaction and try to complete or fix it, and you have to run it again until all issues are fixed. Running that command will tell you how many transactions are left to complete, package name, and so on. Try running /usr/sbin/yum-complete-transaction --help for options in using this commands.

HowTo Install APC on CPanel/WHM

- | Comments

CPanel includes support in their installer for eaccelerator; still, for some strange reason they don’t include support for APC also. So, if you want to install APC on your CPanel powered server, you will have to go back at the command line and install it manually.

Here are the steps needed to install the latest version of APC (3.1.8 at the time of writing this article; please check for the latest version available when you are reading this and make the changes accordingly):

cd /usr/local/src
tar -zxvf APC-3.1.8.tgz
cd APC-3.1.8
./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/local/bin/php-config
make install

Next, activate the apc module in php.ini by adding something like this:


Finally, you will have to restart apache and after that the APC module should be activated and in use. Hopefully, this will help you enable APC on your CPanel server in some very simple steps in less that 5minutes.