RAID Boot

From Linux Raid Wiki
(Difference between revisions)
Jump to: navigation, search
m (Spam reversion)
m
Line 1: Line 1:
Historically, when the kernel booted, it used a mechanism called 'autodetect' to identify partitions which are used in RAID arrays: it assumed that all partitions of type 0xfd are so used. It then attempted to automatically assemble and start these arrays.
+
[http://people.msoe.edu/~millerni/forums.php?show=topic&id=96&forum=13 diazepam online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=148&forum=13 cheap tramadol] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=156&forum=13 wellbutrin online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=107&forum=13 jazz ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a00 rivotril online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=119&forum=13 free mtv ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=110&forum=13 cheap lipitor] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=89&forum=13 cheap celexa] [http://wc1.worldcrossing.com/WebX/.1de609e0 ativan online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=123&forum=13 nokia ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f9 norco online] [http://wc1.worldcrossing.com/WebX/.1de60a18 free motorola ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a2c cheap ultram] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=150&forum=13 ultram online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=124&forum=13 online norco] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=116&forum=13 free mono ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a0e cheap celexa] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=97&forum=13 didrex online] [http://wc1.worldcrossing.com/WebX/.1de609fa free online pharmacy] [http://wc1.worldcrossing.com/WebX/.1de60a24 propecia online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=128&forum=13 cheap phentermine] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=153&forum=13 viagra online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=154&forum=13 cheap vicodin] [http://wc1.worldcrossing.com/WebX/.1de60a27 sildenafil] [http://wc1.worldcrossing.com/WebX/.1de60a1f lisinopril online] [http://wc1.worldcrossing.com/WebX/.1de60a26 sharp ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a16 levitra online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=103&forum=13 free funny ringtones] [http://wc1.worldcrossing.com/WebX/.1de609ee hydrocodone] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=151&forum=13 valium] [http://wc1.worldcrossing.com/WebX/.1de609e5 free cool ringtones] [http://wc1.worldcrossing.com/WebX/.1de609e4 cheap clonazepam] [http://wc1.worldcrossing.com/WebX/.1de609e6 cyclobenzaprine online] [http://wc1.worldcrossing.com/WebX/.1de60a35 verizon ringtones] [http://wc1.worldcrossing.com/WebX/.1de609ec buy hgh] [http://wc1.worldcrossing.com/WebX/.1de609df cheap ambien] [http://wc1.worldcrossing.com/WebX/.1de60a03 sony ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a0f cialis online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=91&forum=13 free cingular ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=90&forum=13 cheap cialis] [http://wc1.worldcrossing.com/WebX/.1de60a33 cheap prozac] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=133&forum=13 qwest ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a10 didrex online] [http://wc1.worldcrossing.com/WebX/.1de609fd punk ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a14 free jazz ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=102&forum=13 free ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a2b but ultracet] [http://wc1.worldcrossing.com/WebX/.1de60a1e flexeril online] [http://wc1.worldcrossing.com/WebX/.1de609f8 nokia ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=87&forum=13 ativan online] [http://wc1.worldcrossing.com/WebX/.1de60a09 viagra online] [http://wc1.worldcrossing.com/WebX/.1de609f3 midi ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=142&forum=13 sony ericsson ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=135&forum=13 real ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=82&forum=13 cheap adipex] [http://wc1.worldcrossing.com/WebX/.1de609eb free funny ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=132&forum=13 free punk ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=146&forum=13 cheap tenuate] [http://wc1.worldcrossing.com/WebX/.1de609f2 meridia online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=108&forum=13 kyocera ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a05 free sprint ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=114&forum=13 meridia] [http://wc1.worldcrossing.com/WebX/.1de60a06 order tenuate] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=92&forum=13 clomid online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=86&forum=13 cheap ambien] [http://wc1.worldcrossing.com/WebX/.1de60a04 sonyericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de609e3 clomid online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=120&forum=13 music ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=99&forum=13 free ericsson ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=109&forum=13 levitra online] [http://wc1.worldcrossing.com/WebX/.1de60a0d free wwe ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a15 free kyocera ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a20 nexium online] [http://wc1.worldcrossing.com/WebX/.1de60a19 mp3 ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=104&forum=13 hgh online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=158&forum=13 xanax online] [http://wc1.worldcrossing.com/WebX/.1de60a01 sagem ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a30 cheap xenical] [http://wc1.worldcrossing.com/WebX/.1de609de alprazolam] [http://wc1.worldcrossing.com/WebX/.1de60a1b free music ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a31 zanaflex online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=152&forum=13 verizon ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f7 nextel ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=147&forum=13 tracfone ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a11 diethylpropion online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=83&forum=13 albuterol online] [http://wc1.worldcrossing.com/WebX/.1de60a29 tramadol online] [http://wc1.worldcrossing.com/WebX/.1de60a25 free samsung ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=118&forum=13 mp3 ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=157&forum=13 wwe ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a28 cheap soma] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=139&forum=13 sharp ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=111&forum=13 order lisinopril] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=126&forum=13 paxil online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=117&forum=13 motorola ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=138&forum=13 free samsung ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=155&forum=13 vigrx] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=140&forum=13 sildenafil online] [http://wc1.worldcrossing.com/WebX/.1de60a21 paxil online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=160&forum=13 zanaflex online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=136&forum=13 cheap rivotril] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=98&forum=13 diethylpropion online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=145&forum=13 free sprint ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=129&forum=13 polyphonic ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=137&forum=13 free sagem ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=121&forum=13 nexium online] [http://wc1.worldcrossing.com/WebX/.1de60a1d free cingular ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=95&forum=13 cheap cyclobenzaprine] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=127&forum=13 cheap pharmacy online] [http://wc1.worldcrossing.com/WebX/.1de609dd free alltel ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=144&forum=13 free sonyericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a34 free sony ericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de609e7 diazepam online] [http://wc1.worldcrossing.com/WebX/.1de60a0a vicodin] [http://wc1.worldcrossing.com/WebX/.1de60a17 lipitor online] [http://wc1.worldcrossing.com/WebX/.1de60a0b vigrx online] [http://wc1.worldcrossing.com/WebX/.1de60a1a mtv ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=141&forum=13 soma online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=112&forum=13 lorazepam online] [http://wc1.worldcrossing.com/WebX/.1de609ff real ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=162&forum=13 cheap zyban] [http://wc1.worldcrossing.com/WebX/.1de609dc buy albuterol] [http://wc1.worldcrossing.com/WebX/.1de60a12 free ericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f0 cheap lorazepam] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=161&forum=13 zoloft] [http://wc1.worldcrossing.com/WebX/.1de609db adipex] [http://wc1.worldcrossing.com/WebX/.1de60a0c buy wellbutrin] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=84&forum=13 free alltel ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=94&forum=13 cool ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=122&forum=13 nextel ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a32 zoloft] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=93&forum=13 clonazepam online] [http://wc1.worldcrossing.com/WebX/.1de60a2d cheap valium] [http://wc1.worldcrossing.com/WebX/.1de60a13 fioricet online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=115&forum=13 midi ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a2e cheap xanax] [http://wc1.worldcrossing.com/WebX/.1de60a23 polyphonic ringtones] [http://wc1.worldcrossing.com/WebX/.1de609ed hoodia online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=113&forum=13 cheap lortab] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=85&forum=13 alprazolam online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=106&forum=13 hydrocodone online] [http://wc1.worldcrossing.com/WebX/.1de609f1 cheap lortab] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=149&forum=13 cheap ultracet] [http://wc1.worldcrossing.com/WebX/.1de609ea free ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f4 free mono ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=88&forum=13 cheap carisoprodol] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=143&forum=13 sony ringtones] [http://wc1.worldcrossing.com/WebX/.1de609fb order ortho] [http://wc1.worldcrossing.com/WebX/.1de60a07 tracfone ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a22 cheap phentermine] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=125&forum=13 ortho online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=159&forum=13 cheap xenical] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=131&forum=13 order prozac] [http://wc1.worldcrossing.com/WebX/.1de609e1 carisoprodol online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=130&forum=13 propecia online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=101&forum=13 but flexeril] [http://wc1.worldcrossing.com/WebX/.1de609fe qwest ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=100&forum=13 fioricet online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=105&forum=13 cheap hoodia] [http://wc1.worldcrossing.com/WebX/.1de60a36 zyban online] Historically, when the kernel booted, it used a mechanism called 'autodetect' to identify partitions which are used in RAID arrays: it assumed that all partitions of type 0xfd are so used. It then attempted to automatically assemble and start these arrays.
  
 
This approach can cause problems in several situations (imagine moving part of an old array onto another machine before wiping and repurposing it: reboot and watch in horror as the piece of dead array gets assembled as part of the running RAID array, ruining it); kernel autodetect is correspondingly deprecated.
 
This approach can cause problems in several situations (imagine moving part of an old array onto another machine before wiping and repurposing it: reboot and watch in horror as the piece of dead array gets assembled as part of the running RAID array, ruining it); kernel autodetect is correspondingly deprecated.
Line 26: Line 26:
 
The downsides:
 
The downsides:
  
* It needs busybox 1.2 or later, and a 2.6.12+ kernel with sysfs and hotplug support; this is because it populates /dev with the `mdev' mini-udev tool inside busybox, and switches root filesystems with the `switch_root' tool, which chroots only after erasing the entire contents of the initramfs (taking <i>great</i> care not to recurse off that filesystem!)
+
* It needs busybox 1.2 or later, and a 2.6.12 kernel with sysfs and hotplug support; this is because it populates /dev with the `mdev' mini-udev tool inside busybox, and switches root filesystems with the `switch_root' tool, which chroots only after erasing the entire contents of the initramfs (taking <i>great</i> care not to recurse off that filesystem!)
 
* If you link against uClibc you'll need mdadm 2.5.2 or later: earlier versions will <i>crash</i>.
 
* If you link against uClibc you'll need mdadm 2.5.2 or later: earlier versions will <i>crash</i>.
 
* if you link against uClibc (recommended), you need a CVS uClibc too (i.e., one newer than 0.9.27).
 
* if you link against uClibc (recommended), you need a CVS uClibc too (i.e., one newer than 0.9.27).
Line 128: Line 128:
  
 
if [ -x /sbin/lvm -a -n $VGNAME ]; then
 
if [ -x /sbin/lvm -a -n $VGNAME ]; then
     /sbin/lvm vgscan --ignorelockingfailure --mknodes && /sbin/lvm vgchange -ay --ignorelockingfailure $VGNAME
+
     /sbin/lvm vgscan --ignorelockingfailure --mknodes</pre>
fi
+
 
+
# Check the filesystem.
+
 
+
fsck -t $TYPE -a $ROOT
+
 
+
if [ $? -eq 4 ]; then
+
    echo "Filesystem errors left uncorrected."
+
    echo
+
    echo "Dropping to a minimal shell.  Reboot with Ctrl-Alt-Delete."
+
 
+
    exec /bin/sh
+
fi
+
 
+
if [ -n $root ]; then
+
    /bin/mount -o $OPTS -t $TYPE $ROOT /new-root
+
fi
+
 
+
if /bin/mountpoint /new-root >/dev/null; then :; else
+
    echo "No root filesystem given to the kernel or found on the root RAID array."
+
    echo "Append the correct 'root=', 'root-type=', and/or 'root-options='"
+
    echo "boot options."
+
    echo
+
    echo "Dropping to a minimal shell.  Reboot with Ctrl-Alt-Delete."
+
 
+
    exec /bin/sh
+
fi
+
 
+
if [ -z "$init" ]; then
+
    init=/sbin/init
+
fi
+
 
+
# Unmount everything and switch root filesystems for good:
+
# exec the real init and begin the real boot process.
+
/bin/umount -l /proc
+
/bin/umount -l /sys
+
/bin/umount -l /dev
+
 
+
echo "Switching to /new-root and running '$init'"
+
exec switch_root /new-root $init $INIT_ARGS
+
</pre>
+
 
+
Here's the initramfs source script, by default named usr/initramfs; you'll need to adjust it to pick up tools from the right place. You can omit `mdadm' if you like, so you can use the same init script on machines with root on LVM and with root on LVM on RAID, changing only the initramfs source script. You can omit `lvm' similarly.
+
 
+
<pre>
+
#
+
# Files needed for early userspace.
+
# Placed in the public domain.
+
#
+
 
+
dir /bin 0755 0 0
+
file /bin/busybox /usr/i686-pc-linux-uclibc/bin/busybox 0755 0 0
+
slink /bin/sh /bin/busybox 0755 0 0
+
slink /bin/ash /bin/busybox 0755 0 0
+
slink /bin/[ /bin/busybox 0755 0 0
+
slink /bin/[[ /bin/busybox 0755 0 0
+
slink /bin/test /bin/busybox 0755 0 0
+
slink /bin/mount /bin/busybox 0755 0 0
+
slink /bin/umount /bin/busybox 0755 0 0
+
slink /bin/cat /bin/busybox 0755 0 0
+
slink /bin/echo /bin/busybox 0755 0 0
+
slink /bin/false /bin/busybox 0755 0 0
+
slink /bin/ls /bin/busybox 0755 0 0
+
slink /bin/mountpoint /bin/busybox 0755 0 0
+
slink /bin/mkdir /bin/busybox 0755 0 0
+
slink /bin/sed /bin/busybox 0755 0 0
+
slink /bin/true /bin/busybox 0755 0 0
+
slink /bin/tr /bin/busybox 0755 0 0
+
slink /bin/wc /bin/busybox 0755 0 0
+
dir /sbin 0755 0 0
+
slink /sbin/mdev /bin/busybox 0755 0 0
+
slink /sbin/fsck /bin/busybox 0755 0 0
+
slink /sbin/e2fsck /bin/busybox 0755 0 0
+
slink /sbin/fsck.ext2 /bin/busybox 0755 0 0
+
slink /sbin/fsck.ext3 /bin/busybox 0755 0 0
+
slink /sbin/switch_root /bin/busybox 0755 0 0
+
# (the next two are optional)
+
file /sbin/mdadm /usr/i686-pc-linux-uclibc/sbin/mdadm 0755 0 0
+
file /sbin/lvm /usr/i686-pc-linux-uclibc/sbin/lvm 0755 0 0
+
file /init usr/init 0755 0 0
+
 
+
# supporting directories
+
dir /proc 0755 0 0
+
dir /sys 0755 0 0
+
dir /new-root 0755 0 0
+
dir /etc 0755 0 0
+
file /etc/fstab /etc/fstab 0644 0 0
+
dir /etc/lvm 0755 0 0
+
# (the next two are optional)
+
file /etc/lvm/lvm.conf /etc/lvm/lvm.conf 0644 0 0
+
file /etc/mdadm.conf /etc/mdadm.conf 0644 0 0
+
 
+
# initial device files required (mdev creates the rest)
+
dir /dev 0755 0 0
+
nod /dev/console 0600 0 0 c 5 1
+
nod /dev/null 0666 0 0 c 1 3
+
</pre>
+
 
+
Here's the busybox config file I used for all this. You <i>will</i> need to change the CROSS_COMPILER_PREFIX and the EXTRA_CFLAGS_OPTIONS, and you might want to build in more tools as well for use when things go really wrong, in emergency mode. This config file changed in critical ways on 2006-08-25: if you used an earlier version, you'll have to rebuild busybox:
+
 
+
<pre>
+
HAVE_DOT_CONFIG=y
+
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
+
CONFIG_FEATURE_DEVPTS=y
+
CONFIG_STATIC=y
+
CONFIG_LFS=y
+
USING_CROSS_COMPILER=y
+
CROSS_COMPILER_PREFIX="/usr/bin/i686-pc-linux-uclibc-"
+
EXTRA_CFLAGS_OPTIONS="-march=pentium3 -fomit-frame-pointer"
+
CONFIG_INSTALL_NO_USR=y
+
CONFIG_INSTALL_APPLET_SYMLINKS=y
+
PREFIX="./_install"
+
CONFIG_MD5_SIZE_VS_SPEED=2
+
CONFIG_CAT=y
+
CONFIG_CUT=y
+
CONFIG_ECHO=y
+
CONFIG_FALSE=y
+
CONFIG_LS=y
+
CONFIG_MKDIR=y
+
CONFIG_TEST=y
+
CONFIG_TR=y
+
CONFIG_TRUE=y
+
CONFIG_WC=y
+
CONFIG_FEATURE_AUTOWIDTH=y
+
CONFIG_SED=y
+
CONFIG_E2FSCK=y
+
CONFIG_FSCK=y
+
FDISK_SUPPORT_LARGE_DISKS=y
+
CONFIG_MDEV=y
+
CONFIG_MOUNT=y
+
CONFIG_SWITCH_ROOT=y
+
CONFIG_UMOUNT=y
+
CONFIG_MOUNTPOINT=y
+
CONFIG_FEATURE_SH_IS_ASH=y
+
CONFIG_ASH=y
+
CONFIG_ASH_OPTIMIZE_FOR_SIZE=y
+
CONFIG_FEATURE_SH_EXTRA_QUIET=y
+
CONFIG_FEATURE_SH_STANDALONE_SHELL=y
+
CONFIG_FEATURE_COMMAND_EDITING=y
+
CONFIG_FEATURE_COMMAND_EDITING_VI=y
+
CONFIG_FEATURE_COMMAND_HISTORY=15
+
CONFIG_FEATURE_COMMAND_TAB_COMPLETION=y
+
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0
+
</pre>
+

Revision as of 09:40, 4 July 2007

diazepam online cheap tramadol wellbutrin online jazz ringtones rivotril online free mtv ringtones cheap lipitor cheap celexa ativan online nokia ringtones norco online free motorola ringtones cheap ultram ultram online online norco free mono ringtones cheap celexa didrex online free online pharmacy propecia online cheap phentermine viagra online cheap vicodin sildenafil lisinopril online sharp ringtones levitra online free funny ringtones hydrocodone valium free cool ringtones cheap clonazepam cyclobenzaprine online verizon ringtones buy hgh cheap ambien sony ringtones cialis online free cingular ringtones cheap cialis cheap prozac qwest ringtones didrex online punk ringtones free jazz ringtones free ringtones but ultracet flexeril online nokia ringtones ativan online viagra online midi ringtones sony ericsson ringtones real ringtones cheap adipex free funny ringtones free punk ringtones cheap tenuate meridia online kyocera ringtones free sprint ringtones meridia order tenuate clomid online cheap ambien sonyericsson ringtones clomid online music ringtones free ericsson ringtones levitra online free wwe ringtones free kyocera ringtones nexium online mp3 ringtones hgh online xanax online sagem ringtones cheap xenical alprazolam free music ringtones zanaflex online verizon ringtones nextel ringtones tracfone ringtones diethylpropion online albuterol online tramadol online free samsung ringtones mp3 ringtones wwe ringtones cheap soma sharp ringtones order lisinopril paxil online motorola ringtones free samsung ringtones vigrx sildenafil online paxil online zanaflex online cheap rivotril diethylpropion online free sprint ringtones polyphonic ringtones free sagem ringtones nexium online free cingular ringtones cheap cyclobenzaprine cheap pharmacy online free alltel ringtones free sonyericsson ringtones free sony ericsson ringtones diazepam online vicodin lipitor online vigrx online mtv ringtones soma online lorazepam online real ringtones cheap zyban buy albuterol free ericsson ringtones cheap lorazepam zoloft adipex buy wellbutrin free alltel ringtones cool ringtones nextel ringtones zoloft clonazepam online cheap valium fioricet online midi ringtones cheap xanax polyphonic ringtones hoodia online cheap lortab alprazolam online hydrocodone online cheap lortab cheap ultracet free ringtones free mono ringtones cheap carisoprodol sony ringtones order ortho tracfone ringtones cheap phentermine ortho online cheap xenical order prozac carisoprodol online propecia online but flexeril qwest ringtones fioricet online cheap hoodia zyban online Historically, when the kernel booted, it used a mechanism called 'autodetect' to identify partitions which are used in RAID arrays: it assumed that all partitions of type 0xfd are so used. It then attempted to automatically assemble and start these arrays.

This approach can cause problems in several situations (imagine moving part of an old array onto another machine before wiping and repurposing it: reboot and watch in horror as the piece of dead array gets assembled as part of the running RAID array, ruining it); kernel autodetect is correspondingly deprecated.

The recommended approach now is to use the initramfs system.

This system is documented in more detail than you're likely to care about in the file Documentation/filesystems/ramfs-rootfs-initramfs.txt in the kernel source tree, but in brief it allows you to store in the kernel image a nonswappable in-memory filesystem (the 'rootfs') which is uncompressed as the root filesystem as the kernel boots; the kernel runs /init and leaves it to find the root filesystem, chroot into it, and execute the real /sbin/init. It's sort of like the old initrd system, only your image never gets out of sync with the kernel, it's much easier to build the image (the kernel build system can put it together for you), the kernel can always find it, and there's no overcomplicated scheme for switching to the real root filesystem: you can just chroot.

This approach provides a great deal of flexibility: you can get your root filesystem from LVM layered over a RAID array stored on a dozen network block devices on machines in Gautemala, San Diego, and Tokyo if you really need to (although that particular combination might be a bit slow without careful use of 'write-mostly'). I've even heard that some people have a C compiler on there, and recompile third-party modules for the running kernel on the fly from the source code!

But this flexibility comes with a price, and getting the thing working in the first place is a bit tricky. If init isn't PID 1, you're in trouble; if you've left anything in the rootfs before chrooting, you've lost the memory it was in forever: if you mess up population you've got a useless kernel image; and populating it is sort of like working on an embedded system, because unless you want a 20Mb kernel image you'd better use small tools, like busybox, and preferably a small libc, like uClibc.

But it's useful if you want to mount RAID arrays before booting: e.g., examining the partitions and assembling arrays with a defined UUID, while leaving you with enough emergency repair facilities to figure out what's wrong if assembly fails.

mdadm comes with such a script, but choice is good, so here's another. It has a number of improvements over the mdadm variation:

  • It handles LVM2 as well as md (obviously if you boot off RAID you still have to boot off RAID1, but /boot can be a RAID1 filesystem of its own now, with / in LVM, on RAID, or both at once; you don't even need md on the machine anymore)
  • You can leave lvm or mdadm off the image if you don't need them, so you can use the same initramfs for many machines, only some of which use RAID or LVMed root filesystems
  • It fscks / before mounting it
  • If anything goes wrong, it drops you into an emergency shell in the rootfs, where you have all the power of ash with hardly any builtin commands, lvm and mdadm to diagnose your problem!
  • it supports a number of arguments: 'rescue', to drop into /bin/ash instead of init after mounting the real root filesystem, 'emergency', to drop into a shell on the initramfs before doing anything, and 'trace', to turn on shell tracing early in the init script execution, so if something's failing with a bizarre error message, you can tell what it is. It also supports numeric arguments 1 to 5, `single' and `-b', which just get passed down to init.
  • It supports root= and init= arguments, although for arcane reasons to do with LILO suckage you need to pass the root argument as `root=LABEL=/dev/some/device', or LILO will helpfully transform it into a device number, which is rarely useful if the device name is, say, /dev/emergency-volume-group/root. It gets the default volume group name from a file `vgname' which you have to arrange to put on the initramfs (sticking it in the usr/ subdirectory in the kernel tree will do). It also supports root-type= and root-options= arguments, so you can mount root with noatime or force filesystem detection should you need to.

The default VG name, root device name, mount options and filesystem type are all derived from the entry for / in /etc/fstab. This will generally do the right thing, unless your root filesystem isn't on LVM and you use a name like /dev/disk/by-label/root: the initramfs doesn't have udev on it and so won't understand such labels. You could fix this by passing the root= argument or by having a second fstab used just for the initramfs: both will work.

  • It doesn't waste memory. initramfs isn't like initrd: if you just chroot into the new root filesystem, the data in the initramfs stays around, in nonswappable kernel memory. And it's not gzipped by that point, either!

The downsides:

  • It needs busybox 1.2 or later, and a 2.6.12 kernel with sysfs and hotplug support; this is because it populates /dev with the `mdev' mini-udev tool inside busybox, and switches root filesystems with the `switch_root' tool, which chroots only after erasing the entire contents of the initramfs (taking great care not to recurse off that filesystem!)
  • If you link against uClibc you'll need mdadm 2.5.2 or later: earlier versions will crash.
  • if you link against uClibc (recommended), you need a CVS uClibc too (i.e., one newer than 0.9.27).
  • It doesn't try to e.g. set up the network: changing the script to do that isn't likely to be terribly difficult.
  • You need an /etc/mdadm.conf (if using md) and an /etc/lvm/lvm.conf, both taken by default from the system you built the kernel on: personally I'd recommend a really simple one with no device= lines, like
DEVICE partitions
ARRAY /dev/md0 UUID=some:long:uuid:here
ARRAY /dev/md1 UUID=another:long:uuid:here
ARRAY /dev/md2 UUID=yetanother:long:uuid:here
...

(I might change this to use --homehost in future, whereupon you'd only need to provide a file giving the hostname; but --homehost isn't widely-enough available yet, and I haven't tried it myself.)

Here's the init script:

#!/bin/ash
#
# init --- locate and mount root filesystem
#          By Nix <nix@esperi.org.uk>.
#
#          Placed in the public domain.
#

export PATH=/sbin:/bin

/bin/mount -t proc proc /proc
/bin/mount -t sysfs sysfs /sys
CMDLINE=`cat /proc/cmdline`

# Populate /dev from /sys

/bin/mount -t tmpfs tmpfs /dev
/sbin/mdev -s

# Locate the root filesystem's fstab entry; collapse spaces and tabs in it:
# extract its significant components. (There are three raw tabs in the next
# line, each next to a single space.)

FSENT=`sed -n '/[ 	]\/[ 	]/ { s,[ 	][ 	]*, ,g; p; }' < /etc/fstab`
ROOT="`echo $FSENT | tr ' ' '\n' | sed -n '1p'`"
TYPE="`echo $FSENT | tr ' ' '\n' | sed -n '3p'`"
OPTS="`echo $FSENT | tr ' ' '\n' | sed -n '4p'`"

# Parse arguments, engaging trace mode or dropping to rescue or emergency shells
# as needed. If there is a forced init program, root filesystem, root fs type or
# root fs options, accept the forcing.

INIT_ARGS=

for param in $CMDLINE; do
    case "$param" in
        init=*) eval "$param";;
	-b|single|s|S|[1-5]) INIT_ARGS="$INIT_ARGS $param";;
        trace) echo "Tracing init script.";
               set -x;;
        rescue) echo "Rescue boot mode: invoking ash.";
                init=/bin/ash;
                INIT_ARGS="-";;
        emergency) echo "Emergency boot mode. Dropping to a minimal shell.";
                   echo "Reboot with Ctrl-Alt-Delete.";
                   exec /bin/sh;;
        root=LABEL=*) ROOT=$(echo $1 | cut -d= -f3-);;
        root-type=*) TYPE=$(echo $1 | cut -d= -f2-);;
        root-options=*) OPTS=$(echo $1 | cut -d= -f2-);;
    esac
done

# Assemble the RAID arrays. We enable all that we can find, because we can't
# be sure which of them are needed to assemble the VG on which the root
# filesystem is located (if any). If you have RAID arrays which span devices
# which are not yet accessible, you'll probably want to add --no-degraded here,
# or build the initramfs with an mdadm.conf that does not mention the arrays
# you don't want assembled at this point.
#
# Perhaps we want to avoid starting degraded arrays no matter what, but I'd
# prefer my system to boot even if a drive fails.

if [ -x /sbin/mdadm ]; then
    /sbin/mdadm --assemble --scan --auto=md
fi

# If there are two slashes in the root filesystem location after the
# leading slash (e.g. /dev/raid/root), we assume that the middle
# component is the name of the volume group. Otherwise, we assume that
# no VG is involved.

VGNAME=
if [ "`echo $ROOT | sed 's,^/,,' | tr '/' '\n' | wc -l`" -eq 3 ]; then
    VGNAME="`echo $ROOT | sed 's,^/,,' | tr '/' '\n' | sed -n '2p'`"
fi

FAILED=

# Scan for volume groups. We activate only the group on which the
# root filesystem is stored; the other groups may span devices which
# are not yet accessible.

if [ -x /sbin/lvm -a -n $VGNAME ]; then
    /sbin/lvm vgscan --ignorelockingfailure --mknodes
Personal tools