This is equivalent to raidautorun that some distros provide.
- --help now goes to stdout so you can direct it to a pager.
- Various manpage updates.
- Make "--grow --add" for linear arrays really work.
+ - --auto-detect to trigger in-kernel autodetect.
Changes Prior to 2.6.1 release
- --monitor was producing some meaningless warnings due to a bug.
return 0;
}
+
+int autodetect(void)
+{
+ /* Open any md device, and issue the RAID_AUTORUN ioctl */
+ int rv = 1;
+ int fd = dev_open("9:0", O_RDONLY);
+ if (fd >= 0) {
+ if (ioctl(fd, RAID_AUTORUN, 0) == 0)
+ rv = 0;
+ close(fd);
+ }
+ return rv;
+}
#endif
{"zero-superblock", 0, 0, 'K'}, /* deliberately no a short_option */
{"query", 0, 0, 'Q'},
{"examine-bitmap", 0, 0, 'X'},
+ {"auto-detect", 0, 0, AutoDetect},
/* synonyms */
{"monitor", 0, 0, 'F'},
" --incremental -I : add a single device to an array as appropriate\n"
" --query -Q : Display general information about how a\n"
" device relates to the md driver\n"
+" --auto-detect : Start arrays auto-detected by the kernel\n"
;
/*
"\n"
{ "monitor", MONITOR},
{ "grow", GROW},
{ "incremental", INCREMENTAL},
+ { "auto-detect", AUTODETECT},
};
mapping_t faultylayout[] = {
'''This mode allows operations on independent devices such as examine MD
'''superblocks, erasing old superblocks and stopping active arrays.
+.TP
+.B Auto-detect
+This mode does not act on a specific device or array, but rather it
+requests the Linux Kernel to activate any auto-detected arrays.
.SH OPTIONS
.SH Options for selecting a mode are:
Change the size or shape of an active array.
.TP
-.BE \-I ", " \-\-incremental
+.BR \-I ", " \-\-incremental
Add a single device into an appropriate array, and possibly start the array.
+.TP
+.B \-\-auto-detect
+Request that the kernel starts any auto-detected arrays. This can only
+work if
+.I md
+is compiled into the kernel \(em not if it is a module.
+Arrays can be auto-detected by the kernel if all the components are in
+primary MS-DOS partitions with partition type
+.BR FD .
+In-kernel autodetect is not recommended for new installations. Using
+.I mdadm
+to detect and assemble arrays \(em possibly in an
+.I initrd
+\(em is substantially more flexible and should be preferred.
+
.P
If a device is given before any options, or if the first option is
.BR \-\-add ,
case 'F': newmode = MONITOR;break;
case 'G': newmode = GROW; shortopt = short_bitmap_auto_options; break;
case 'I': newmode = INCREMENTAL; break;
+ case AutoDetect:
+ newmode = AUTODETECT; break;
case '#':
case 'D':
case 'F':
case 'G':
case 'I':
+ case AutoDetect:
continue;
}
if (opt == 1) {
}
rv = Incremental(devlist->devname, verbose-quiet, runstop,
ss, homehost, autof);
+ break;
+ case AUTODETECT:
+ autodetect();
+ break;
}
exit(rv);
}
MONITOR,
GROW,
INCREMENTAL,
+ AUTODETECT,
};
extern char short_options[];
HomeHost,
AutoHomeHost,
Symlinks,
+ AutoDetect,
};
/* structures read from config file */
extern int Manage_reconfig(char *devname, int fd, int layout);
extern int Manage_subdevs(char *devname, int fd,
mddev_dev_t devlist, int verbose);
+extern int autodetect(void);
extern int Grow_Add_device(char *devname, int fd, char *newdev);
extern int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int write_behind, int force);
extern int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
# assume md0, md1, md2 exist in /dev
md0=/dev/md0 md1=/dev/md1 md2=/dev/md2
+mdp0=/dev/md_d0
+mdp1=/dev/md_d1
# We test mdadm on loop-back block devices.
# dir for storing files should be settable by command line maybe
+
+#
+# Test in-kernel autodetect.
+# Create a partitionable array on each of two devices,
+# put a partition on each, create an array, and see if we can
+# use autodetect to restart the array.
+
+mdadm -CR $mdp0 -l0 -f -n1 $dev0
+mdadm -CR $mdp1 -l0 -f -n1 $dev1
+sfdisk $mdp0 >&2 << END
+,,FD
+END
+sfdisk $mdp1 >&2 << END
+,,FD
+END
+mdadm -CR $md0 -l1 -n2 ${mdp0}p1 ${mdp1}p1
+check resync
+check raid1
+check wait
+mdadm -S $md0
+mdadm --auto-detect
+check raid1
+
+mdadm -Ss
+exit 0