hostOS.
What you need:
- have a host os which runs xen in dom0 (you can install a centOS and choose virtualization as profile)
- some disk space (i put 20Gb for the / and 2 for swap)
- run the following two commands to set the volumes
pvcreate /dev/sda7 -- change the /dev/sda7 with whatever you want to
vgcreate VolGroup00 /dev/sda7 -- change the /dev/sda7 with whatever you want to
if unsure what to do look it on on how to create volumes in linux (google it ... )
The following script will create you and image:
#!/bin/sh
##########################################
echo $0 "Starting" #
echo "This script will clone the guestOS #
creating a new xen image" #
#
# echo "Author: dioda11@gmail.com" #
##########################################
if [ $@ ne 1 ]; then
echo "please give a numeric identifier for the clone
between 10 and 100"
exit 1;
# if ![ $1 lt 100 ]
fi
IMGID=$1
BASEDIRMOUNT=/mnt
VOLGROUP=VolGroup00
lvcreate -L 20G -n LV_VM$IMGID_RH5.3_ROOT $VOLGROUP
lvcreate -L 2G -n LV_VM$IMGID_RH5.3_SWAP $VOLGROUP
mkfs.ext3 /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT
mkswap /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_SWAP
if [ -d $BASEDIRMOUNT/$IMGID ]; then
mount /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT $BASEDIRMOUNT/$IMGID
echo "Mounting the /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT was " $?
else
mkdir -p $BASEDIRMOUNT/$IMGID
echo "Creating $BASEDIRMOUNT/$IMGID was " $?
mount /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT $BASEDIRMOUNT/$IMGID
echo "Mounting the /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT was " $?
fi
echo "Cloning the host OS === "
ARCH=`uname -m`
if [ $ARCH == "x86_64" ]; then
cp -ax /{bin,dev,etc,lib,lib64,root,sbin,usr,var} $BASEDIRMOUNT/$IMGID
else
cp -ax /{bin,dev,etc,lib,root,sbin,usr,var} $BASEDIRMOUNT/$IMGID
fi
mkdir $BASEDIRMOUNT/$IMGID/{home,proc,opt,sys,tmp}
chmod 777 $BASEDIRMOUNT/$IMGID/tmp
echo "Cloning finished === " $?
echo "At this point you need to fix the /etc/fstab and create the xen config file"
# umount $BASEDIRMOUNT/$IMGID
------------------------
0 comments:
Post a Comment