html/guestfs-python.3.html
html/guestfs-ruby.3.html
html/guestmount.1.html
-html/recipes.html
html/virt-cat.1.html
html/virt-copy-in.1.html
html/virt-copy-out.1.html
debian/shlibs.local \
debian/watch \
html/pod.css \
- html/recipes.css \
libguestfs.pc libguestfs.pc.in \
libtool-kill-dependency_libs.sh \
logo/fish.svg logo/fish.png \
- make-recipes.sh \
m4/.gitignore \
- recipes/LICENSE \
- recipes/README \
- recipes/*.html \
- recipes/*.sh \
- recipes/*.example \
run \
update-bugs.sh
-# Recipes web page.
-html/recipes.html: $(wildcard recipes/*.sh) $(wildcard recipes/*.html) $(wildcard recipes/*.example) Makefile make-recipes.sh
- mkdir -p html
- rm -f $@ $@-t
- sh make-recipes.sh recipes/*.sh > $@-t
- mv $@-t $@
-
HTMLFILES = \
html/guestfs.3.html \
html/guestfs-examples.3.html \
html/virt-tar.1.html \
html/virt-tar-in.1.html \
html/virt-tar-out.1.html \
- html/virt-win-reg.1.html \
- html/recipes.html \
- html/pod.css html/recipes.css
+ html/virt-win-reg.1.html
TEXTFILES = BUGS README RELEASE-NOTES ROADMAP TODO
+++ /dev/null
-/* CSS to make pod2html files look a little bit better. */
-@import url("http://people.redhat.com/~rjones/css/standard.css");
-
-div.example pre {
- /*font-weight: bold;*/
- width: 40em;
- border: 1px solid #c00;
-}
\ No newline at end of file
+++ /dev/null
-#!/bin/sh -
-# libguestfs
-# Copyright (C) 2009 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-cat <<EOF
-<html>
- <head>
- <title>guestfish recipes</title>
- <link rel="stylesheet" href="recipes.css" type="text/css" title="Standard"/>
- </head>
- <body>
- <h1>guestfish recipes</h1>
- <p>You can also find these in the
- <a href="http://git.annexia.org/?p=libguestfs.git;a=tree;f=recipes;hb=HEAD"><code>recipes/</code>
- subdirectory</a> of the source.</p>
-
- <p>
- <a href="http://libguestfs.org/download/">Download
- libguestfs and guestfish here</a> or
- <a href="http://libguestfs.org/">go to the
- libguestfs home page</a>.
- </p>
-
- <h2>Table of recipes</h2>
- <ul>
-EOF
-
-for f in recipes/*.sh; do
- b=`basename $f .sh`
- echo -n ' <li> <a href="#'$b'">'$b.sh
- if [ -r recipes/$b.title ]; then
- echo -n ': '
- cat recipes/$b.title
- fi
- echo '</a> </li>'
-done
-echo ' </ul>'
-echo
-echo
-
-for f in recipes/*.sh; do
- b=`basename $f .sh`
- echo -n '<a name="'$b'"></a>'
- echo -n '<h2>'$b'.sh'
- if [ -r recipes/$b.title ]; then
- echo -n ': '
- cat recipes/$b.title
- fi
- echo -n '<small style="font-size: 8pt; margin-left: 2em;"><a href="#'$b'">permalink</a></small>'
- echo '</h2>'
- if [ -r recipes/$b.html ]; then
- cat recipes/$b.html
- fi
- echo '<h3>'$b'.sh</h3>'
- echo '<div class="example">'
- source-highlight --output=STDOUT --src-lang=sh --input=$f
- echo '</div>'
- if [ -r recipes/$b.example ]; then
- echo '<h3>Example output</h3>'
- echo '<pre>'
- sed -e 's,&,\&,g' -e 's,<,\<,g' -e 's,>,\>,g' < recipes/$b.example
- echo '</pre>'
- fi
-done
-
-echo '</body></html>'
+++ /dev/null
-All the scripts in the recipes/ subdirectory may be freely
-copied without any restrictions.
+++ /dev/null
-This directory contains guestfish-based shell which give some useful
-recipes to follow.
-
-These also get copied to the website here:
-http://libguestfs.org/recipes.html
-
-The format for each recipe is:
-
- foo.sh Shell script, using guestfish.
- foo.title The title of the recipe.
- foo.html HTML snippet describing the recipe.
- foo.example Plain text snippet showing example output.
-
-Everything in the recipes/ directory may be used and distributed
-without restrictions.
-
-To run a script before libguestfs has been installed, you can do
-something like this:
-
- LIBGUESTFS_PATH=../appliance PATH=../fish:$PATH ./show-devices.sh disk.img
-
-You can apply these recipes in your own programs by translating the
-guestfish commands into API calls in the language of your choice. The
-translation is a simple 1-1 mapping.
-
-Got a useful tip or recipe? Please contribute ...
+++ /dev/null
-$ clone.sh /tmp/test.img /tmp/new.img /dev/sda1 192.168.1.1 newmachine
-204800+0 records in
-204800+0 records out
-104857600 bytes (105 MB) copied, 2.02821 s, 51.7 MB/s
-
-$ guestfish -a /tmp/new.img -m /dev/sda1
-
-Welcome to guestfish, the libguestfs filesystem interactive shell for
-editing virtual machine filesystems.
-
-Type: 'help' for a list of commands
- 'man' to read the manual
- 'quit' to quit the shell
-
-><fs> cat /etc/resolv.conf
-nameserver 192.168.1.1
-><fs> cat /etc/HOSTNAME
-newmachine
+++ /dev/null
-<p>
-This script shows how you might have a library of premade
-virtual machines ready for cloning, but as a final step you
-use libguestfs or guestfish to customize some configuration
-files inside the VM before it's ready to go.
-</p>
-
-<p>
-In this simple recipe, we overwrite the <code>/etc/resolv.conf</code> file
-with a new nameserver entry, and change <code>/etc/HOSTNAME</code>.
-</p>
-
-<p>
-There are lots of possible improvements to this script, such as
-using qcow2 snapshots so that cloned VMs share storage with their
-"parent" preimages.
-</p>
-
-<p>
-For more information about cloning images using libvirt and libguestfs
-see <a href="https://rwmj.wordpress.com/2010/09/24/tip-my-procedure-for-cloning-a-fedora-vm/#content">Richard Jones's procedure for cloning a Fedora VM</a>.
-</p>
+++ /dev/null
-#!/bin/sh -
-
-preimage="$1" ;# original guest
-newimage="$2" ;# new guest
-root="$3" ;# root filesystem
-nameserver="$4" ;# new nameserver
-hostname="$5" ;# new hostname
-
-dd if="$preimage" of="$newimage" bs=1M
-
-guestfish -a "$newimage" -m "$root" <<EOF
- write /etc/resolv.conf "nameserver $nameserver"
- write /etc/HOSTNAME "$hostname"
-EOF
+++ /dev/null
-Clone and edit a virtual machine
\ No newline at end of file
+++ /dev/null
-<p>
-If you messed up your VM and made it unbootable, it's
-often useful to be able to go in and edit <code>/boot/grub/grub.conf</code>.
-This guestfish script shows how to do that.
-</p>
-
-<pre>
-editgrub.sh broken-guest.img
-</pre>
-
-<p>
-See also <a href="http://libguestfs.org/virt-edit.1.html">virt-edit</a>.
-</p>
+++ /dev/null
-#!/bin/sh -
-
-guestfish -a "$1" -i edit /boot/grub/grub.conf
+++ /dev/null
-Fix an unbootable VM by editing /boot/grub/grub.conf
\ No newline at end of file
+++ /dev/null
-$ ./export2tar.sh /dev/mapper/Guests-RHEL53PV32 /dev/VolGroup00/LogVol00 \
- /home /tmp/home.tar.gz
-$ ll /tmp/home.tar.gz
--rw-rw-r--. 1 rjones rjones 824 2009-04-25 12:33 /tmp/home.tar.gz
-$ tar ztf /tmp/home.tar.gz
-./
-./rjones/
-./rjones/.bash_profile
-./rjones/.mozilla/
-./rjones/.mozilla/extensions/
-./rjones/.mozilla/plugins/
-./rjones/.bash_logout
-./rjones/.bashrc
-./rjones/.emacs
+++ /dev/null
-<p>
-This script lets you export any directory you like from a virtual
-machine as a tarball. For example, to export <code>/home</code>
-from a standard Fedora or RHEL virtual machine you would do:
-</p>
-
-<pre>
-export2tar.sh guest.img /dev/VolGroup00/LogVol00 /home home.tar.gz
-</pre>
-
-<p>
-<code>/dev/VolGroup00/LogVol00</code> is the partition or LV <i>inside</i>
-the VM which contains the directory you want.
-</p>
-
-<p>
-See also <a href="http://libguestfs.org/virt-tar.1.html">virt-tar</a>
-and <a href="https://rwmj.wordpress.com/2010/12/02/tip-uploading-and-downloading/#content">Richard
-Jones's complete list of ways to upload and download files</a>.
-</p>
+++ /dev/null
-#!/bin/sh -
-
-guestfish --ro -a "$1" -m "$2" tgz-out "$3" "$4"
+++ /dev/null
-Export the /home directory from a virtual machine into a tarball
\ No newline at end of file
+++ /dev/null
-$ ll -h /tmp/Fedora-11-Beta-i386-netinst.iso
--r--r--r--. 1 rjones rjones 168M 2009-04-25 22:38 /tmp/Fedora-11-Beta-i386-netinst.iso
-$ ./iso2tar.sh /tmp/Fedora-11-Beta-i386-netinst.iso /tmp/cd.tar.gz
-$ ls -lh /tmp/cd.tar.gz
--rw-rw-r--. 1 rjones rjones 177M 2009-04-25 22:50 /tmp/cd.tar.gz
-$ tar ztf /tmp/cd.tar.gz
-./
-./EFI/
-./EFI/BOOT/
-./EFI/BOOT/BOOT.conf
-./EFI/BOOT/BOOTIA32.conf
-./EFI/BOOT/splash.xpm.gz
-./EFI/BOOT/TRANS.TBL
-./images/
-./images/efiboot.img
-[etc]
+++ /dev/null
-<p>
-Convert a CD-ROM or DVD ISO to a tarball.
-</p>
-
-<p>
-Usage is very simple:
-</p>
-
-<pre>
-iso2tar.sh cd.iso output.tar.gz
-</pre>
-
-<p>
-See also <a href="http://libguestfs.org/virt-tar.1.html">virt-tar</a>
-and <a href="https://rwmj.wordpress.com/2010/12/02/tip-uploading-and-downloading/#content">Richard
-Jones's complete list of ways to upload and download files</a>.
-</p>
+++ /dev/null
-#!/bin/sh -
-
-guestfish -a "$1" --ro -m /dev/sda tgz-out / "$2"
+++ /dev/null
-Convert a CD-ROM or DVD ISO to a tarball
\ No newline at end of file
+++ /dev/null
-$ list-apps.sh win7.img
-[0] = {
- app_name: Mozilla Firefox (3.6.12)
- app_display_name: Mozilla Firefox (3.6.12)
- app_epoch: 0
- app_version: 3.6.12 (en-GB)
- app_release:
- app_install_path: C:\Program Files\Mozilla Firefox
- app_trans_path:
- app_publisher: Mozilla
- app_url: http://www.mozilla.com/en-GB/
- app_source_package:
- app_summary:
- app_description: Mozilla Firefox
-}
-[1] = {
- app_name: VLC media player
- app_display_name: VLC media player 1.1.5
- app_epoch: 0
- app_version: 1.1.5
- app_release:
- app_install_path: C:\Program Files\VideoLAN\VLC
- app_trans_path:
- app_publisher: VideoLAN
- app_url: http://www.videolan.org/
- app_source_package:
- app_summary:
- app_description:
-}
+++ /dev/null
-<p>
-The command lists the applications (eg. RPMs, debs, Windows programs)
-installed inside a virtual machine. It does this using the
-<a href="http://libguestfs.org/guestfs.3.html#inspection">inspection API</a>.
-</p>
-
-<p>
-See also <a href="http://libguestfs.org/virt-inspector.1.html">virt-inspector</a>.
-</p>
+++ /dev/null
-#!/bin/sh -
-
-eval "$(guestfish --ro -a "$1" --i --listen)"
-root="$(guestfish --remote inspect-get-roots)"
-guestfish --remote inspect-list-applications "$root"
-guestfish --remote exit
+++ /dev/null
-List the apps (eg. RPMs) installed inside a virtual machine
\ No newline at end of file
+++ /dev/null
-<p>
-List the files in a virtual machine.
-</p>
+++ /dev/null
-#!/bin/sh -
-
-guestfish --ro -a "$1" -i find0 / - |
- tr '\000' '\n' |
- sort
+++ /dev/null
-List the files and directories in a virtual machine
+++ /dev/null
-$ product-name.sh win.img
-Windows 7 Enterprise
+++ /dev/null
-<p>
-Get the string which describes the operating system installed in a
-virtual machine. This uses the
-<a href="http://libguestfs.org/guestfs.3.html#inspection">inspection API</a>.
-</p>
-
-<p>
-See also <a href="http://libguestfs.org/virt-inspector.1.html">virt-inspector</a>.
-</p>
+++ /dev/null
-#!/bin/sh -
-
-eval "$(guestfish --ro -a "$1" --i --listen)"
-root="$(guestfish --remote inspect-get-roots)"
-guestfish --remote inspect-get-product-name "$root"
-guestfish --remote exit
+++ /dev/null
-Get the operating system "Product Name" string
\ No newline at end of file
+++ /dev/null
-$ show-devices.sh /dev/mapper/Guests-RHEL53PV32
-/dev/sda
-/dev/sda1
-/dev/sda2
-/dev/sda2
-VolGroup00
-/dev/VolGroup00/LogVol00
-/dev/VolGroup00/LogVol01
+++ /dev/null
-<p>
-This very simple script shows how you can display an overview
-of what devices, partitions and LVM data are found in a
-guest image.
-</p>
-
-<p>
-See
-also <a href="http://libguestfs.org/virt-filesystems.1.html">virt-filesystems</a>.
-</p>
+++ /dev/null
-#!/bin/sh -
-
-guestfish -a "$1" <<EOF
-run
-list-devices
-list-partitions
-pvs
-vgs
-lvs
-EOF
+++ /dev/null
-Display the devices, partitions, LVs, VGs and PVs in a guest image
\ No newline at end of file
+++ /dev/null
-$ squashfs.sh
-Parallel mksquashfs: Using 4 processors
-Creating 4.0 filesystem on test.sqsh, block size 131072.
-[===============================================================|] 752/752 100%
-
-[...]
-
-Filesystem Size Used Avail Use% Mounted on
-/dev/vda1 97M 3.5M 89M 4% /sysroot/output
-
-$ guestfish -a test1.img -m /dev/sda1 ll /
-total 38
-drwxr-xr-x 4 root root 1024 Dec 21 16:52 .
-drwxr-xr-x 23 500 500 4096 Dec 21 16:52 ..
-drwx------ 2 root root 12288 Dec 21 16:52 lost+found
-drwxr-xr-x. 2 root root 19456 Dec 18 07:20 man8
+++ /dev/null
-<p>
-You can use squashfs to import large amounts of data
-into a guest. First you prepare the squashfs image:
-</p>
-
-<pre>
-/sbin/mksquashfs data <i>[...]</i> data.sqsh
-</pre>
-
-<p>
-and then you can add it to the guest as an extra data
-drive. In the example below, we show how to make a
-squashfs from the contents of some local directory
-(<code>/usr/share/man/man8</code> in this example)
-and then make that appear in the guest.
-</p>
-
-<p>
-See also <a href="http://libguestfs.org/virt-tar.1.html">virt-tar</a>
-and <a href="https://rwmj.wordpress.com/2010/12/02/tip-uploading-and-downloading/#content">Richard
-Jones's complete list of ways to upload and download files</a>.
-</p>
+++ /dev/null
-#!/bin/sh -
-
-datadir=/usr/share/man/man8
-rm -f test.sqsh
-/sbin/mksquashfs $datadir test.sqsh
-
-guestfish -N fs -a test.sqsh <<'EOF'
- mkmountpoint /output
- mkmountpoint /squash
- mount-options "" /dev/sda1 /output
- mount-options "" /dev/sdb /squash
- cp-a /squash /output/man8
- umount /squash
- df-h
- umount /output
-EOF
-
-rm test.sqsh
+++ /dev/null
-Mount data in a guest using squashfs
\ No newline at end of file
+++ /dev/null
-$ ./tar2vm.sh ../libguestfs-1.0.10.tar.gz /tmp/test.img 10M
+++ /dev/null
-<p>
-This script shows how you might generate a whole virtual
-machine, or a disk image for a virtual machine, starting
-with a tarball that contains the content for the machine.
-</p>
-
-<p>
-The usage is:
-</p>
-
-<pre>
-tar2vm.sh input.tar.gz output.img 100M
-</pre>
-
-<p>
-where (for example) <code>100M</code> is the size of the output
-disk image. You have to specify a size that is large enough to contain all
-the contents of the tarball, but not too large that there is too much
-wasted space (unless you want to give the VM extra working space of
-course).
-</p>
-
-<p>
-See also <a href="http://libguestfs.org/virt-make-fs.1.html">virt-make-fs</a>.
-</p>
+++ /dev/null
-#!/bin/sh -
-
-guestfish <<EOF
- alloc $2 $3
- run
- part-disk /dev/sda mbr
- mkfs ext3 /dev/sda1
- mount /dev/sda1 /
- tgz-in $1 /
- umount-all
-EOF
+++ /dev/null
-Make a virtual machine out of a tarball
\ No newline at end of file
+++ /dev/null
-<p>
-A simple way to see which home directory is using most
-space. Note this just counts the contents of directories
-in /home and doesn't include other files that a user may
-have.
-</p>
+++ /dev/null
-#!/bin/sh -
-
-vmfile="$1"
-dir=/home
-
-eval $(guestfish --ro -a "$vmfile" -i --listen)
-
-for d in $(guestfish --remote ls "$dir"); do
- echo -n "$dir/$d"
- echo -ne '\t'
- guestfish --remote du "$dir/$d";
-done | sort -nr -k 2
-guestfish --remote exit
+++ /dev/null
-See which user is using most space
\ No newline at end of file