All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harry Butterworth <harry@hebutterworth.freeserve.co.uk>
To: xen-devel@lists.xensource.com
Subject: [PATCH] create an initrd for dom0 in install.sh script
Date: Mon, 03 Apr 2006 14:34:21 +0100	[thread overview]
Message-ID: <1144071261.9237.44.camel@localhost.localdomain> (raw)

[-- Attachment #1: Type: text/plain, Size: 4210 bytes --]

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@uk.ibm.com>

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 #2: initrd.patch --]
[-- Type: text/x-patch, Size: 2550 bytes --]

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 #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2006-04-03 13:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1144071261.9237.44.camel@localhost.localdomain \
    --to=harry@hebutterworth.freeserve.co.uk \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.