### Archive

Archive for August, 2010

## Adding a new disk to a Xen VM

Create a new image file (10GiB):

dd if=/dev/zero of=mailstore.img bs=1M count=10k


(Note: You can also create a sparse file with dd’s seek option. Have a look at the dd manpage or the examples on http://en.wikipedia.org/wiki/Dd_(Unix))

Create the new filesystem:

mkfs.ext3 mailstore.img


Label the filesystem:

e2label mailstore.img <new-label>


Edit the DomU’s config file, /etc/xen/<hostname>.cfg and add the new disk:

disk = [ "tap:aio:/vm/disk.img,xvda,w", \
"tap:aio:/vm/mailstore.img,xvdb,w" ]


Start the VM:

xm create <hostname>.cfg


Edit DomU’s /etc/fstab & mount the disk:

[...]
LABEL=/<new-label>   /<mount-point>   ext3   defaults   0 1
[...]

Categories: Uncategorized Tags:

## Installing yum build dependencies with yum-builddep

After fiddling around with rpmbuild for quite a while, I stumbled upon yum-builddep. It’s basically a tool to install all packages required to rebuild an RPM package from the SRPM. So if you want to install all “BuildRequires” mentioned in the spec file of a package, invoke

yum-builddep <package name>


The source RPM for the specified package must be available in the yum repository or it can be a local source RPM file.

yum-builddep itself it part of the yum-utils package. You can install it with yum

yum install yum-utils


Categories: Uncategorized Tags:

## Xen DomU hanging at “Checking for hardware changes”

Just a little memory hook:

When a Xen DomU hangs at “Checking for hardware changes”, it is probably due to a dead xenconsoled process on the Dom0. This happens from time to time but

[root@xen ~]# /usr/sbin/xenconsoled


should immediately fix the hanging DomUs.

Categories: Uncategorized Tags:

## Display current git branch in bash

Sometimes it’s very useful to know which git branch you are working on right from the command prompt. There are many solutions out there, but most of them include python and some awk or grep magic which can time a serious amount of time when you cd into a reasonably large git tree.

But you can also take advantage of the __git_ps1 function, provided by /etc/bash_completion.d/git in the git package. Add this line to ~/.bashrc:

export PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '


This setting helps you keep track of which branch you are in at a given time. If you are in a git working directory, it shows the current branch as part of the prompt:

[user@host directory-name (master)]$ If you do not have the bash-completion package installed, you must manually source the git completion script prior to using __git_ps1(). To do this, add source /etc/bash_completion.d/git  to ~/.bashrc. You might also want to display when there are changes in your work tree or the git index: [user@host directory-name (master*)]$
[user@host directory-name (master+)]$[user@host directory-name (master%)]$

• * indicates that a tracked file was modified
• + indicates that a tracked file was modified and staged (with git add)
• % indicates that you have untracked files in your tree

To do so, simply add these lines in your ~/.bashrc, right before the line modifying your prompt:

export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true


See the comments at the beginning of /etc/bash_completion.d/git for more details.

Categories: Uncategorized Tags: