lvm2create_initrd(8)

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

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

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.

  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:

root=/dev/ram0 lvm2root=/dev/rootvg/root [ lvm2rescue ]

of course there may be other options.

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

lvm2root=/dev/rootvg/root
    This option is also required. It tells the initrd image which LVM2 device the root filesystem is located on.

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.

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.

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

-v|--verbose
    Turn on extra verbosity for debugging, etc.

-c|--lvmconf /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 lvm dumpconfig. This can also be set via the $LVMCONF environment variable.

-m|--modules "/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 $MODULES environment variable.

-e|--extra "/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 $EXTRAFILES environment variable.

-r|--raid "/dev/md1 /dev/md2..."
    RAID devices to be started prior to scanning for LVM2 volume groups. If this option is used then then mdadm program must be installed. This can also be specified via the $RAID environment variable.

-R|--raidconf "/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 -r option above must have minor numbers that match their superblock values. This can also be specified via the $RAIDCONF environment variable.

-M|--makedev style
    Set MAKEDEV invocation style. The script currently supports 3 styles of MAKEDEV programs debian, redhat and gentoo. The default is debian. Set to redhat if using the RedHat/Fedora binary MAKEDEV program. 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.

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.

$LVMCONF
    Same as -c option.

$MODULES
    Same as -m option.

$EXTRAFILES
    Same as -e option.

$RAID
    Same as -r option.

$RAIDCONF
    Same as -R option.

$MAKEDEV
    Same as -M option.

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

$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 MAKEDEV program to create device entries in the initrd image.

$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.

$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.

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.

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 jtlayton@poochiereds.net.

SEE ALSO
MAKEDEV(8), mdadm(8), busybox(8), lvm.conf(5)