=head1 NAME

lvm2create_initrd - create initrd image for booting to root\-on\-LVM2

=head1 SYNOPSIS

B<lvm2create_initrd> [ B<-h|--help> ] [ B<-v|--verbose> ] [ B<-c|--lvmconf> I</path/to/lvm.conf> ] [ B<-m|--modules> "I<module1 module2 ...>" ] [ B<-e|--extra> "I<file1 file2 ...>" ] [ B<-r|--raid> "I</dev/md1 /dev/md2 ...>" ]
[ B<-R|--raidconf> I</path/to/mdadm.conf> ] [ B<-M|--makedev> I<style> ]

=head1 DESCRIPTION

lvm2create_initrd creates an initial ramdisk (initrd) image suitable for booting to system that has an LVM2 volume as its root filesystem.

To boot to such a setup, you'll
either need a bootloader that understands LVM2 volumes, or you'll need a
filesystem on a regular volume to act as a boot partition (typically mounted
on /boot).

The resulting initrd image is fairly full-featured. It can harbor and load
kernel modules, start MD devices, and boot to a shell to perform rescue
operations.

=head2 Booting to your initrd Image:

The filesystem image created is an ext2fs filesystem, hence your kernel must have
ext2fs built into it statically in order to boot to the image.

Once you create your initrd image, you must pass the correct options to the kernel when
you boot using it. Your kernel command line should look something like this:

B<root=/dev/ram0 lvm2root=/dev/rootvg/root [ lvm2rescue ]>

of course there may be other options.

=over

=item B<root=/dev/ram0>

This option is required. It tells the kernel that the root filesystem should initially
be set to the ramdisk (/dev/ram0).

=item B<lvm2root=/dev/rootvg/root>

This option is also required. It tells the initrd image which LVM2 device the root filesystem is located on.

=item B<lvm2rescue>

Causes the initrd image to run a shell prior to mounting the root filesystem. This is
helpful in disaster situations where your initrd image is accessable, but there is
a problem with the root filesystem (corrupted image, incorrect device setup, etc.). This
option is (of course) optional.

=back

=head1 OPTIONS

Most of parameters that can be set via command-line options can also be set
via environment variables. Options specified on the command-line always take
precedence.

=over

=item B<-h|--help>

Display short help text and exit. If used, other options are ignored.

=item B<-v|--verbose>

Turn on extra verbosity for debugging, etc.

=item B<-c|--lvmconf> I</path/to/lvm.conf>

Specify an lvm.conf file to include in the image. This is useful if you have
special device filters or other options you wish to use during the initrd
stage. If this option is not
included, then a lvm.conf file is created that contains only the current
device filter from an B<lvm dumpconfig>. This can also be set via the B<$LVMCONF>
environment variable.

=item B<-m|--modules> "I</path/to/module1.ko /path/to/module2.ko ...>"

Specify modules to include and plug in during the initrd phase. This option
takes a quoted, space-separated list of modules. Full pathnames are required.
These modules are loaded into the kernel early in the initrd phase of the boot
process. The current modprobe.conf file is also copied to the initrd image
as well. This can also be specified via the B<$MODULES> environment variable.

=item B<-e|--extra> "I</path/to/file1 /path/to/file2 ...>"

Extra files that should be included in the initrd image. These files will be
copied to the same location in the initrd image that they are in the current
filesystem. Again full pathnames are required. This can also be specified via
the B<$EXTRAFILES> environment variable.

=item B<-r|--raid> "I</dev/md1 /dev/md2...>"

RAID devices to be started prior to scanning for LVM2 volume groups. If this
option is used then then B<mdadm> program must be installed. This can also be
specified via the B<$RAID> environment variable.

=item B<-R|--raidconf> "I</path/to/mdadm.conf>"

Location of a mdadm.conf file to include. If this is not specified, then no
files are included, and any devices specified with the B<-r> option above
must have minor numbers that match their superblock values. This can also be
specified via the B<$RAIDCONF> environment variable.

=item B<-M|--makedev> I<style>

Set MAKEDEV invocation style. The script currently supports 3 styles of
MAKEDEV programs I<debian>, I<redhat> and I<gentoo>. The default is I<debian>.
Set to I<redhat> if using the RedHat/Fedora binary MAKEDEV program. I<gentoo>
has the same binary but in /sbin instead of /dev. Please send a bug report to
maintainer if your distribution doesn't work with any of the current options.

=back

=head1 ENVIRONMENT VARIABLES

Most of the options to this script can be set via environment variables. In
situations where both are set, then the command-line options take precedence.

=over

=item B<$LVMCONF>

Same as -c option.

=item B<$MODULES>

Same as -m option.

=item B<$EXTRAFILES>

Same as -e option.

=item B<$RAID>

Same as -r option.

=item B<$RAIDCONF>

Same as -R option.

=item B<$MAKEDEV>

Same as -M option.

=item B<$BASICDEVICES>

Overrides the default value of $BASICDEVICES in the script (which is "std consoleonly fd"). These values are passed to the B<MAKEDEV> program to create device
entries in the initrd image.

=item B<$BLOCKDEVICES>

Overrides the default value of $BLOCKDEVICES in the script (which is "md hda hdb hdc hdd sda sdb sdc sdd"). This value is passed to the B<MAKEDEV> program to
create device entries in the initrd image.

=item B<$BINFILES>

Overrides the default value of $BINFILES (which is "/lib/lvm-200/lvm /bin/bash /bin/busybox /sbin/pivot_root"). The difference between using this and adding
a file to the $EXTRAFILES list above is that libraries that these depend upon are also included. You can still use $EXTRAFILES to achieve the same effect, but
you must resolve library dependencies youself.

=item B<$INITRDSIZE>

Force a particular size for your initrd image. The default is to total up the size of
the included files and to add 512K as a buffer.

=back

=head1 BUGS

I don't like having to specify a -M option to set the MAKEDEV style, but I know
of no way to reliably detect what type of MAKEDEV is being used. We'll probably
have to add other MAKEDEV styles in the future as this script is tested on
other distributions.

=head1 AUTHORS

The script was originally written by Miguel Cabeca, with significant
improvements by Jeffrey Layton. Comments, bug reports and patches should be
sent to Jeffrey Layton at S<B<jtlayton@poochiereds.net>>.

=head1 SEE ALSO

B<MAKEDEV>(8), B<mdadm>(8), B<busybox>(8), B<lvm.conf>(5)
