JuanLu,
We do it exactly just like you said...
Is here how:
* Create a disk image (dd if=/dev/zero of=somefile.img bs=1 count=1 seek=8G)
* Format disk image (mkfs.ext2 somefile.img)
* Mount disk image (mount -o loop somefile.img looppoint)
* Copy your files (tar -zxSf yourtarballingzformat -C looppoint)
* Unmount your loop (umount loop)
* Create your swap file (if you want) (dd if=/dev/zero of=xen-swap.img bs=1M count=256) <-- no sparse file for this...
* Create your xen.conf file for that image.
xen.conf...
name = 'myvm'
memory = '256'
disk = [ 'tap:aio:/xen/myvm/somefile.img,sda1,w',
'tap:aio:/xen/myvm/xen-swap.img,sda2,w',
]
root = '/dev/sda1 ro'
vif = [ 'mac=00:16:3e:22:10:f8,bridge=eth0' ]
on_reboot = 'restart'
on_crash = 'restart'
vcpus = 2
kernel = "/xen/centos_boot/vmlinuz-2.6.18-92.1.18.el5xen"
ramdisk = "/xen/centos_boot/2.6.18-92.1.18.el5xen.img"
Please note that I'm running this under FC8 but booting the domU with CentOS kernel (thus the ramdisk/kernel). That is probably the only thing you will need to change and get additional advice on.
Two things to note.
* Whatever kernel you boot the domU in is what you need the lib files for (copied into the vm). This simplifies things. You could roll your own domU kernel which some people have been doing. I'm using this one since we are doing development specific to CentOS.
* Think up a file naming convention that suites you. We use /xen/vmname/xen-D[x].img (where x is the disk number starting at zero) for the files (except swap which is names xen-swap.img).