Go to file
Neil Brown 353632d927 Support restarting of a reshape on --assemble
Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-20 03:17:31 +00:00
misc mdadm-1.8.0 2004-11-01 04:49:34 +00:00
tests Initial reshape support 2006-03-13 05:51:32 +00:00
ANNOUNCE-2.0 Release!! 2005-08-26 06:37:33 +00:00
ANNOUNCE-2.1 Release 2-0 2005-09-12 07:12:07 +00:00
ANNOUNCE-2.2 Release 2.2 2005-12-09 04:55:02 +00:00
ANNOUNCE-2.3 Update ChangeLog and release 2.3 2006-02-02 05:17:24 +00:00
ANNOUNCE-2.3.1 Add ANNOUNCE-2.3.1 2006-02-06 04:11:49 +00:00
Assemble.c Support restarting of a reshape on --assemble 2006-03-20 03:17:31 +00:00
bitmap.c Release some compile fixes. 2006-02-06 04:18:12 +00:00
bitmap.h Create version-4 bitmaps if kernel supports it. 2005-10-11 04:44:44 +00:00
Build.c Support bitmaps with raid10 2005-11-22 03:37:14 +00:00
ChangeLog Release some compile fixes. 2006-02-06 04:18:12 +00:00
config.c Allow /etc/mdadm/mdadm.conf as an alternate to /etc/mdadm.conf 2005-12-09 05:01:22 +00:00
COPYING mdctl-0.6 2002-03-06 23:17:40 +00:00
Create.c Prefer version-1 superblocks for v.large devices. 2006-01-31 00:01:48 +00:00
Detail.c Sort mdstat entries so that composites are well-ordered. 2006-01-31 00:39:50 +00:00
dlink.c mdadm-1.5.0 2004-01-22 02:10:29 +00:00
dlink.h mdadm-0.8 2002-04-04 01:58:32 +00:00
Examine.c Provide error message if --examine does find a valid superblock 2006-01-27 06:25:55 +00:00
Grow.c Support restarting of a reshape on --assemble 2006-03-20 03:17:31 +00:00
INSTALL mdadm-0.8.1 2002-04-05 22:00:28 +00:00
inventory Release some compile fixes. 2006-02-06 04:18:12 +00:00
Kill.c Enable support for v.large raid1. 2006-01-27 06:21:06 +00:00
makedist Release some compile fixes. 2006-02-06 04:18:12 +00:00
Makefile Initial reshape support 2006-03-13 05:51:32 +00:00
Manage.c Fix assembling of array with spares when verion-1 superblock is used. 2005-09-12 05:23:11 +00:00
md_p.h Have --examine report reshape details. 2006-01-27 07:28:34 +00:00
md_u.h Initial bitmap support 2005-06-07 23:16:35 +00:00
md.4 Lots of little manpage updates. 2005-08-25 05:11:29 +00:00
mdadm.8 Release some compile fixes. 2006-02-06 04:18:12 +00:00
mdadm.c Initial reshape support 2006-03-13 05:51:32 +00:00
mdadm.conf-example Fix silly example 2005-06-14 06:33:45 +00:00
mdadm.conf.5 Lots of little manpage updates. 2005-08-25 05:11:29 +00:00
mdadm.h Support restarting of a reshape on --assemble 2006-03-20 03:17:31 +00:00
mdadm.spec Release some compile fixes. 2006-02-06 04:18:12 +00:00
mdassemble.8 Release some compile fixes. 2006-02-06 04:18:12 +00:00
mdassemble.c Release 1.8.1 after some man page updates and other fixes. 2005-06-07 23:16:36 +00:00
mdopen.c Release some compile fixes. 2006-02-06 04:18:12 +00:00
mdstat.c Sort mdstat entries so that composites are well-ordered. 2006-01-31 00:39:50 +00:00
mkinitramfs Guides on how to use mdadm with initramfs 2005-12-05 05:56:42 +00:00
Monitor.c Sort mdstat entries so that composites are well-ordered. 2006-01-31 00:39:50 +00:00
Query.c Support nameing of version-1 arrays. 2005-08-09 05:23:20 +00:00
raid5extend.c mdctl-0.5 2001-08-23 02:33:20 +00:00
ReadMe.c Release some compile fixes. 2006-02-06 04:18:12 +00:00
README.initramfs Guides on how to use mdadm with initramfs 2005-12-05 05:56:42 +00:00
restripe.c Support restarting of a reshape on --assemble 2006-03-20 03:17:31 +00:00
super1.c Support restarting of a reshape on --assemble 2006-03-20 03:17:31 +00:00
super0.c Support restarting of a reshape on --assemble 2006-03-20 03:17:31 +00:00
swap_super.c Getting ready for 2.0 release... 2005-08-26 02:26:37 +00:00
sysfs.c Support restarting of a reshape on --assemble 2006-03-20 03:17:31 +00:00
test Add 'setup' option to 'test' 2005-10-11 04:10:00 +00:00
TODO Assorted fixes... 2006-01-27 01:44:47 +00:00
util.c Initial reshape support 2006-03-13 05:51:32 +00:00

Assembling md arrays at boot time.
---------------------------------
December 2005

These notes apply to 2.6 kernels only and, in some cases,
to 2.6.15 or later.

Md arrays can be assembled at boot time using the 'autodetect' functionality
which is triggered by storing components of an array in partitions of type
'fd' - Linux Raid Autodetect.
They can also be assembled by specifying the component devices in a
kernel parameter such as
  md=0,/dev/sda,/dev/sdb
In this case, /dev/md0 will be assembled (because of the 0) from the listed
devices.

These mechanisms, while useful, do not provide complete functionality
and are unlikely to be extended.  The preferred way to assemble md
arrays at boot time is using 'mdadm' or 'mdassemble' (which is a
trimmed-down mdadm).  To assemble an array which contains the root
filesystem, mdadm needs to be run before that filesystem is mounted,
and so needs to be run from an initial-ram-fs.  It is how this can
work that is the primary focus of this document.

It should be noted up front that only the array containing the root
filesystem should be assembled from the initramfs.  Any other arrays
should be assembled under the control of files on the main filesystem
as this enhanced flexibility and maintainability.

A minimal initramfs for assembling md arrays can be created using 3
files and one directory.  These are:

/bin           Directory
/bin/mdadm     statically linked mdadm binary
/bin/busybox   statically linked busybox binary
/bin/sh        hard link to /bin/busybox
/init          a shell script which call mdadm appropriately.

An example init script is:

==============================================
#!/bin/sh

echo 'Auto-assembling boot md array'
mkdir /proc
mount -t proc proc /proc
if [ -n "$rootuuid" ]
then arg=--uuid=$rootuuid
elif [ -n "$mdminor" ]
then arg=--super-minor=$mdminor
else arg=--super-minor=0
fi
echo "Using $arg"
mdadm -Acpartitions $arg --auto=part /dev/mda
cd /
mount /dev/mda1 /root ||  mount /dev/mda /root
umount /proc
cd /root
exec chroot . /sbin/init < /dev/console > /dev/console 2>&1
=============================================

This could certainly be extended, or merged into a larger init script.
Though tested and in production use, it is not presented here as
"The Right Way" to do it, but as a useful example.
Some key points are:

  /proc needs to be mounted so that /proc/partitions can be accessed
  by mdadm, and so that /proc/filesystems can be accessed by mount.

  The uuid of the array can be passed in as a kernel parameter
  (rootuuid).  As the kernel doesn't use this value, it is made available
  in the environment for /init

  If no uuid is given, we default to md0, (--super-minor=0) which is a
  commonly used to store the root filesystem.  This may not work in
  all situations.

  We assemble the array as a partitionable array (/dev/mda) even if we
  end up using the whole array.  There is no cost in using the partitionable
  interface, and in this context it is simpler.

  We try mounting both /dev/mda1 and /dev/mda as they are the most like
  part of the array to contain the root filesystem.

  The --auto flag is given to mdadm so that it will create /dev/md*
  files automatically.  This is needed as /dev will not contain
  and md files, and udev will not create them (as udev only created device
  files after the device exists, and mdadm need the device file to create
  the device).  Note that the created md files may not exist in /dev
  of the mounted root filesystem.  This needs to be deal with separately
  from mdadm - possibly using udev.

  We do not need to create device files for the components which will
  be assembled into /dev/mda.  mdadm finds the major/minor numbers from
  /proc/partitions and creates a temporary /dev file if one doesn't already
  exist.

The script "mkinitramfs" which is included with the mdadm distribution
can be used to create a minimal initramfs.  It creates a file called
'init.cpio.gz' which can be specified as an 'initrd' to lilo or grub
(or whatever boot loader is being used).




Resume from an md array
-----------------------

If you want to make use of the suspend-to-disk/resume functionality in Linux,
and want to have swap on an md array, you will need to assemble the array
before resume is possible.
However, because the array is active in the resumed image, you do not want
anything written to any drives during the resume process, such as superblock
updates or array resync.

This can be achieved in 2.6.15-rc1 and later kernels using the
'start_readonly' module parameter.
Simply include the command
  echo 1 > /sys/module/md_mod/parameters/start_ro
before assembling the array with 'mdadm'.
You can then echo
  9:0
or whatever is appropriate to /sys/power/resume to trigger the resume.