summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorrjones <rjones>2009-03-20 16:00:04 +0000
committerrjones <rjones>2009-03-20 16:00:04 +0000
commitc7f1933cab6a4da2f201da741003ba2449c8bbde (patch)
tree2522b1563d5b196269091c165466838c0aa3763a /examples
parent37bbdb07326d285b7bd6011da9119a46c09897e5 (diff)
downloadfebootstrap-c7f1933cab6a4da2f201da741003ba2449c8bbde.tar.gz
febootstrap-c7f1933cab6a4da2f201da741003ba2449c8bbde.tar.xz
febootstrap-c7f1933cab6a4da2f201da741003ba2449c8bbde.zip
Added guestfs example.
Diffstat (limited to 'examples')
-rw-r--r--examples/.cvsignore3
-rw-r--r--examples/Makefile.am4
-rwxr-xr-xexamples/guestfs-test.sh67
3 files changed, 73 insertions, 1 deletions
diff --git a/examples/.cvsignore b/examples/.cvsignore
index dd87bfc..bef3f0d 100644
--- a/examples/.cvsignore
+++ b/examples/.cvsignore
@@ -1,5 +1,8 @@
Makefile.in
Makefile
+guestfs
+guestfs-initrd.img
+guest-image
minimal
minimal-initrd.img
vmlinuz
diff --git a/examples/Makefile.am b/examples/Makefile.am
index dae53af..08fb42b 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -18,4 +18,6 @@
# Written by Richard W.M. Jones <rjones@redhat.com>
EXTRA_DIST = \
- README minimal-filesystem.sh
+ README \
+ minimal-filesystem.sh \
+ guestfs-test.sh
diff --git a/examples/guestfs-test.sh b/examples/guestfs-test.sh
new file mode 100755
index 0000000..b45c1f4
--- /dev/null
+++ b/examples/guestfs-test.sh
@@ -0,0 +1,67 @@
+#!/bin/sh -
+
+# Before running, make sure 'vmlinuz' in this examples directory is a
+# bootable Linux kernel or a symlink to one. You can just use any
+# kernel out of the /boot directory for this.
+#
+# eg:
+# cd examples
+# ln -s /boot/vmlinuz-NNN vmlinuz
+#
+# Also make 'guest-image' be a symlink to a virtual machine disk image.
+
+# This is a realistic example for 'libguestfs', which contains a
+# selection of command-line tools, LVM, NTFS and an NFS server.
+
+if [ $(id -u) -eq 0 ]; then
+ echo "Don't run this script as root. Read instructions in script first."
+ exit 1
+fi
+
+if [ ! -e vmlinuz -o ! -e guest-image ]; then
+ echo "Read instructions in script first."
+ exit 1
+fi
+
+../febootstrap \
+ -i bash \
+ -i coreutils \
+ -i lvm2 \
+ -i ntfs-3g \
+ -i nfs-utils \
+ -i util-linux-ng \
+ -i MAKEDEV \
+ fedora-10 ./guestfs $1
+
+echo -n "Before minimization: "; du -sh guestfs
+../febootstrap-minimize --all ./guestfs
+echo -n "After minimization: "; du -sh guestfs
+
+# Create the /init which will scan for and enable all LVM volume groups.
+
+( cd guestfs && cat > init <<'__EOF__'
+#!/bin/sh
+PATH=/sbin:/usr/sbin:$PATH
+MAKEDEV mem null port zero core full ram tty console fd \
+ hda hdb hdc hdd sda sdb sdc sdd loop sd
+mount -t proc /proc /proc
+mount -t sysfs /sys /sys
+mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
+modprobe sata_nv pata_acpi ata_generic
+lvm vgscan --ignorelockingfailure
+lvm vgchange -ay --ignorelockingfailure
+/bin/bash -i
+__EOF__
+chmod +x init
+)
+
+# Convert the filesystem to an initrd image.
+
+../febootstrap-to-initramfs ./guestfs > guestfs-initrd.img
+
+# Now run qemu to boot this guestfs system.
+
+qemu-system-$(arch) \
+ -m 128 \
+ -kernel vmlinuz -initrd guestfs-initrd.img \
+ -hda guest-image -boot c