Updated README files.
*.iso
+livecd.ks
livecd-test.ks
livecd-post.sh
\ No newline at end of file
@echo "make build Build the live CD ISO"
@echo "make boot [ISO=foo.iso] Boot built/named ISO (uses qemu)"
-build: livecd-test.ks
+build: livecd.ks
rm -f $(LABEL).iso
livecd-creator \
--config=$< \
boot:
qemu -m 512 -cdrom $(ISO)
-livecd-test.ks: livecd-test.ks.in livecd-post.sh Makefile
+livecd.ks: livecd.ks.in livecd-post.sh Makefile
sed \
-e 's|@BASEREPO@|$(BASEREPO)|g' \
-e 's|@LANG@|$(LANG)|g' \
< $< > $@
clean:
- rm -f *~ core livecd-test.ks livecd-post.sh
+ rm -f *~ core livecd.ks livecd-post.sh
+$Id$
+
virt-p2v : P2V ("physical to virtual") migration tool
----------------------------------------------------------------------
-The files in this directory are:
+$Id$
-livecd-test.ks.in
+Background reading
+----------------------------------------------------------------------
+
+About Live CDs / livecd-creator tool:
+
+ http://fedoraproject.org/wiki/FedoraLiveCD/LiveCDHowTo
+
+The files in this directory
+----------------------------------------------------------------------
+
+livecd.ks.in
+
+ Kickstart file which describes how to build the live CD. This is
+ essentially the configuration file for livecd-creator. Most
+ importantly it lists the RPMs which are needed on the live CD.
livecd-post.sh.in
+ This is the %post-configuration section of the Kickstart script. It
+ is a shell script which runs after the RPMs have been installed but
+ before the live CD is turned into an ISO. The shell script creates
+ any extra files we need on the live CD.
+
p2v.init
+ This is installed on the live CD as /etc/init.d/p2v, and it causes the
+ live CD to boot into the P2V configuration tool (see next).
+
virt-p2v.sh
+
+ This is the virt-p2v.sh P2V configuration tool itself. It is
+ installed on the live CD as /usr/bin/virt-p2v.sh and runs after the
+ live CD has booted. All the P2V stuff happens from this script. It
+ uses the 'dialog' program to ask questions.
+
+General implementation plan
+----------------------------------------------------------------------
+
+User boots the live CD. The job of the live CD is to:
+
+(a) Find local disks.
+
+(b) Copy the disk image(s) over to the Xen host.
+
+(c) Change certain files (eg. /etc/fstab may contain references to
+disk devices, which need to be changed when running under Xen).
+
+(d) BUT, the live CD must be totally non-destructive. It cannot
+modify the local disks in any way.
+
+(e) The above steps are not automatic. We need to ask the user some
+questions along the way.
+
+For (a) there are various methods to detect local devices. We sniff
+for devices in /sys/block.
+
+For (b) we can simply use 'dd' and 'ssh'. The general plan is to do
+this:
+
+ dd if=/dev/disk | gzip | ssh xenhost 'cat > /var/lib/xen/images/disk.img'
+
+If the user doesn't have sshd installed on the Xen host, then they can
+also opt for a pure TCP transport:
+
+ dd if=/dev/disk | gzip | nc xenhost port
+
+ and on the remote host they do:
+ nc -l -p port > /var/lib/xen/images/disk.img
+
+For (c) we can use device-mapper snapshots to mount a ramdisk above
+the disks themselves. This allows us to make non-destructive changes
+to files, and still see the "modified" block device (d). A hairy
+shell script looks for candidate files to modify.
+
+Non-generic virt-p2v
+----------------------------------------------------------------------
+
+The above describes the generic virt-p2v, which asks users questions
+after boot. It is also possible to build your own live CD, based on
+virt-p2v which has various settings compiled in, so it runs
+automatically.
\ No newline at end of file
grep
sed
gawk
+findutils
# Some other generally useful packages
which
#!/bin/bash
#
# virt-p2v.sh is a shell script which performs a physical to
-# virtual conversion of local disks, interactively.
+# virtual conversion of local disks.
#
# By Richard W.M. Jones <rjones@redhat.com>
+#
+# Copyright (C) 2007 Red Hat Inc.
+
+export PATH=/usr/sbin:/sbin:/usr/local/bin:/usr/kerberos/bin:/usr/bin:/bin
+
+# The defaults here make a generic virt-p2v.sh script, but if you want
+# to build a partially-/fully-automatic P2V solution, then you can set
+# these variables to something, and the script won't ask the user for
+# input.
+
+# greeting=no
+greeting=
+
+override_remote_host=
+override_remote_port=
+
+# can be 'ssh' or 'tcp'
+override_remote_transport=
+
+# eg. override_remote_directory=/var/lib/xen/images
+# (only if override_remote_transport is 'ssh')
+override_remote_directory=
+
+# list of devices to send, separated by spaces, if empty ask user
+override_devices_to_send=""
+
+#----------------------------------------------------------------------
+# Device mapper snapshotting.
+
+# Create a device-mapper snapshot of a device with ramdisk overlay.
+# Example:
+# snapshot /dev/sda1 snap
+# creates a snapshot of /dev/sda1 called /dev/mapper/snap
+
+
+# XXX Error checking.
+function snapshot {
+ dev=$1
+ name=$2
+
+ # Get size of the device in sectors.
+ sectors=`blockdev --getsize $dev`
+
+ dmsetup create ${name}_org \
+ --table="0 $sectors snapshot-origin $dev"
+ dmsetup create $name \
+ --table="0 $sectors snapshot /dev/mapper/${name}_org /dev/ram1 n 64"
+}
+
+# Drop an existing snapshot created by snapshot function.
+# Example:
+# drop_snapshot snap
+# drops a snapshot called /dev/mapper/snap
+function drop_snapshot {
+ dmsetup remove /dev/mapper/$name
+ dmsetup remove /dev/mapper/${name}_org
+}
+
+
+#----------------------------------------------------------------------
+# General script setup.
+
+# We can safely write files into /tmp without modifying anything.
+cd /tmp
+
+#----------------------------------------------------------------------
+# Dialog with the user.
+
+if [ "$greeting" != "no" ]; then
+ dialog \
+ --title "virt-p2v" \
+ --msgbox "\nWelcome to virt-p2v, a live CD for migrating a physical machine to a virtualized host.\n\nTo continue press the Return key.\n\nTo get a shell you can use [ALT] [F2] and log in as root with no password." 17 50
+fi
+
+# Get configuration from the user.
+
+# To make the [Back] button work, we make this into a looping state
+# machine. Each state asks a question and jumps to the next state
+# (unless [Back] is pressed, in which case it jumps back to the previous
+# state). Finally the 'exit' state causes us to quit the loop.
+state=hostname
+while [ "$state" != "exit" ]; do
+ case "$state" in
+ hostname)
+ if [ -n "$override_remote_host" ]; then
+ remote_host="$override_remote_host"
+ else
+ dialog \
+ --nocancel \
+ --inputbox "Remote host" 10 50 "$remote_host" \
+ 2> line
+ remote_host=`cat line`
+ state=port
+ fi
+ ;;
+ port)
+ if [ -n "$override_remote_port" ]; then
+ remote_port="$override_remote_port"
+ else
+ dialog \
+ --extra-button --extra-label "Back" --nocancel \
+ --inputbox "Remote port" 10 50 "$remote_port" \
+ 2> line
+ if [ $? -eq 3 ]; then state=hostname
+ else
+ remote_port=`cat line`
+ state=exit
+ fi
+ fi
+ ;;
+ *)
+ echo "Invalid state: $state"
+ state=hostname
+ ;;
+ esac
+done
+clear
+echo remote_host $remote_host
+echo remote_port $remote_port
\ No newline at end of file