summaryrefslogtreecommitdiff
path: root/scripts/lvm2create_initrd/lvm2create_initrd.pod
blob: 577930f80109e77abc0671971dfb3552bcb029f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
=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 2 styles of
MAKEDEV programs I<debian> and I<redhat>. The default is I<debian>. Set
to I<redhat> if using the RedHat/Fedora binary MAKEDEV program. Please send
a bug report to maintainer if your distrib 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)