Archive for July 2009
Using LVM2 Snapshots to provide rollback functionality for Xen Domain loopback images
LVM2 is a set of tools which work with the device-mapper drivers of the linux kernel to provide volume management. The provide a convenient set of tools for creating,resizing and deleting volumes which can span or be striped over multiple disks. One of the convenient pieces of functionality provided by LVM is the ability to take a snapshot of an LVM volume and make it visible as another partition. This is typically useful when you want to take consistent backups. For example if you know your database is in a consistent state, you can lock it for a moment, create a volume snapshot which takes just a few seconds, and then unlock the database. You can then backup the snapshot volume to slow media or whatever. What has this got to do with [Xen http://www.xen.org/] the visualization mechanism? Well it turns out that you can write to an LVM2 snapshot, and the original volume is unaffected. This means you can create a snapshot of a volume containing lvm loopback images in your desired state, then run the virtual machine on the snapshot images instead. To rollback, you simply power off the machine even with xm destroy unmount and remove the snapshot, and then recreate the snapshot and reboot the virtual machine. A process that takes only a few seconds. Here below is how its done in practice:
1) Create the snapshot of /dev/vga/domU with enough space for 6GB of alterations
lvcreate -L6G -s -n domU.S /dev/vga/domU
(the snapshot doesnt have to be the same size as the original, it only has to have enough space to store the differences)
2) Create a mount point to mount the snapshot:
mkdir -p /workarea/xen/domains.S
3) mount the snapshot:
mount -t auto /dev/vga/domU.S /workarea/xen/domains.S/
4) Start the virtual machine
xm create -c /etc/xen/myvirtual-S.cfg
The configuration file will need to have had the paths to the loopback images updated so that they point to the versions on the snapshot
4) After the machine has finished unmount and remove the snapshot volumes:
umount /workarea/xen/domains.S
lvremove -f /dev/mapper/vga-domU.S
5) rinse and repeat
When you create a new snapshot its condition will of course be the original version of the virtual machine provided no changes have been made to it in the mean time.
You might also be interested in more articles about Ubuntu Xen
Recently when configuring and using xen virtual machines for older versions of Linux distributions, such as Centos 4, I experienced a keyboard mapping problem with FreeNX and the NX Client. The problem didn't exist when accessing the NX server from Windows, only from newer Linux distributions such as Ubuntu Juanty. A typical symptom of the problem is that the up arrow key is mapped to the print key, and the other arrow keys/cursor keys don't work. It seems the actual cause of the problem is a difference between newer and older versions of xorg. Newer versions use the evdev driver and evdev mappings, while the older xorg versions use xf86 keyboard mappings. It seems that these two mappings are not compatible.
In fact a patch and a work around exists. It turns out that Nomachine have in fact created a work around for this problem, and its in the released version of NX 3.3. This of course wont be the version you will find in your older distributions, so you will need to scout around a bit for a version for your operating system. However installing the updated version of nx alone wont in fact work. You need to patch your version of freenx. The latest released version of freenx is 0.7.3, so you should try and install that. Then you will need to patch the version of nxnode installed by freenx with the patch below. This will call nx with additional parameters to enable to workaround. These updates and patched need to be installed on the server side (where you are running the older distribution with the older xorg). To install the patch, you can save it to a file called nxnode.patch in the /usr/bin/ directory where the nxnode file is, and then use something like 'patch -p0 < nxnode.patch'.
Server Versions for Centos 4
freenx-0.7.3-1.el4.centos
nx-3.3.0-35.el4
Patch
--- nxnode 2009-01-14 04:22:40 +0000
+++ nxnode 2009-01-14 04:24:02 +0000
@@ -555,7 +555,8 @@
# Start the agent
- PATH="$PATH_BIN:$PATH" $PATH_BIN/nxagent $P $R -name "NX - $user@$SERVER_NAME:$display - $session (GPL Edition)" -option "$USER_FAKE_HOME/.nx/C-$sess_id/options" $K $G $B $FP $AGENT_EXTRA_OPTIONS_X :$display 2>&3 &
+ #PATH="$PATH_BIN:$PATH" $PATH_BIN/nxagent $P $R -name "NX - $user@$SERVER_NAME:$display - $session (GPL Edition)" -option "$USER_FAKE_HOME/.nx/C-$sess_id/options" $K $G $B $FP $AGENT_EXTRA_OPTIONS_X :$display 2>&3 &
+ PATH="$PATH_BIN:$PATH" $PATH_BIN/nxagent $R -name "NX - $user@$SERVER_NAME:$display - $session (GPL Edition)" -option "$USER_FAKE_HOME/.nx/C-$sess_id/options" $B $FP $AGENT_EXTRA_OPTIONS_X :$display 2>&3 &
fi
#
@@ -1094,6 +1095,8 @@
# Rootless fix from 2x nxserver 1.5.0
realtype=$type
[ "$type" = "unix-application" -o "$type" = "unix-default" ] && realtype="unix-desktop"
+ [ "$type" = "unix-gnome" ] && realtype="gnome"
+ [ "$type" = "unix-kde" ] && realtype="kde"
# NX 2.1.0 file-sharing port options
client=$(getparam client)
@@ -1272,7 +1275,7 @@
umask 0077
cat << EOF > "$USER_FAKE_HOME/.nx/C-$sess_id/options"
-${keyboard:+keyboard=$keyboard,}${kbtype:+kbtype=$kbtype,}${kbload:+kbload=$kbload,}${keymap:+keymap=$keymap,}${resize:+resize=$resize,}${CACHE}${IMAGES}${PACK}link=$link,nodelay=$nodelay,type=$realtype,cleanup=0,${ACCEPT}cookie=$proxy_cookie,id=$sess_id,samba=$samba,media=$media${sync:+,sync=$sync}${cups:+,cups=$cups}${keybd:+,keybd=$keybd}${aux:+,aux=$aux}${http:+,http=$http}${rdpcolors:+,rdpcolors=$rdpcolors}${rdpcache:+,rdpcache=$rdpcache}${fullscreen:+,fullscreen=1}${clipboard:+,clipboard=$clipboard}${menu:+,menu=$menu}:$display
+nx/nx,${keyboard:+keyboard=$keyboard,}${kbtype:+kbtype=$kbtype,}${kbload:+kbload=$kbload,}${keymap:+keymap=$keymap,}${geometry:+geometry=$geometry,}${client:+client=$client,}${resize:+resize=$resize,}${CACHE}${IMAGES}${PACK}link=$link,nodelay=$nodelay,type=$realtype${clipboard:+,clipboard=$clipboard}${composite:+composite=$composite},cleanup=0,product=LFE/None/LFEN/None,shmem=1,${backingstore:+backingstore=$backingstore,}shpix=1,${ACCEPT}cookie=$proxy_cookie,id=$sess_id,samba=$samba,media=$media${sync:+,sync=$sync}${cups:+,cups=$cups}${keybd:+,keybd=$keybd}${aux:+,aux=$aux}${http:+,http=$http}${rdpcolors:+,rdpcolors=$rdpcolors}${rdpcache:+,rdpcache=$rdpcache}${fullscreen:+,fullscreen=1}${menu:+,menu=$menu}:$display
EOF
umask $OLD_UMASK
#samba=$samba,
References
Quickstart howto install amanda backup 2.6 on Ubuntu 9.04 Jaunty Jakalope
wget http://www.zmanda.com/downloads/community/Amanda/2.6.1p1/Ubuntu-Intrepid/amanda-backup-server_2.6.1p1-1_i386.deb
dpkg -i amanda-backup-server_2.6.1p1-1_i386.deb
apt-get -f install
chmod u+x /tmp/amanda/
mkdir -p /usr/adm/amanda/
chown amandabackup /usr/adm/amanda/
chown amandabackup /var/amanda
Amanda will run under the username amandabackup
home directory is /var/lib/amanda/
configuration files go in /etc/amanda/