xref: /dflybsd-src/contrib/lvm2/dist/scripts/lvm2create_initrd/lvm2create_initrd.pod (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino=head1 NAME
286d7f5d3SJohn Marino
386d7f5d3SJohn Marinolvm2create_initrd - create initrd image for booting to root\-on\-LVM2
486d7f5d3SJohn Marino
586d7f5d3SJohn Marino=head1 SYNOPSIS
686d7f5d3SJohn Marino
786d7f5d3SJohn MarinoB<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 ...>" ]
886d7f5d3SJohn Marino[ B<-R|--raidconf> I</path/to/mdadm.conf> ] [ B<-M|--makedev> I<style> ]
986d7f5d3SJohn Marino
1086d7f5d3SJohn Marino=head1 DESCRIPTION
1186d7f5d3SJohn Marino
1286d7f5d3SJohn Marinolvm2create_initrd creates an initial ramdisk (initrd) image suitable for booting to system that has an LVM2 volume as its root filesystem.
1386d7f5d3SJohn Marino
1486d7f5d3SJohn MarinoTo boot to such a setup, you'll
1586d7f5d3SJohn Marinoeither need a bootloader that understands LVM2 volumes, or you'll need a
1686d7f5d3SJohn Marinofilesystem on a regular volume to act as a boot partition (typically mounted
1786d7f5d3SJohn Marinoon /boot).
1886d7f5d3SJohn Marino
1986d7f5d3SJohn MarinoThe resulting initrd image is fairly full-featured. It can harbor and load
2086d7f5d3SJohn Marinokernel modules, start MD devices, and boot to a shell to perform rescue
2186d7f5d3SJohn Marinooperations.
2286d7f5d3SJohn Marino
2386d7f5d3SJohn Marino=head2 Booting to your initrd Image:
2486d7f5d3SJohn Marino
2586d7f5d3SJohn MarinoThe filesystem image created is an ext2fs filesystem, hence your kernel must have
2686d7f5d3SJohn Marinoext2fs built into it statically in order to boot to the image.
2786d7f5d3SJohn Marino
2886d7f5d3SJohn MarinoOnce you create your initrd image, you must pass the correct options to the kernel when
2986d7f5d3SJohn Marinoyou boot using it. Your kernel command line should look something like this:
3086d7f5d3SJohn Marino
3186d7f5d3SJohn MarinoB<root=/dev/ram0 lvm2root=/dev/rootvg/root [ lvm2rescue ]>
3286d7f5d3SJohn Marino
3386d7f5d3SJohn Marinoof course there may be other options.
3486d7f5d3SJohn Marino
3586d7f5d3SJohn Marino=over
3686d7f5d3SJohn Marino
3786d7f5d3SJohn Marino=item B<root=/dev/ram0>
3886d7f5d3SJohn Marino
3986d7f5d3SJohn MarinoThis option is required. It tells the kernel that the root filesystem should initially
4086d7f5d3SJohn Marinobe set to the ramdisk (/dev/ram0).
4186d7f5d3SJohn Marino
4286d7f5d3SJohn Marino=item B<lvm2root=/dev/rootvg/root>
4386d7f5d3SJohn Marino
4486d7f5d3SJohn MarinoThis option is also required. It tells the initrd image which LVM2 device the root filesystem is located on.
4586d7f5d3SJohn Marino
4686d7f5d3SJohn Marino=item B<lvm2rescue>
4786d7f5d3SJohn Marino
4886d7f5d3SJohn MarinoCauses the initrd image to run a shell prior to mounting the root filesystem. This is
4986d7f5d3SJohn Marinohelpful in disaster situations where your initrd image is accessable, but there is
5086d7f5d3SJohn Marinoa problem with the root filesystem (corrupted image, incorrect device setup, etc.). This
5186d7f5d3SJohn Marinooption is (of course) optional.
5286d7f5d3SJohn Marino
5386d7f5d3SJohn Marino=back
5486d7f5d3SJohn Marino
5586d7f5d3SJohn Marino=head1 OPTIONS
5686d7f5d3SJohn Marino
5786d7f5d3SJohn MarinoMost of parameters that can be set via command-line options can also be set
5886d7f5d3SJohn Marinovia environment variables. Options specified on the command-line always take
5986d7f5d3SJohn Marinoprecedence.
6086d7f5d3SJohn Marino
6186d7f5d3SJohn Marino=over
6286d7f5d3SJohn Marino
6386d7f5d3SJohn Marino=item B<-h|--help>
6486d7f5d3SJohn Marino
6586d7f5d3SJohn MarinoDisplay short help text and exit. If used, other options are ignored.
6686d7f5d3SJohn Marino
6786d7f5d3SJohn Marino=item B<-v|--verbose>
6886d7f5d3SJohn Marino
6986d7f5d3SJohn MarinoTurn on extra verbosity for debugging, etc.
7086d7f5d3SJohn Marino
7186d7f5d3SJohn Marino=item B<-c|--lvmconf> I</path/to/lvm.conf>
7286d7f5d3SJohn Marino
7386d7f5d3SJohn MarinoSpecify an lvm.conf file to include in the image. This is useful if you have
7486d7f5d3SJohn Marinospecial device filters or other options you wish to use during the initrd
7586d7f5d3SJohn Marinostage. If this option is not
7686d7f5d3SJohn Marinoincluded, then a lvm.conf file is created that contains only the current
7786d7f5d3SJohn Marinodevice filter from an B<lvm dumpconfig>. This can also be set via the B<$LVMCONF>
7886d7f5d3SJohn Marinoenvironment variable.
7986d7f5d3SJohn Marino
8086d7f5d3SJohn Marino=item B<-m|--modules> "I</path/to/module1.ko /path/to/module2.ko ...>"
8186d7f5d3SJohn Marino
8286d7f5d3SJohn MarinoSpecify modules to include and plug in during the initrd phase. This option
8386d7f5d3SJohn Marinotakes a quoted, space-separated list of modules. Full pathnames are required.
8486d7f5d3SJohn MarinoThese modules are loaded into the kernel early in the initrd phase of the boot
8586d7f5d3SJohn Marinoprocess. The current modprobe.conf file is also copied to the initrd image
8686d7f5d3SJohn Marinoas well. This can also be specified via the B<$MODULES> environment variable.
8786d7f5d3SJohn Marino
8886d7f5d3SJohn Marino=item B<-e|--extra> "I</path/to/file1 /path/to/file2 ...>"
8986d7f5d3SJohn Marino
9086d7f5d3SJohn MarinoExtra files that should be included in the initrd image. These files will be
9186d7f5d3SJohn Marinocopied to the same location in the initrd image that they are in the current
9286d7f5d3SJohn Marinofilesystem. Again full pathnames are required. This can also be specified via
9386d7f5d3SJohn Marinothe B<$EXTRAFILES> environment variable.
9486d7f5d3SJohn Marino
9586d7f5d3SJohn Marino=item B<-r|--raid> "I</dev/md1 /dev/md2...>"
9686d7f5d3SJohn Marino
9786d7f5d3SJohn MarinoRAID devices to be started prior to scanning for LVM2 volume groups. If this
9886d7f5d3SJohn Marinooption is used then then B<mdadm> program must be installed. This can also be
9986d7f5d3SJohn Marinospecified via the B<$RAID> environment variable.
10086d7f5d3SJohn Marino
10186d7f5d3SJohn Marino=item B<-R|--raidconf> "I</path/to/mdadm.conf>"
10286d7f5d3SJohn Marino
10386d7f5d3SJohn MarinoLocation of a mdadm.conf file to include. If this is not specified, then no
10486d7f5d3SJohn Marinofiles are included, and any devices specified with the B<-r> option above
10586d7f5d3SJohn Marinomust have minor numbers that match their superblock values. This can also be
10686d7f5d3SJohn Marinospecified via the B<$RAIDCONF> environment variable.
10786d7f5d3SJohn Marino
10886d7f5d3SJohn Marino=item B<-M|--makedev> I<style>
10986d7f5d3SJohn Marino
11086d7f5d3SJohn MarinoSet MAKEDEV invocation style. The script currently supports 2 styles of
11186d7f5d3SJohn MarinoMAKEDEV programs I<debian> and I<redhat>. The default is I<debian>. Set
11286d7f5d3SJohn Marinoto I<redhat> if using the RedHat/Fedora binary MAKEDEV program. Please send
11386d7f5d3SJohn Marinoa bug report to maintainer if your distrib doesn't work with any of the
11486d7f5d3SJohn Marinocurrent options.
11586d7f5d3SJohn Marino
11686d7f5d3SJohn Marino=back
11786d7f5d3SJohn Marino
11886d7f5d3SJohn Marino=head1 ENVIRONMENT VARIABLES
11986d7f5d3SJohn Marino
12086d7f5d3SJohn MarinoMost of the options to this script can be set via environment variables. In
12186d7f5d3SJohn Marinosituations where both are set, then the command-line options take precedence.
12286d7f5d3SJohn Marino
12386d7f5d3SJohn Marino=over
12486d7f5d3SJohn Marino
12586d7f5d3SJohn Marino=item B<$LVMCONF>
12686d7f5d3SJohn Marino
12786d7f5d3SJohn MarinoSame as -c option.
12886d7f5d3SJohn Marino
12986d7f5d3SJohn Marino=item B<$MODULES>
13086d7f5d3SJohn Marino
13186d7f5d3SJohn MarinoSame as -m option.
13286d7f5d3SJohn Marino
13386d7f5d3SJohn Marino=item B<$EXTRAFILES>
13486d7f5d3SJohn Marino
13586d7f5d3SJohn MarinoSame as -e option.
13686d7f5d3SJohn Marino
13786d7f5d3SJohn Marino=item B<$RAID>
13886d7f5d3SJohn Marino
13986d7f5d3SJohn MarinoSame as -r option.
14086d7f5d3SJohn Marino
14186d7f5d3SJohn Marino=item B<$RAIDCONF>
14286d7f5d3SJohn Marino
14386d7f5d3SJohn MarinoSame as -R option.
14486d7f5d3SJohn Marino
14586d7f5d3SJohn Marino=item B<$MAKEDEV>
14686d7f5d3SJohn Marino
14786d7f5d3SJohn MarinoSame as -M option.
14886d7f5d3SJohn Marino
14986d7f5d3SJohn Marino=item B<$BASICDEVICES>
15086d7f5d3SJohn Marino
15186d7f5d3SJohn MarinoOverrides 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
15286d7f5d3SJohn Marinoentries in the initrd image.
15386d7f5d3SJohn Marino
15486d7f5d3SJohn Marino=item B<$BLOCKDEVICES>
15586d7f5d3SJohn Marino
15686d7f5d3SJohn MarinoOverrides 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
15786d7f5d3SJohn Marinocreate device entries in the initrd image.
15886d7f5d3SJohn Marino
15986d7f5d3SJohn Marino=item B<$BINFILES>
16086d7f5d3SJohn Marino
16186d7f5d3SJohn MarinoOverrides 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
16286d7f5d3SJohn Marinoa 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
16386d7f5d3SJohn Marinoyou must resolve library dependencies youself.
16486d7f5d3SJohn Marino
16586d7f5d3SJohn Marino=item B<$INITRDSIZE>
16686d7f5d3SJohn Marino
16786d7f5d3SJohn MarinoForce a particular size for your initrd image. The default is to total up the size of
16886d7f5d3SJohn Marinothe included files and to add 512K as a buffer.
16986d7f5d3SJohn Marino
17086d7f5d3SJohn Marino=back
17186d7f5d3SJohn Marino
17286d7f5d3SJohn Marino=head1 BUGS
17386d7f5d3SJohn Marino
17486d7f5d3SJohn MarinoI don't like having to specify a -M option to set the MAKEDEV style, but I know
17586d7f5d3SJohn Marinoof no way to reliably detect what type of MAKEDEV is being used. We'll probably
17686d7f5d3SJohn Marinohave to add other MAKEDEV styles in the future as this script is tested on
17786d7f5d3SJohn Marinoother distributions.
17886d7f5d3SJohn Marino
17986d7f5d3SJohn Marino=head1 AUTHORS
18086d7f5d3SJohn Marino
18186d7f5d3SJohn MarinoThe script was originally written by Miguel Cabeca, with significant
18286d7f5d3SJohn Marinoimprovements by Jeffrey Layton. Comments, bug reports and patches should be
18386d7f5d3SJohn Marinosent to Jeffrey Layton at S<B<jtlayton@poochiereds.net>>.
18486d7f5d3SJohn Marino
18586d7f5d3SJohn Marino=head1 SEE ALSO
18686d7f5d3SJohn Marino
18786d7f5d3SJohn MarinoB<MAKEDEV>(8), B<mdadm>(8), B<busybox>(8), B<lvm.conf>(5)
188