WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] create an initrd for dom0 in install.sh script

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] create an initrd for dom0 in install.sh script
From: Harry Butterworth <harry@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 03 Apr 2006 14:34:21 +0100
Delivery-date: Mon, 03 Apr 2006 06:34:25 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Here is a second version of the patch.  I moved the symbolic link
creation into the install.sh file and created an external wrapper for
mkinitrd which detects the distro and calls the distro mkinitrd script
with the correct parameters.

The mkinitrd-wrapper currently only has support for debian-derived
distros because I decided not to submit any untested code.  If this
patch is accepted then the wrapper can easily be enhanced for other
distros by people who happen to have them installed and can test them.

I have tested both the debian-derived case (on ubuntu) and the case
where the script is unable to detect the distribution (in which case it
just reports an error and continues).

This patch is enough that a default installation of xen unstable will
now actually boot on my machine.

The initrd generated by this script is really only useful for dom0.  I
couldn't immediately see how to automatically create a correct initrd
for a domU.  The problem is that the distro mkinitrd script assumes that
it is executing on the machine for which the initrd is intended and so
probes for things like the root device and the configuration of any raid
arrays etc.  All this probed information would be incorrect for a domU.

It's already possible to create domUs with the -xen kernel since the
default -xen kernel doesn't need an initrd as the front-end drivers are
built-in by default.

I'm not going to take this any further---it's good enough to get a
default installation up and running for a new developer---anything more
sophisticated should probably be left for the distro package
maintainers.

Signed-off-by: Harry Butterworth <butterwo@xxxxxxxxxx>

diff -r 4ad317429111 -r e82e67a38b9c install.sh
--- a/install.sh        Sun Apr  2 15:16:53 2006
+++ b/install.sh        Mon Apr  3 13:26:22 2006
@@ -44,6 +44,25 @@
 (cd $tmp; tar -cf - *) | tar --no-same-owner -C "$dst" -xf -
 rm -rf "$tmp"
 
+if [ -x "$(which mkinitrd)" ] && [ -x "$(which depmod)" ] && [ $dst ==
'/' ]; then
+  cd $src/lib/modules
+  for i in *; do
+    cd ->/dev/null
+    cd $dst/boot
+    echo " - attempting to create initrd-$i.img..."
+    depmod $i
+    if $dst/etc/xen/scripts/mkinitrd-wrapper -o initrd-$i.img -v $i;
then
+      ln -s -f initrd-$i.img initrd-2.6-xen.img
+      echo "    - success."
+    else
+      echo "    - failed. You may need to create an initrd manually."
+    fi
+  done
+  cd ->/dev/null
+else
+  echo " - you may need to create an initrd manually."
+fi
+
 echo "All done."
 
 echo "Checking to see whether prerequisite tools are installed..."
diff -r 4ad317429111 -r e82e67a38b9c tools/examples/Makefile
--- a/tools/examples/Makefile   Sun Apr  2 15:16:53 2006
+++ b/tools/examples/Makefile   Mon Apr  3 13:26:22 2006
@@ -28,6 +28,7 @@
 XEN_SCRIPTS += block-enbd block-nbd
 XEN_SCRIPTS += vtpm vtpm-delete
 XEN_SCRIPTS += xen-hotplug-cleanup
+XEN_SCRIPTS += mkinitrd-wrapper
 XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh
 XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh
vif-common.sh
 XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh
vtpm-hotplug-common.sh
diff -r 4ad317429111 -r e82e67a38b9c tools/examples/mkinitrd-wrapper
--- /dev/null   Sun Apr  2 15:16:53 2006
+++ b/tools/examples/mkinitrd-wrapper   Mon Apr  3 13:26:22 2006
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+set -e
+
+usage()
+{
+       cat >&2 << EOF
+
+Usage: $0 -o output_file -v version_string
+
+Call the distro mkinitrd using the distro-specific syntax.
+
+Options:
+  -o output_file    The pathname of the created initrd file.
+  -v version_string The version of the kernel for which to create the
initrd.
+EOF
+       exit 1
+}
+
+while getopts "o:v:" flag; do
+       case $flag in
+       o)
+               output_file="${OPTARG}"
+               got_output_file=yes
+               ;;
+       v)
+               version_string="${OPTARG}"
+               got_version_string=yes
+               ;;
+       *)
+               usage
+               ;;
+       esac
+done
+
+shift $(($OPTIND - 1))
+
+if ! [ $got_output_file ] || ! [ $got_version_string ] || [ $# -gt 0 ];
then
+       usage
+fi
+
+if   [ -e /etc/debian_version ]; then
+       distro="debian-derived"
+else
+       distro="unknown"
+fi
+
+case $distro in
+"debian-derived")
+       mkinitrd -o $output_file $version_string
+       ;;
+"unknown")
+       echo "Sorry don't know how to call mkinitrd on your distro."
+       exit 1
+       ;;
+esac

Attachment: initrd.patch
Description: Text Data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] create an initrd for dom0 in install.sh script, Harry Butterworth <=