From 9a9dab3670110c2db7fe6f716977b72adedbf855 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 8 Mar 2002 00:03:52 +0000 Subject: mdadm-0.7 --- Assemble.c | 4 +- Build.c | 4 +- ChangeLog | 10 +- Create.c | 4 +- Detail.c | 4 +- Examine.c | 6 +- Kill.c | 83 +++++++++ Makefile | 27 +-- Manage.c | 4 +- Monitor.c | 4 +- ReadMe.c | 53 +++--- TAGS | 289 +++++++++++++++++++------------ TODO | 8 +- config.c | 6 +- makedist | 6 +- mdadm.8 | 575 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mdadm.c | 545 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mdadm.h | 152 ++++++++++++++++ mdadm.man | 476 ++++++++++++++++++++++++++++++++++++++++++++++++++ mdctl.8 | 575 ------------------------------------------------------------- mdctl.c | 540 --------------------------------------------------------- mdctl.h | 150 ---------------- mdctl.man | 476 -------------------------------------------------- mdctl.spec | 16 +- util.c | 4 +- 25 files changed, 2093 insertions(+), 1928 deletions(-) create mode 100644 Kill.c create mode 100644 mdadm.8 create mode 100644 mdadm.c create mode 100644 mdadm.h create mode 100644 mdadm.man delete mode 100644 mdctl.8 delete mode 100644 mdctl.c delete mode 100644 mdctl.h delete mode 100644 mdctl.man diff --git a/Assemble.c b/Assemble.c index 1a4cb7e..53c09d6 100644 --- a/Assemble.c +++ b/Assemble.c @@ -1,5 +1,5 @@ /* - * mdctl - manage Linux "md" devices aka RAID arrays. + * mdadm - manage Linux "md" devices aka RAID arrays. * * Copyright (C) 2001-2002 Neil Brown * @@ -27,7 +27,7 @@ * Australia */ -#include "mdctl.h" +#include "mdadm.h" #include "md_u.h" #include "md_p.h" diff --git a/Build.c b/Build.c index 51f2df0..42aab1f 100644 --- a/Build.c +++ b/Build.c @@ -1,5 +1,5 @@ /* - * mdctl - manage Linux "md" devices aka RAID arrays. + * mdadm - manage Linux "md" devices aka RAID arrays. * * Copyright (C) 2001-2002 Neil Brown * @@ -27,7 +27,7 @@ * Australia */ -#include "mdctl.h" +#include "mdadm.h" #define REGISTER_DEV _IO (MD_MAJOR, 1) #define START_MD _IO (MD_MAJOR, 2) diff --git a/ChangeLog b/ChangeLog index b27e2d5..82a2b7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,15 @@ +Changes Prior to 0.7 release + + - Fix makefile to install binary at /sbin and not /sbin/sbin + Also install man page. + - Add --zero-superblock based on --destroywithextremeprejudice + from Dale Stephenson + - change name to mdadm. It is palandromic, and much nicer to pronouce. + Changes Prior to 0.6 release - - Remove the limit on the number of device names that can be + - Remove the limit on the number of device names that can be given on the command line. - Fix bug in --assemble --force where it would only update a single superblock. diff --git a/Create.c b/Create.c index 55a9eca..d801fb4 100644 --- a/Create.c +++ b/Create.c @@ -1,5 +1,5 @@ /* - * mdctl - manage Linux "md" devices aka RAID arrays. + * mdadm - manage Linux "md" devices aka RAID arrays. * * Copyright (C) 2001-2002 Neil Brown * @@ -27,7 +27,7 @@ * Australia */ -#include "mdctl.h" +#include "mdadm.h" #include "md_u.h" #include "md_p.h" diff --git a/Detail.c b/Detail.c index 7c2860d..232b458 100644 --- a/Detail.c +++ b/Detail.c @@ -1,5 +1,5 @@ /* - * mdctl - manage Linux "md" devices aka RAID arrays. + * mdadm - manage Linux "md" devices aka RAID arrays. * * Copyright (C) 2001-2002 Neil Brown * @@ -27,7 +27,7 @@ * Australia */ -#include "mdctl.h" +#include "mdadm.h" #include "md_p.h" #include "md_u.h" diff --git a/Examine.c b/Examine.c index c8fbfbb..dc33e0f 100644 --- a/Examine.c +++ b/Examine.c @@ -1,5 +1,5 @@ /* - * mdctl - manage Linux "md" devices aka RAID arrays. + * mdadm - manage Linux "md" devices aka RAID arrays. * * Copyright (C) 2001-2002 Neil Brown * @@ -27,7 +27,7 @@ * Australia */ -#include "mdctl.h" +#include "mdadm.h" #include "dlink.h" #if ! defined(__BIG_ENDIAN) && ! defined(__LITTLE_ENDIAN) @@ -50,7 +50,7 @@ int Examine(mddev_dev_t devlist, int brief, char *conffile) * * utime, state etc * - * If (brief) gather devices for same array and just print a mdctl.conf line including devices= + * If (brief) gather devices for same array and just print a mdadm.conf line including devices= * if devlist==NULL, use conf_get_devs( */ int fd; diff --git a/Kill.c b/Kill.c new file mode 100644 index 0000000..a57bdf8 --- /dev/null +++ b/Kill.c @@ -0,0 +1,83 @@ +/* + * mdadm - manage Linux "md" devices aka RAID arrays. + * + * Copyright (C) 2001-2002 Neil Brown + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Neil Brown + * Email: + * Paper: Neil Brown + * School of Computer Science and Engineering + * The University of New South Wales + * Sydney, 2052 + * Australia + * + * Added by Dale Stephenson + * steph@snapserver.com + */ + +#include "mdadm.h" +#include "md_u.h" +#include "md_p.h" + +int Kill(char *dev, int force) +{ + /* + * Nothing fancy about Kill. It just zeroes out a superblock + * Definitely not safe. + */ + + mdp_super_t super; + int fd, rv = 0; + + fd = open(dev, O_RDWR); + if (fd < 0) { + fprintf(stderr, Name ": Couldn't open %s for write - not zeroing\n", + dev); + return 1; + } + rv = load_super(fd, &super); + if (force && rv >= 5) + rv = 0; /* ignore bad data in superblock */ + switch(rv) { + case 1: + fprintf(stderr, Name ": cannot file device size for %s: %s\n", + dev, strerror(errno)); + break; + case 2: + fprintf(stderr, Name ": %s is too small for md.\n", dev); + break; + case 3: + case 4: + fprintf(stderr, Name ": cannot access superblock on %s.\n", dev); + break; + case 5: + case 6: + fprintf(stderr, Name ": %s does not appear to have an MD superblock.\n", dev); + break; + } + if (!rv) { + memset(&super, 0, sizeof(super)); + if (store_super(fd, &super)) { + fprintf(stderr, Name ": Could not zero superblock on %s\n", + dev); + rv = 1; + } + } + close(fd); + return rv; +} diff --git a/Makefile b/Makefile index 5513451..22cd52f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # -# mdctl - manage Linux "md" devices aka RAID arrays. +# mdadm - manage Linux "md" devices aka RAID arrays. # # Copyright (C) 2001-2002 Neil Brown # @@ -31,25 +31,28 @@ CC = gcc CFLAGS = -Wall,error,strict-prototypes -ggdb INSTALL = /usr/bin/install -DESTDIR = /sbin +DESTDIR = /. +BINDIR = /sbin +MANDIR = /usr/share/man/man8 -OBJS = mdctl.o config.o ReadMe.o util.o Manage.o Assemble.o Build.o Create.o Detail.o Examine.o Monitor.o dlink.o +OBJS = mdadm.o config.o ReadMe.o util.o Manage.o Assemble.o Build.o Create.o Detail.o Examine.o Monitor.o dlink.o Kill.o -all : mdctl mdctl.man +all : mdadm mdadm.man -mdctl : $(OBJS) - $(CC) -o mdctl $^ +mdadm : $(OBJS) + $(CC) -o mdadm $^ -mdctl.man : mdctl.8 - nroff -man mdctl.8 > mdctl.man +mdadm.man : mdadm.8 + nroff -man mdadm.8 > mdadm.man -$(OBJS) : mdctl.h +$(OBJS) : mdadm.h -install : mdctl - $(INSTALL) -m 755 mdctl $(DESTDIR)/sbin +install : mdadm mdadm.8 + $(INSTALL) -m 755 mdadm $(DESTDIR)/$(BINDIR) + $(INSTALL) -m 644 mdadm.8 $(DESTDIR)/$(MANDIR) clean : - rm -f mdctl $(OBJS) core mdctl.man + rm -f mdadm $(OBJS) core mdadm.man dist : clean ./makedist diff --git a/Manage.c b/Manage.c index cab49bc..b3e048e 100644 --- a/Manage.c +++ b/Manage.c @@ -1,5 +1,5 @@ /* - * mdctl - manage Linux "md" devices aka RAID arrays. + * mdadm - manage Linux "md" devices aka RAID arrays. * * Copyright (C) 2001-2002 Neil Brown * @@ -27,7 +27,7 @@ * Australia */ -#include "mdctl.h" +#include "mdadm.h" #include "md_u.h" #include "md_p.h" diff --git a/Monitor.c b/Monitor.c index 4f4aa0e..bdab942 100644 --- a/Monitor.c +++ b/Monitor.c @@ -1,5 +1,5 @@ /* - * mdctl - manage Linux "md" devices aka RAID arrays. + * mdadm - manage Linux "md" devices aka RAID arrays. * * Copyright (C) 2001-2002 Neil Brown * @@ -27,7 +27,7 @@ * Australia */ -#include "mdctl.h" +#include "mdadm.h" #include "md_p.h" #include "md_u.h" #include diff --git a/ReadMe.c b/ReadMe.c index 5128cbf..e13075c 100644 --- a/ReadMe.c +++ b/ReadMe.c @@ -1,5 +1,5 @@ /* - * mdctl - manage Linux "md" devices aka RAID arrays. + * mdadm - manage Linux "md" devices aka RAID arrays. * * Copyright (C) 2001-2002 Neil Brown * @@ -27,19 +27,19 @@ * Australia */ -#include "mdctl.h" +#include "mdadm.h" -char Version[] = Name " - v0.6 - 7 March 2002\n"; +char Version[] = Name " - v0.7 - 8 March 2002\n"; /* * File: ReadMe.c * * This file contains general comments about the implementation - * and the various usage messages that can be displayed by mdctl + * and the various usage messages that can be displayed by mdadm * - * mdctl is a single program that can be used to control Linux md devices. + * mdadm is a single program that can be used to control Linux md devices. * It is intended to provide all the functionality of the mdtools and * raidtools but with a very different interface. - * mdctl can perform all functions without a configuration file. + * mdadm can perform all functions without a configuration file. * There is the option of using a configuration file, but not in the same * way that raidtools uses one * raidtools uses a configuration file to describe how to create a RAID @@ -48,7 +48,7 @@ char Version[] = Name " - v0.6 - 7 March 2002\n"; * file for such things as stopping a raid array which needs to know * nothing about the array. * - * The configuration file that can be used by mdctl lists two + * The configuration file that can be used by mdadm lists two * different things: * 1/ a mapping from uuid to md device to identify which arrays are * expect and what names (numbers) they should be given @@ -58,7 +58,7 @@ char Version[] = Name " - v0.6 - 7 March 2002\n"; */ /* - * mdctl has 4 major modes of operation: + * mdadm has 4 major modes of operation: * 1/ Create * This mode is used to create a new array with a superbock * It can progress in several step create-add-add-run @@ -66,7 +66,7 @@ char Version[] = Name " - v0.6 - 7 March 2002\n"; * 2/ Assemble * This mode is used to assemble the parts of a previously created * array into an active array. Components can be explicitly given - * or can be searched for. mdctl (optionally) check that the components + * or can be searched for. mdadm (optionally) check that the components * do form a bonafide array, and can, on request, fiddle superblock * version numbers so as to assemble a faulty array. * 3/ Build @@ -87,6 +87,8 @@ struct option long_options[] = { {"detail", 0, 0, 'D'}, {"examine", 0, 0, 'E'}, {"follow", 0, 0, 'F'}, + {"grow", 0, 0, 'G'}, /* not yet implemented */ + {"zero-superblock", 0, 0, 'H'}, /* synonyms */ {"monitor", 0, 0, 'F'}, @@ -136,21 +138,21 @@ struct option long_options[] = { }; char Usage[] = -"Usage: mdctl --help\n" +"Usage: mdadm --help\n" " for help\n" ; char Help[] = -"Usage: mdctl --create device options...\n" -" mdctl --assemble device options...\n" -" mdctl --build device options...\n" -" mdctl --detail device\n" -" mdctl --examine device\n" -" mdctl --follow options...\n" -" mdctl device options...\n" -" mdctl is used for controlling Linux md devices (aka RAID arrays)\n" +"Usage: mdadm --create device options...\n" +" mdadm --assemble device options...\n" +" mdadm --build device options...\n" +" mdadm --detail device\n" +" mdadm --examine device\n" +" mdadm --follow options...\n" +" mdadm device options...\n" +" mdadm is used for controlling Linux md devices (aka RAID arrays)\n" " For detail help on major modes use, e.g.\n" -" mdctl --assemble --help\n" +" mdadm --assemble --help\n" "\n" "Any parameter that does not start with '-' is treated as a device name\n" "The first such name is normally the name of an md device. Subsequent\n" @@ -167,7 +169,7 @@ char Help[] = "\n" " --help -h : This help message or, after above option,\n" " mode specific help message\n" -" --version -V : Print version information for mdctl\n" +" --version -V : Print version information for mdadm\n" " --verbose -v : Be more verbose about what is happening\n" "\n" " For create or build:\n" @@ -209,11 +211,12 @@ char Help[] = " --stop -S : deactive array, releasing all resources\n" " --readonly -o : mark array as readonly\n" " --readwrite -w : mark array as readwrite\n" +" --zero-superblock : erase the MD superblock from a device.\n" ; char Help_create[] = -"Usage: mdctl --create device -chunk=X --level=Y --raid-disks=Z devices\n" +"Usage: mdadm --create device -chunk=X --level=Y --raid-disks=Z devices\n" "\n" " This usage will initialise a new md array and possibly associate some\n" " devices with it. If enough devices are given to complete the array,\n" @@ -240,7 +243,7 @@ char Help_create[] = ; char Help_build[] = -"Usage: mdctl --build device -chunk=X --level=Y --raid-disks=Z devices\n" +"Usage: mdadm --build device -chunk=X --level=Y --raid-disks=Z devices\n" "\n" " This usage is similar to --create. The difference is that it creates\n" " a legacy array with a superblock. With these arrays there is no\n" @@ -253,12 +256,12 @@ char Help_build[] = ; char Help_assemble[] = -"Usage: mdctl --assemble device options...\n" -" mdctl --assemble --scan options...\n" +"Usage: mdadm --assemble device options...\n" +" mdadm --assemble --scan options...\n" "\n" "This usage assembles one or more raid arrays from pre-existing\n" "components.\n" -"For each array, mdctl needs to know the md device, the identify of\n" +"For each array, mdadm needs to know the md device, the identify of\n" "the array, and a number of sub devices. These can be found in a number\n" "of ways.\n" "\n" diff --git a/TAGS b/TAGS index 6c159c9..a7e975c 100644 --- a/TAGS +++ b/TAGS @@ -1,4 +1,110 @@ +Assemble.c,22 +int Assemble(34,1176 + +Build.c,100 +#define REGISTER_DEV 32,1140 +#define START_MD 33,1181 +#define STOP_MD 34,1222 +int Build(36,1264 + +COPYING,99 +program will will52,2561 +program proprietary.proprietary53,2632 +PROGRAM PROVE PROVE267,14397 + +ChangeLog,294 + - When --assemble --force,13,443 + - When marking drives as not-failed in the superblock,16,627 + are passed as unsigned lock,23,1044 + - If HOT_ADD_DISK failes for -a,24,1100 + if we cannot read from the array,25,1166 + and mdctl.conf compatible description with uuid=31,1443 + +Create.c,20 +int Create(34,1176 + +Detail.c,20 +int Detail(34,1176 + +Examine.c,21 +int Examine(38,1285 + +Kill.c,18 +int Kill(37,1237 + +Makefile,12 +CC 30,1091 + +Manage.c,161 +#define REGISTER_DEV 34,1176 +#define START_MD 35,1217 +#define STOP_MD 36,1258 +int Manage_ro(38,1300 +int Manage_runstop(75,2154 +int Manage_subdevs(118,3161 + +Monitor.c,49 +int Monitor(37,1283 +static void alert(175,4727 + +ReadMe.c,266 +char Version[32,1140 +char short_options[81,3226 +struct option long_options[82,3290 +char Usage[140,4885 +char Help[145,4942 +char Help_create[218,8393 +char Help_build[245,9615 +char Help_assemble[258,10155 +mapping_t r5layout[317,13101 +mapping_t pers[331,13317 + +TODO,590 +* write proc.c to parse /proc/mdstat file,5,65 + Build list of arrays: name,6,140 +* --detail --scan to read mdctl.conf,8,189 +* --detail --scan to read mdctl.conf, and then iterate over these,8,189 +- set md_minor,34,933 +- for create raid5,35,976 + all working,36,1019 + one missing,37,1050 + one missing, one spare,37,1050 +- when RUN_ARRAY,40,1152 +- get --detail to extract extra stuff from superblock,42,1206 +- when --assemble --scan,48,1368 +- when --assemble --scan, if an underlying device is an md device,48,1368 +ARRAY lines in config file to have super_minor=62,1797 + +config.c,479 +char DefaultConfFile[68,2401 +char *keywords[70,2446 +int match_keyword(77,2645 +char *conf_word(97,3153 +char *conf_line(163,4744 +void free_line(184,5046 +struct conf_dev conf_dev195,5188 +} *cdevlist 198,5249 +int devline(202,5272 +mddev_ident_t mddevlist 220,5595 +mddev_ident_t *mddevlp 221,5627 +void arrayline(223,5665 +int loaded 303,7978 +void load_conffile(305,7995 +mddev_ident_t conf_get_ident(338,8486 +mddev_dev_t conf_get_devs(348,8688 +int match_oneof(383,9316 + +dlink.c,177 +void *dl_head(11,180 +void dl_free(20,289 +void dl_init(26,363 +void dl_insert(32,430 +void dl_add(40,598 +void dl_del(48,763 +char *dl_strndup(57,969 +char *dl_strdup(73,1176 + dlink.h,193 struct __dl_head__dl_head5,100 #define dl_alloc(dl_alloc11,187 @@ -7,6 +113,11 @@ struct __dl_head__dl_head5,100 #define dl_next(dl_next15,391 #define dl_prev(dl_prev16,461 +makedist,127 +target=3,11 +( cd .. ; ln -s mdctl mdctl-$version 19,352 +( cd .. ; ln -s mdctl mdctl-$version ; tar czhvf - --exclude=19,352 + md_p.h,1316 #define _MD_P_H16,582 #define MD_RESERVED_BYTES 44,1414 @@ -41,8 +152,8 @@ typedef struct mdp_device_descriptor_s mdp_device_descriptor_s82,2946 #define MD_SB_CLEAN 96,3390 #define MD_SB_ERRORS 97,3413 typedef struct mdp_superblock_s mdp_superblock_s99,3438 -} mdp_super_t;mdp_super_t164,5820 -static inline __u64 md_event(166,5836 +} mdp_super_t;mdp_super_t164,5835 +static inline __u64 md_event(166,5851 md_u.h,1118 #define _MD_U_H16,590 @@ -77,123 +188,73 @@ typedef struct mdu_start_info_s mdu_start_info_s97,2713 typedef struct mdu_param_smdu_param_s108,2878 } mdu_param_t;mdu_param_t113,3014 -mdctl.h,826 -#define __USE_LARGEFILE6430,1115 -#define MD_MAJOR 47,1491 -#define Name 52,1531 -extern char short_options[54,1553 -extern struct option long_options[55,1582 -extern char Version[56,1619 -extern char Version[], Usage[56,1619 -extern char Version[], Usage[], Help[56,1619 -extern char Version[], Usage[], Help[], Help_create[56,1619 -extern char Version[], Usage[], Help[], Help_create[], Help_build[56,1619 -extern char Version[], Usage[], Help[], Help_create[], Help_build[], Help_assemble[56,1619 -typedef struct mddev_ident_s mddev_ident_s68,2055 -} *mddev_ident_t;mddev_ident_t80,2292 -typedef struct mddev_dev_s mddev_dev_s83,2359 -} *mddev_dev_t;mddev_dev_t86,2431 -typedef struct mapping mapping88,2448 -} mapping_t;mapping_t91,2496 -extern mapping_t r5layout[95,2606 -extern mapping_t r5layout[], pers[95,2606 - -Assemble.c,22 -int Assemble(34,1171 - -Build.c,100 -#define REGISTER_DEV 32,1135 -#define START_MD 33,1176 -#define STOP_MD 34,1217 -int Build(36,1259 +mdctl.8,252 +real block devices. This allows multiple devices 14,241 +{left,right}-{,a}symmetric,185,4006 +{left,right}-{,a}symmetric, la,185,4006 +{left,right}-{,a}symmetric, la, ra,185,4006 +{left,right}-{,a}symmetric, la, ra, ls,185,4006 +.BR --layout=188,4087 -Create.c,20 -int Create(34,1171 - -Detail.c,20 -int Detail(34,1171 - -Examine.c,21 -int Examine(37,1261 - -Manage.c,161 -#define REGISTER_DEV 34,1171 -#define START_MD 35,1212 -#define STOP_MD 36,1253 -int Manage_ro(38,1295 -int Manage_runstop(75,2149 -int Manage_subdevs(118,3161 - -ReadMe.c,265 -char Version[32,1135 -char short_options[81,3222 -struct option long_options[82,3280 -char Usage[123,4484 -char Help[128,4541 -char Help_create[185,7233 -char Help_build[212,8453 -char Help_assemble[225,8993 -mapping_t r5layout[284,11939 -mapping_t pers[298,12155 - -config.c,479 -char DefaultConfFile[68,2396 -char *keywords[70,2441 -int match_keyword(77,2640 -char *conf_word(97,3148 -char *conf_line(163,4739 -void free_line(184,5041 -struct conf_dev conf_dev195,5183 -} *cdevlist 198,5244 -int devline(202,5267 -mddev_ident_t mddevlist 220,5590 -mddev_ident_t *mddevlp 221,5622 -void arrayline(223,5660 -int loaded 289,7453 -void load_conffile(291,7470 -mddev_ident_t conf_get_ident(324,7961 -mddev_dev_t conf_get_devs(334,8163 -int match_oneof(369,8791 +mdctl.c,64 +int open_mddev(33,1158 +int main(50,1477 +#define O(O177,4288 -dlink.c,177 -void *dl_head(11,180 -void dl_free(20,289 -void dl_init(26,363 -void dl_insert(32,430 -void dl_add(40,598 -void dl_del(48,763 -char *dl_strndup(57,969 -char *dl_strdup(73,1176 +mdctl.h,855 +#define __USE_LARGEFILE6430,1120 +#define MD_MAJOR 47,1496 +#define Name 52,1536 +extern char short_options[54,1558 +extern struct option long_options[55,1587 +extern char Version[56,1624 +extern char Version[], Usage[56,1624 +extern char Version[], Usage[], Help[56,1624 +extern char Version[], Usage[], Help[], Help_create[56,1624 +extern char Version[], Usage[], Help[], Help_create[], Help_build[56,1624 +extern char Version[], Usage[], Help[], Help_create[], Help_build[], Help_assemble[56,1624 +typedef struct mddev_ident_s mddev_ident_s68,2060 +} *mddev_ident_t;mddev_ident_t83,2389 +typedef struct mddev_dev_s mddev_dev_s86,2456 +} *mddev_dev_t;mddev_dev_t92,2644 +typedef struct mapping mapping94,2661 +} mapping_t;mapping_t97,2709 +#define Sendmail 100,2740 +extern mapping_t r5layout[105,2884 +extern mapping_t r5layout[], pers[105,2884 -mdctl.c,64 -int open_mddev(33,1153 -int main(50,1472 -#define O(O149,3610 +mdctl.spec,235 +Summary: mdctl is used for controlling Linux md devices 1,0 +option of using a configuration file,18,630 +raidtools uses a configuration file to describe how to create a RAID array,21,718 +Further,23,871 +stopping a raid array,24,941 raid5extend.c,39 int phys2log(2,1 raid5_extend(46,902 -util.c,573 -int parse_uuid(40,1354 -int md_get_version(82,2117 -int get_linux_version(101,2476 -int enough(113,2673 -int same_uuid(129,2923 -void uuid_from_super(139,3052 -int compare_super(153,3329 -int load_super(187,4292 -int store_super(227,4950 -int check_ext2(253,5321 -int check_reiser(284,6084 -int check_raid(308,6640 -int ask(324,7003 -char *map_num(344,7368 -int map_name(354,7503 -struct devmap devmap369,7832 -} *devlist 373,7911 -int devlist_ready 374,7930 -#define __USE_XOPEN_EXTENDED376,7954 -int add_dev(380,8003 -char *map_dev(396,8370 -int calc_sb_csum(412,8645 +util.c,600 +int parse_uuid(40,1359 +int md_get_version(82,2122 +int get_linux_version(101,2481 +int enough(113,2678 +int same_uuid(129,2928 +void uuid_from_super(139,3057 +int compare_super(153,3334 +int load_super(187,4297 +int store_super(227,4955 +int check_ext2(253,5326 +int check_reiser(284,6089 +int check_raid(308,6645 +int ask(324,7008 +char *map_num(344,7373 +int map_name(354,7508 +struct devmap devmap369,7837 +} *devlist 373,7916 +int devlist_ready 374,7935 +#define __USE_XOPEN_EXTENDED376,7959 +int add_dev(380,8008 +char *map_dev(396,8375 +int calc_sb_csum(412,8650 +char *human_size(428,9046 diff --git a/TODO b/TODO index a23e0fe..061a2b4 100644 --- a/TODO +++ b/TODO @@ -5,7 +5,7 @@ * write proc.c to parse /proc/mdstat file, and maybe /proc/partitions too. Build list of arrays: name, rebuild-percent -* --detail --scan to read mdctl.conf, and then iterate over these, +* --detail --scan to read mdadm.conf, and then iterate over these, but assume --brief. --verbose can override check each subdevice to see if it is in conf_get_devs. Warn if not. @@ -23,7 +23,7 @@ spare added ------------------------------------ -- --examine --scan scans all drives and build an mdctl.conf file DONE +- --examine --scan scans all drives and build an mdadm.conf file DONE - check superblock checksum in examine DONE - report "chunk" or "rounding" depending on raid level DONE @@ -49,9 +49,9 @@ then try to assemble that device first. -- mdctl -S /dev/md0 /dev/md1 gives internal error FIXED +- mdadm -S /dev/md0 /dev/md1 gives internal error FIXED -- mdctl --detail --scan print summary of what it can find? +- mdadm --detail --scan print summary of what it can find? --------- diff --git a/config.c b/config.c index 4fc381c..ea2f971 100644 --- a/config.c +++ b/config.c @@ -1,5 +1,5 @@ /* - * mdctl - manage Linux "md" devices aka RAID arrays. + * mdadm - manage Linux "md" devices aka RAID arrays. * * Copyright (C) 2001-2002 Neil Brown * @@ -27,7 +27,7 @@ * Australia */ -#include "mdctl.h" +#include "mdadm.h" #include "dlink.h" #include #include @@ -65,7 +65,7 @@ * */ -char DefaultConfFile[] = "/etc/mdctl.conf"; +char DefaultConfFile[] = "/etc/mdadm.conf"; char *keywords[] = { "device", "array", NULL }; diff --git a/makedist b/makedist index dae9949..73f1ea3 100755 --- a/makedist +++ b/makedist @@ -1,6 +1,6 @@ #!/bin/sh -target=${1-~/public_html/source/mdctl} +target=${1-~/public_html/source/mdadm} if [ -d $target ] then : else echo $target is not a directory @@ -9,13 +9,13 @@ fi set `grep '^char Version' ReadMe.c ` version=`echo $7 | sed 's/v//'` echo version = $version -base=mdctl-$version.tgz +base=mdadm-$version.tgz if [ -f $target/$base ] then echo $target/$base exists. exit 1 fi trap "rm $target/$base; exit" 1 2 3 -( cd .. ; ln -s mdctl mdctl-$version ; tar czhvf - --exclude='*,v' --exclude='*.o' --exclude mdctl --exclude=RCS mdctl-$version ; rm mdctl-$version ) > $target/$base +( cd .. ; ln -s mdadm mdadm-$version ; tar czhvf - --exclude='*,v' --exclude='*.o' --exclude mdadm --exclude=RCS mdadm-$version ; rm mdadm-$version ) > $target/$base chmod a+r $target/$base ls -l $target/$base diff --git a/mdadm.8 b/mdadm.8 new file mode 100644 index 0000000..7eba10c --- /dev/null +++ b/mdadm.8 @@ -0,0 +1,575 @@ +.\" -*- nroff -*- +.TH mdadm 8 +.SH NAME +mdadm \- manage MD devices +.I aka +Linux Software Raid. + +.SH SYNOPSIS + +.BI mdadm " [mode] [options] " + +.SH DESCRIPTION +RAID devices are virtual devices created from two or more +real block devices. This allows multiple devices (typically disk +drives or partitions there-of) to be combined into a single device to +hold (for example) a single filesystem. +Some RAID levels included redundancy and so can survive some degree of +device failure. + +Linux Software RAID devices are implemented through the md (Multiple Devices) device driver. + +Currently, Linux supports +.B LINEAR +md devices, +.B RAID0 +(striping), +.B RAID1 +(mirroring), +.B RAID4 +and +.B RAID5. + +Recent kernels (2002) also support a mode known as +.BR MULTIPATH . +.B mdadm +does not support MULTIPATH as yet. + +.B mdadm +is a program that can be used to create and manage MD devices. As +such it provides a similar set of functionality to the +.B raidtools +packages. +The key differences between +.B mdadm +and +.B raidtools +are: +.IP \(bu 4 +.B mdadm +is a single program and not a collection of programs. +.IP \(bu 4 +.B mdadm +can perform (almost) all of its functions without having a +configuration file. Also mdadm helps with management of the configuration +file. +.IP \(bu 4 +.B mdadm +can provide information about your arrays (through Detail and Examine) +that +.B raidtools +cannot. +.IP \(bu 4 +.B raidtools +can manage MULTIPATH devices which +.B mdadm +cannot yet manage. + +.SH MODES +mdadm has 7 major modes of operation: +.TP +.B Assemble +Assemble the parts of a previously created +array into an active array. Components can be explicitly given +or can be searched for. +.B mdadm +checks that the components +do form a bona fide array, and can, on request, fiddle superblock +information so as to assemble a faulty array. + +.TP +.B Build +Build a legacy array without per-device superblocks. + +.TP +.B Create +Create a new array with per-device superblocks. +'''It can progress +'''in several step create-add-add-run or it can all happen with one command. + +.TP +.B Detail +Display the details of a given md device. Details include the RAID +level, the number of devices, which ones are faulty (if any), and the +array UUID. + +.TP +.B Examine +Examine a device to see if it is part of an md array, and print out +the details of that array. +This mode can also be used to examine a large number of devices and to +print out a summary of the arrays found in a format suitable for the +.B mdadm.conf +configuration file. + +.TP +.B "Follow or Monitor" +Monitor one or more md devices and act on any state changes. + +.TP +.B Manage +This is for odd bits an pieces like hotadd, hotremove, setfaulty, stop, +readonly, readwrite. +'''If an array is only partially setup by the +'''Create or Assemble commands, subsequent Manage commands can finish the +'''job. + +.SH OPTIONS + +Available options are: + +.TP +.BR -A ", " --assemble +Assemble an existing array. + +.TP +.BR -B ", " --build +Build a legacy array without superblocks. + +.TP +.BR -C ", " --create +Create a new array. + +.TP +.BR -D ", " --detail +Print detail of one or more md devices. + +.TP +.BR -E ", " --examine +Print content of md superblock on device(s). + +.TP +.BR -F ", " --follow ", " --monitor +Select +.B Monitor +mode. + +.TP +.BR -h ", " --help +Display help message or, after above option, mode specific help message. + +.TP +.BR -V ", " --version +Print version information for mdadm. + +.TP +.BR -v ", " --verbose +Be more verbose about what is happening. + +.TP +.BR -b ", " --brief +Be less verbose. This is used with +.B --detail +and +.BR --examine . + +.SH For create or build: + +.TP +.BR -c ", " --chunk= +Specify chunk size of kibibytes. The default is 64. + +.TP +.BR --rounding= +Specify rounding factor for linear array (==chunk size) + +.TP +.BR -l ", " --level= +Set raid level. Options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid5, 4, +raid5, 5. Obviously some of these are synonymous. +Only the first 4 are valid when Building. + +.TP +.BR -p ", " --parity= +Set raid5 parity algorithm. Options are: +{left,right}-{,a}symmetric, la, ra, ls, rs. The default is left-symmetric. + +.TP +.BR --layout= +same as --parity + +.TP +.BR -n ", " --raid-disks= +number of active devices in array. + +.TP +.BR -x ", " --spare-disks= +number of spare (eXtra) disks in initial array. Spares can be added +and removed later. + +.TP +.BR -z ", " --size= +Amount (in Kibibytes) of space to use from each drive in RAID1/4/5. +This must be a multiple of the chunk size, and must leave about 128Kb +of space at the end of the drive for the RAID superblock. +If this is not specified +(as it normally is not) the smallest drive (or partition) sets the +size, though if there is a variance among the drives of greater than 1%, a warning is +issued. + +.SH For assemble: + +.TP +.BR -u ", " --uuid= +uuid of array to assemble. Devices which don't have this uuid are +excluded + +.TP +.BR -m ", " --super-minor= +Minor number of device that array was created for. Devices which +don't have this minor number are excluded. If you create an array as +/dev/md1, then all superblock will contain the minor number 1, even if +the array is later assembled as /dev/md2. + +.TP +.BR -c ", " --config= +config file. Default is +.BR /etc/mdadm.conf . + +.TP +.BR -s ", " --scan +scan config file for missing information + +.TP +.BR -f ", " --force +Assemble the array even if some superblocks appear out-of-date + +.TP +.BR -R ", " --run +Attempt to start the array even if fewer drives were given than are +needed for a full array. Normally if not all drives are found and +.B --scan +is not used, then the array will be assembled but not started. +With +.B --run +an attempt will be made to start it anyway. + +.SH General management + +.TP +.BR -a ", " --add +'''add, or +hotadd listed devices. + +.TP +.BR -r ", " --remove +remove listed devices. The must not be active. i.e. they should +be failed or spare devices. + +.TP +.BR -f ", " --fail +mark listed devices as faulty. + +.TP +.BR --set-faulty +same as --fail. + +.TP +.BR -R ", " --run +start a partially built array. + +.TP +.BR -S ", " --stop +deactivate array, releasing all resources. + +.TP +.BR -o ", " --readonly +mark array as readonly. + +.TP +.BR -w ", " --readwrite +mark array as readwrite. + + +.SH ASSEMBLY MODE + +.HP 12 +Usage: +.B mdadm --assemble +.I device options... +.HP 12 +Usage: +.B mdadm --assemble --scan +.I options... + +.PP +This usage assembles one or more raid arrays from pre-existing components. +For each array, mdadm needs to know the md device, the identity of the +array, and a number of sub devices. These can be found in a number of ways. + +The md device is either given before +.B --scan +or is found from the config file. In the latter case, multiple md devices +can be started with a single mdadm command. + +The identity can be given with the +.B --uuid +option, with the +.B --super-minor +option, can be found in in the config file, or will be taken from the +super block on the first subdevice listed on the command line. + +Devices can be given on the +.B --assemble +command line or from the config file. Only devices which have an md +superblock which contains the right identity will be considered for any device. + +The config file is only used if explicitly named with +.B --config +or requested with +.B --scan. +In the later case, +.B /etc/mdadm.conf +is used. + +If +.B --scan +is not given, then the config file will only be used to find the +identity of md arrays. + +Normally the array will be started after it is assembled. However is +.B --scan +is not given and insufficient drives were lists to start a complete +(non-degraded) array, then the array is not started (to guard against +usage errors). To insist that the array be started in this case (as +may work for RAID1 or RAID5), give the +.B --run +flag. + + +.SH BUILD MODE + +.HP 12 +Usage: +.B mdadm --build +.I device +.BI --chunk= X +.BI --level= Y +.BI --raid-disks= Z +.I devices + +.PP +This usage is similar to +.BR --create . +The difference is that it creates a legacy array without a superblock. With +these arrays there is no difference between initially creating the array and +subsequently assembling the array, except that hopefully there is useful +data there in the second case. + +The level may only be 0, raid0, or linear. All devices must be listed +and the array will be started once complete. + +.SH CREATE MODE + +.HP 12 +Usage: +.B mdadm --create +.I device +.BI --chunk= X +.BI --level= Y +.br +.BI --raid-disks= Z +.I devices + +.PP +This usage will initialise a new md array, associate some devices with +it, and activate the array. + +As devices are added, they are checked to see if they contain raid +superblocks or filesystems. They are also check to see if the variance in +device size exceeds 1%. + +If any discrepancy is found, the array will not automatically be run, though +the presence of a +.B --run +can override this caution. + +'''If the +'''.B --size +'''option is given, it is not necessary to list any subdevices in this command. +'''They can be added later, before a +'''.B --run. +'''If no +'''.B --size +'''is given, the apparent size of the smallest drive given is used. + +The General Management options that are valid with --create are: +.TP +.B --run +insist of running the array even if some devices look like they might +be in use. + +.TP +.B --readonly +start the array readonly - not supported yet. + +.SH DETAIL MODE +.HP 12 +Usage: +.B mdadm --detail +.RB [ --brief ] +.I device ... +.PP + +This usage sill print out the details of the given array including a +list of component devices. To determine names for the devices, +.B mdadm +searches +.B /dev +for device files with the right major and minor numbers. + +With +.B --brief +.B mdadm +prints a single line that identifies the level, number of disks, and +UUID of the array. This line is suitable for inclusion in +.BR /etc/mdadm.conf . + +.SH EXAMINE MODE +.HP 12 +Usage: +.B mdadm --examine +.RB [ --scan ] +.RB [ --brief ] +.I device ... +.PP +This usage will examine some block devices to see if that have a valid +RAID superblock on them. The information in each valid raid +superblock will be printed. + +If +.B --scan +is used, the no devices should be listed, and the complete set of +devices identified in the configuration file are checked. +.B --scan +implies +.B --brief +but this implication can be countered by specifying +.BR --verbose . + +With +.B --brief +.B mdadm +will output an config file entry of each distinct array that was +found. This entry will list the UUID, the raid level, and a list of +the individual devices on which a superblock for that array was found. +This output will by syntactically suitable for inclusion in the +configuration file, but should +.B NOT +be used blindly. Often the array description that you want in the +configuration file is much less specific than that given by +.BR "mdadm -Bs" . +For example, you normally do not want to list the devices, +particularly if they are SCSI devices. + +'''.SH BUGS +'''no known bugs. + +.SH FILES + +.SS /proc/mdstat + +If you're using the +.B /proc +filesystem, +.B /proc/mdstat +gives you informations about md devices status. +This file is not currently used by +.BR mdadm . + +.SS /etc/mdadm.conf + +The config file is line oriented with, as usual, blank lines and lines +beginning with a hash (or pound sign or sharp or number sign, +whichever you like to call it) ignored. +Lines that start with a blank are treated as continuations of the +previous line (I don't like trailing slashes). + +Each line contains a sequence of space-separated words, the first of +which identified the type of line. Keywords are case-insensitive, and +the first work on a line can be abbreviated to 3 letters. + +There are two types of lines. ARRAY and DEVICE. + +The DEVICE lines usually come first. All remaining words on the line +are treated as names of devices, possibly containing wild cards (see +.IR glob (7)). +These list all the devices that +.B mdadm +is allowed to scan +when looking for devices with RAID superblocks. +Each line can contain multiple device names, and there can be multiple +DEVICE lines. For example: +.IP +DEVICE /dev/hda* /dev/hdc* +.br +DEV /dev/sd* +.br +DEVICE /dev/discs/disc*/disc +.PP +The ARRAY lines identify actual arrays. The second word on the line +should be the name of the device where the array is normally +assembled, such as /dev/md1. +Subsequent words identify the array. If multiple identities are given, +then the array much match ALL identities to be considered a match. +Each identity word has a tag, and equals sign, and some value. +The options are: + +.TP +.B uuid= +The value should be a 128 bit uuid in hexadecimal, with punctuation +interspersed if desired. This must match the uuid stored in the +superblock. +.TP +.B super-minor= +The value is an integer which indicates the minor number that was +stored in the superblock when the array was created. When an array is +created as /dev/mdX, then the minor number X is stored. +.TP +.B devices= +The value is a comma separated list of device names. Precisely these +devices will be used to assemble the array. Note that the devices +listed there must also be listed on a DEVICE line. +.TP +.B level= +The value is a raid level. This is normally used to identify an +array, but is supported so that the output of +.B "mdadm --examine --scan" +can be use directly in the configuration file. +.TP +.B disks= +The value is the number of disks in a complete active array. As with +.B level= +this is mainly for compatibility with the output of +.BR "mdadm --examine --scan" . + +.SH TODO + +Finish and document Follow mode. + +.SH SEE ALSO +For information on the various levels of +RAID, check out: + +.IP +.UR http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/ +http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/ +.UE +.PP +for new releases of the RAID driver check out: + +.IP +.UR ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches +ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches +.UE +.PP +or +.IP +.UR http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/ +http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/ +.URk +.PP +.IR raidtab (5), +.IR raid0run (8), +.IR raidstop (8), +.IR mkraid (8) diff --git a/mdadm.c b/mdadm.c new file mode 100644 index 0000000..54a718b --- /dev/null +++ b/mdadm.c @@ -0,0 +1,545 @@ +/* + * mdadm - manage Linux "md" devices aka RAID arrays. + * + * Copyright (C) 2001-2002 Neil Brown + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Neil Brown + * Email: + * Paper: Neil Brown + * School of Computer Science and Engineering + * The University of New South Wales + * Sydney, 2052 + * Australia + */ + +#include "mdadm.h" +#include "md_p.h" + +int open_mddev(char *dev) +{ + int mdfd = open(dev, O_RDWR, 0); + if (mdfd < 0) + fprintf(stderr,Name ": error opening %s: %s\n", + dev, strerror(errno)); + else if (md_get_version(mdfd) <= 0) { + fprintf(stderr, Name ": %s does not appear to be an md device\n", + dev); + close(mdfd); + mdfd = -1; + } + return mdfd; +} + + + +int main(int argc, char *argv[]) +{ + char mode = '\0'; + int opt; + char *help_text; + char *c; + int rv; + int i; + + int chunk = 0; + int size = 0; + int level = -10; + int layout = -1; + int raiddisks = 0; + int sparedisks = 0; + struct mddev_ident_s ident; + char *configfile = NULL; + char *cp; + int scan = 0; + char devmode = 0; + int runstop = 0; + int readonly = 0; + mddev_dev_t devlist = NULL; + mddev_dev_t *devlistend = & devlist; + mddev_dev_t dv; + int devs_found = 0; + int verbose = 0; + int brief = 0; + int force = 0; + + char *mailaddr = NULL; + char *program = NULL; + int delay = 0; + + int mdfd = -1; + + ident.uuid_set=0; + ident.level = -10; + ident.raid_disks = -1; + ident.super_minor= -1; + ident.devices=0; + + while ((opt=getopt_long(argc, argv, + short_options, long_options, + NULL)) != -1) { + + switch(opt) { + case '@': /* just incase they say --manage */ + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'H': + /* setting mode - only once */ + if (mode) { + fprintf(stderr, Name ": --%s/-%c not allowed, mode already set to %s\n", + long_options[opt-'A'+1].name, + long_options[opt-'A'+1].val, + long_options[mode-'A'+1].name); + exit(2); + } + mode = opt; + continue; + + case 'h': + help_text = Help; + switch (mode) { + case 'C': help_text = Help_create; break; + case 'B': help_text = Help_build; break; + case 'A': help_text = Help_assemble; break; + } + fputs(help_text,stderr); + exit(0); + + case 'V': + fputs(Version, stderr); + exit(0); + + case 'v': verbose = 1; + continue; + + case 'b': brief = 1; + continue; + + case 1: /* an undecorated option - must be a device name. + * Depending on mode, it could be that: + * All devices listed are "md" devices : --Detail, -As + * No devices are "md" devices : --Examine + * First device is "md", others are component: -A,-B,-C + * Only accept on device before mode is determined. + * If mode is @, then require devmode for other devices. + */ + if (devs_found > 0 && !mode ) { + fprintf(stderr, Name ": Must give mode flag before second device name at %s\n", optarg); + exit(2); + } + if (devs_found > 0 && mode == '@' && !devmode) { + fprintf(stderr, Name ": Must give on of -a/-r/-f for subsequent devices at %s\n", optarg); + exit(2); + } + dv = malloc(sizeof(*dv)); + if (dv == NULL) { + fprintf(stderr, Name ": malloc failed\n"); + exit(3); + } + dv->devname = optarg; + dv->disposition = devmode; + dv->next = NULL; + *devlistend = dv; + devlistend = &dv->next; + + devs_found++; + continue; + + case ':': + case '?': + fputs(Usage, stderr); + exit(2); + default: + /* force mode setting - @==manage if nothing else */ + if (!mode) mode = '@'; + } + + /* We've got a mode, and opt is now something else which + * could depend on the mode */ +#define O(a,b) ((a<<8)|b) + switch (O(mode,opt)) { + case O('C','c'): + case O('B','c'): /* chunk or rounding */ + if (chunk) { + fprintf(stderr, Name ": chunk/rounding may only be specified once. " + "Second value is %s.\n", optarg); + exit(2); + } + chunk = strtol(optarg, &c, 10); + if (!optarg[0] || *c || chunk<4 || ((chunk-1)&chunk)) { + fprintf(stderr, Name ": invalid chunk/rounding value: %s\n", + optarg); + exit(2); + } + continue; + + case O('C','z'): /* size */ + if (size) { + fprintf(stderr, Name ": size may only be specified once. " + "Second value is %s.\n", optarg); + exit(2); + } + size = strtol(optarg, &c, 10); + if (!optarg[0] || *c || size < 4) { + fprintf(stderr, Name ": invalid size: %s\n", + optarg); + exit(2); + } + continue; + + case O('C','l'): + case O('B','l'): /* set raid level*/ + if (level != -10) { + fprintf(stderr, Name ": raid level may only be set once. " + "Second value is %s.\n", optarg); + exit(2); + } + level = map_name(pers, optarg); + if (level == -10) { + fprintf(stderr, Name ": invalid raid level: %s\n", + optarg); + exit(2); + } + if (level > 0 && mode == 'B') { + fprintf(stderr, Name ": Raid level %s not permitted with --build.\n", + optarg); + exit(2); + } + if (sparedisks > 0 && level < 1) { + fprintf(stderr, Name ": raid level %s is incompatible with spare-disks setting.\n", + optarg); + exit(2); + } + ident.level = level; + continue; + + case O('C','p'): /* raid5 layout */ + if (layout >= 0) { + fprintf(stderr,Name ": layout may only be sent once. " + "Second value was %s\n", optarg); + exit(2); + } + switch(level) { + default: + fprintf(stderr, Name ": layout now meaningful for %s arrays.\n", + map_num(pers, level)); + exit(2); + case -10: + fprintf(stderr, Name ": raid level must be given before layout.\n"); + exit(2); + + case 5: + layout = map_name(r5layout, optarg); + if (layout==-10) { + fprintf(stderr, Name ": layout %s not understood for raid5.\n", + optarg); + exit(2); + } + break; + } + continue; + + case O('C','n'): + case O('B','n'): /* number of raid disks */ + if (raiddisks) { + fprintf(stderr, Name ": raid-disks set twice: %d and %s\n", + raiddisks, optarg); + exit(2); + } + raiddisks = strtol(optarg, &c, 10); + if (!optarg[0] || *c || raiddisks<=0 || raiddisks > MD_SB_DISKS) { + fprintf(stderr, Name ": invalid number of raid disks: %s\n", + optarg); + exit(2); + } + ident.raid_disks = raiddisks; + continue; + + case O('C','x'): /* number of spare (eXtra) discs */ + if (sparedisks) { + fprintf(stderr,Name ": spare-disks set twice: %d and %s\n", + sparedisks, optarg); + exit(2); + } + if (level > -10 && level < 1) { + fprintf(stderr, Name ": spare-disks setting is incompatible with raid level %d\n", + level); + exit(2); + } + sparedisks = strtol(optarg, &c, 10); + if (!optarg[0] || *c || sparedisks < 0 || sparedisks > MD_SB_DISKS - raiddisks) { + fprintf(stderr, Name ": invalid number of spare disks: %s\n", + optarg); + exit(2); + } + continue; + case O('C','f'): /* force honouring of device list */ + case O('A','f'): /* force assembly */ + case O('H','f'): /* force zero */ + force=1; + continue; + + /* now for the Assemble options */ + case O('A','u'): /* uuid of array */ + if (ident.uuid_set) { + fprintf(stderr, Name ": uuid cannot be set twice. " + "Second value %s.\n", optarg); + exit(2); + } + if (parse_uuid(optarg, ident.uuid)) + ident.uuid_set = 1; + else { + fprintf(stderr,Name ": Bad uuid: %s\n", optarg); + exit(2); + } + continue; + + case O('A','m'): /* super-minor for array */ + if (ident.super_minor >= 0) { + fprintf(stderr, Name ": super-minor cannot be set twice. " + "Second value: %s.\n", optarg); + exit(2); + } + ident.super_minor = strtoul(optarg, &cp, 10); + if (!optarg[0] || *cp) { + fprintf(stderr, Name ": Bad super-minor number: %s.\n", optarg); + exit(2); + } + continue; + + case O('A','c'): /* config file */ + case O('F','c'): + if (configfile) { + fprintf(stderr, Name ": configfile cannot be set twice. " + "Second value is %s.\n", optarg); + exit(2); + } + configfile = optarg; + /* FIXME possibly check that config file exists. Even parse it */ + continue; + case O('A','s'): /* scan */ + case O('E','s'): + scan = 1; + continue; + + case O('F','m'): /* mail address */ + if (mailaddr) + fprintf(stderr, Name ": only specify one mailaddress. %s ignored.\n", + optarg); + else + mailaddr = optarg; + continue; + + case O('F','p'): /* alert program */ + if (program) + fprintf(stderr, Name ": only specify one alter program. %s ignored.\n", + optarg); + else + program = optarg; + continue; + + case O('F','d'): /* delay in seconds */ + if (delay) + fprintf(stderr, Name ": only specify delay once. %s ignored.\n", + optarg); + else { + delay = strtol(optarg, &c, 10); + if (!optarg[0] || *c || delay<1) { + fprintf(stderr, Name ": invalid delay: %s\n", + optarg); + exit(2); + } + } + continue; + + + /* now the general management options. Some are applicable + * to other modes. None have arguments. + */ + case O('@','a'): + case O('C','a'): + case O('B','a'): + case O('A','a'): /* add a drive */ + devmode = 'a'; + continue; + case O('@','r'): /* remove a drive */ + devmode = 'r'; + continue; + case O('@','f'): /* set faulty */ + devmode = 'f'; + continue; + case O('@','R'): + case O('A','R'): + case O('B','R'): + case O('C','R'): /* Run the array */ + if (runstop < 0) { + fprintf(stderr, Name ": Cannot both Stop and Run an array\n"); + exit(2); + } + runstop = 1; + continue; + case O('@','S'): + if (runstop > 0) { + fprintf(stderr, Name ": Cannot both Run and Stop an array\n"); + exit(2); + } + runstop = -1; + continue; + + case O('@','o'): + if (readonly < 0) { + fprintf(stderr, Name ": Cannot have both readonly and readwrite\n"); + exit(2); + } + readonly = 1; + continue; + case O('@','w'): + if (readonly > 0) { + fprintf(stderr, "mkdctl: Cannot have both readwrite and readonly.\n"); + exit(2); + } + readonly = -1; + continue; + } + /* We have now processed all the valid options. Anything else is + * an error + */ + fprintf(stderr, Name ": option %c not valid in mode %c\n", + opt, mode); + exit(2); + + } + + if (!mode) { + fputs(Usage, stderr); + exit(2); + } + /* Ok, got the option parsing out of the way + * hopefully it's mostly right but there might be some stuff + * missing + * + * That is mosty checked in ther per-mode stuff but... + * + * For @,B,C and A without -s, the first device listed must be an md device + * we check that here and open it. + */ + + if (mode=='@' || mode == 'B' || mode == 'C' || (mode == 'A' && ! scan)) { + if (devs_found < 1) { + fprintf(stderr, Name ": an md device must be given in this mode\n"); + exit(2); + } + mdfd = open_mddev(devlist->devname); + if (mdfd < 0) + exit(1); + } + + + rv = 0; + switch(mode) { + case '@':/* Management */ + /* readonly, add/remove, readwrite, runstop */ + if (readonly>0) + rv = Manage_ro(devlist->devname, mdfd, readonly); + if (!rv && devs_found>1) + rv = Manage_subdevs(devlist->devname, mdfd, + devlist->next); + if (!rv && readonly < 0) + rv = Manage_ro(devlist->devname, mdfd, readonly); + if (!rv && runstop) + rv = Manage_runstop(devlist->devname, mdfd, runstop); + break; + case 'A': /* Assemble */ + if (!scan) + rv = Assemble(devlist->devname, mdfd, &ident, configfile, + devlist->next, + readonly, runstop, verbose, force); + else if (devs_found>0) + for (dv = devlist ; dv ; dv=dv->next) { + mddev_ident_t array_ident = conf_get_ident(configfile, dv->devname); + mdfd = open_mddev(dv->devname); + if (mdfd < 0) { + rv |= 1; + continue; + } + if (array_ident == NULL) { + fprintf(stderr, Name ": %s not identified in config file.\n", + dv->devname); + rv |= 1; + continue; + } + rv |= Assemble(dv->devname, mdfd, array_ident, configfile, + NULL, + readonly, runstop, verbose, force); + } + else { + mddev_ident_t array_list = conf_get_ident(configfile, NULL); + if (!array_list) { + fprintf(stderr, Name ": No arrays found in config file\n"); + rv = 1; + } else + for (; array_list; array_list = array_list->next) { + mdu_array_info_t array; + mdfd = open_mddev(array_list->devname); + if (mdfd < 0) { + rv |= 1; + continue; + } + if (ioctl(mdfd, GET_ARRAY_INFO, &array)>=0) + /* already assembled, skip */ + continue; + rv |= Assemble(array_list->devname, mdfd, + array_list, configfile, + NULL, + readonly, runstop, verbose, force); + } + } + break; + case 'B': /* Build */ + rv = Build(devlist->devname, mdfd, chunk, level, raiddisks, devlist->next); + break; + case 'C': /* Create */ + rv = Create(devlist->devname, mdfd, chunk, level, layout, size, + raiddisks, sparedisks, + devs_found-1, devlist->next, runstop, verbose, force); + break; + case 'D': /* Detail */ + for (dv=devlist ; dv; dv=dv->next) + rv |= Detail(dv->devname, brief); + break; + case 'E': /* Examine */ + if (devlist == NULL && scan==0) { + fprintf(stderr, Name ": No devices to examine\n"); + exit(2); + } + rv = Examine(devlist, devlist?brief:!verbose, configfile); + break; + case 'F': /* Follow */ + rv= Monitor(devlist, mailaddr, program, + delay?delay:60, configfile); + break; + case 'H': /* Zero superblock */ + for (dv=devlist ; dv; dv=dv->next) + rv |= Kill(dv->devname, force); + break; + } + exit(rv); +} diff --git a/mdadm.h b/mdadm.h new file mode 100644 index 0000000..6959cfe --- /dev/null +++ b/mdadm.h @@ -0,0 +1,152 @@ +/* + * mdadm - manage Linux "md" devices aka RAID arrays. + * + * Copyright (C) 2001-2002 Neil Brown + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Neil Brown + * Email: + * Paper: Neil Brown + * School of Computer Science and Engineering + * The University of New South Wales + * Sydney, 2052 + * Australia + */ + +#define __USE_LARGEFILE64 +#include +extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence)); + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#define MD_MAJOR 9 + + +#include "md_u.h" + +#define Name "mdadm" + +extern char short_options[]; +extern struct option long_options[]; +extern char Version[], Usage[], Help[], Help_create[], Help_build[], Help_assemble[]; + +/* structures read from config file */ +/* List of mddevice names and identifiers + * Identifiers can be: + * uuid=128-hex-uuid + * super-minor=decimal-minor-number-from-superblock + * devices=comma,separated,list,of,device,names,with,wildcards + * + * If multiple fields are present, the intersection of all matching + * devices is considered + */ +typedef struct mddev_ident_s { + char *devname; + + int uuid_set; + __u32 uuid[4]; + + int super_minor; /* -1 if not set */ + + char *devices; /* comma separated list of device + * names with wild cards + */ + int level; /* -10 if not set */ + int raid_disks; /* -1 if not set */ + char *spare_group; + struct mddev_ident_s *next; +} *mddev_ident_t; + +/* List of device names - wildcards expanded */ +typedef struct mddev_dev_s { + char *devname; + char disposition; /* 'a' for add, 'r' for remove, 'f' for fail. + * Not set for names read from .config + */ + struct mddev_dev_s *next; +} *mddev_dev_t; + +typedef struct mapping { + char *name; + int num; +} mapping_t; + +#ifndef Sendmail +#define Sendmail "/usr/lib/sendmail -t" +#endif + +extern char *map_num(mapping_t *map, int num); +extern int map_name(mapping_t *map, char *name); +extern mapping_t r5layout[], pers[]; + +extern char *map_dev(int major, int minor); + + +extern int Manage_ro(char *devname, int fd, int readonly); +extern int Manage_runstop(char *devname, int fd, int runstop); +extern int Manage_subdevs(char *devname, int fd, + mddev_dev_t devlist); + + +extern int Assemble(char *mddev, int mdfd, + mddev_ident_t ident, + char *conffile, + mddev_dev_t devlist, + int readonly, int runstop, + int verbose, int force); + +extern int Build(char *mddev, int mdfd, int chunk, int level, + int raiddisks, + mddev_dev_t devlist); + + +extern int Create(char *mddev, int mdfd, + int chunk, int level, int layout, int size, int raiddisks, int sparedisks, + int subdevs, mddev_dev_t devlist, + int runstop, int verbose, int force); + +extern int Detail(char *dev, int brief); +extern int Examine(mddev_dev_t devlist, int brief, char *conffile); +extern int Monitor(mddev_dev_t devlist, + char *mailaddr, char *alert_cmd, + int period, + char *config); + +extern int Kill(char *dev, int force); + +extern int md_get_version(int fd); +extern int get_linux_version(); +extern int parse_uuid(char *str, int uuid[4]); +extern int check_ext2(int fd, char *name); +extern int check_reiser(int fd, char *name); +extern int check_raid(int fd, char *name); + +extern mddev_ident_t conf_get_ident(char *, char*); +extern mddev_dev_t conf_get_devs(char *); + +extern char *human_size(long kbytes); diff --git a/mdadm.man b/mdadm.man new file mode 100644 index 0000000..b12de95 --- /dev/null +++ b/mdadm.man @@ -0,0 +1,476 @@ +mdadm(8) mdadm(8) + + + +NNAAMMEE + mdadm - manage MD devices _a_k_a Linux Software Raid. + + +SSYYNNOOPPSSIISS + mmddaaddmm _[_m_o_d_e_] _<_r_a_i_d_d_e_v_i_c_e_> _[_o_p_t_i_o_n_s_] _<_s_u_b_d_e_v_i_c_e_s_> + + +DDEESSCCRRIIPPTTIIOONN + RAID devices are virtual devices created from two or more + real block devices. This allows multiple devices (typi- + cally disk drives or partitions there-of) to be combined + into a single device to hold (for example) a single + filesystem. Some RAID levels included redundancy and so + can survive some degree of device failure. + + Linux Software RAID devices are implemented through the md + (Multiple Devices) device driver. + + Currently, Linux supports LLIINNEEAARR md devices, RRAAIIDD00 (strip- + ing), RRAAIIDD11 (mirroring), RRAAIIDD44 and RRAAIIDD55.. + + Recent kernels (2002) also support a mode known as MMUULLTTII-- + PPAATTHH. mmddaaddmm does not support MULTIPATH as yet. + + mmddaaddmm is a program that can be used to create and manage + MD devices. As such it provides a similar set of func- + tionality to the rraaiiddttoooollss packages. The key differences + between mmddaaddmm and rraaiiddttoooollss are: + + +o mmddaaddmm is a single program and not a collection of pro- + grams. + + +o mmddaaddmm can perform (almost) all of its functions with- + out having a configuration file. Also mdadm helps + with management of the configuration file. + + +o mmddaaddmm can provide information about your arrays + (through Detail and Examine) that rraaiiddttoooollss cannot. + + +o rraaiiddttoooollss can manage MULTIPATH devices which mmddaaddmm + cannot yet manage. + + +MMOODDEESS + mdadm has 7 major modes of operation: + + AAsssseemmbbllee + Assemble the parts of a previously created array + into an active array. Components can be explicitly + given or can be searched for. mmddaaddmm checks that + the components do form a bona fide array, and can, + on request, fiddle superblock information so as to + assemble a faulty array. + + + BBuuiilldd Build a legacy array without per-device + superblocks. + + + CCrreeaattee Create a new array with per-device superblocks. + + + DDeettaaiill Display the details of a given md device. Details + include the RAID level, the number of devices, + which ones are faulty (if any), and the array UUID. + + + EExxaammiinnee + Examine a device to see if it is part of an md + array, and print out the details of that array. + This mode can also be used to examine a large num- + ber of devices and to print out a summary of the + arrays found in a format suitable for the + mmddaaddmm..ccoonnff configuration file. + + + FFoollllooww oorr MMoonniittoorr + Monitor one or more md devices and act on any state + changes. + + + MMaannaaggee This is for odd bits an pieces like hotadd, + hotremove, setfaulty, stop, readonly, readwrite. + + +OOPPTTIIOONNSS + Available options are: + + + --AA, ----aasssseemmbbllee + Assemble an existing array. + + + --BB, ----bbuuiilldd + Build a legacy array without superblocks. + + + --CC, ----ccrreeaattee + Create a new array. + + + --DD, ----ddeettaaiill + Print detail of one or more md devices. + + + --EE, ----eexxaammiinnee + Print content of md superblock on device(s). + + + --FF, ----ffoollllooww, ----mmoonniittoorr + Select MMoonniittoorr mode. + + + --hh, ----hheellpp + Display help message or, after above option, mode + specific help message. + + + --VV, ----vveerrssiioonn + Print version information for mdadm. + + + --vv, ----vveerrbboossee + Be more verbose about what is happening. + + + --bb, ----bbrriieeff + Be less verbose. This is used with ----ddeettaaiill and + ----eexxaammiinnee. + + +FFoorr ccrreeaattee oorr bbuuiilldd:: + --cc, ----cchhuunnkk== + Specify chunk size of kibibytes. The default is + 64. + + + ----rroouunnddiinngg== + Specify rounding factor for linear array (==chunk + size) + + + --ll, ----lleevveell== + Set raid level. Options are: linear, raid0, 0, + stripe, raid1, 1, mirror, raid5, 4, raid5, 5. + Obviously some of these are synonymous. Only the + first 4 are valid when Building. + + + --pp, ----ppaarriittyy== + Set raid5 parity algorithm. Options are: + {left,right}-{,a}symmetric, la, ra, ls, rs. The + default is left-symmetric. + + + ----llaayyoouutt== + same as --parity + + + --nn, ----rraaiidd--ddiisskkss== + number of active devices in array. + + + --xx, ----ssppaarree--ddiisskkss== + number of spare (eXtra) disks in initial array. + Spares can be added and removed later. + + + --zz, ----ssiizzee== + Amount (in Kibibytes) of space to use from each + drive in RAID1/4/5. This must be a multiple of the + chunk size, and must leave about 128Kb of space at + the end of the drive for the RAID superblock. If + this is not specified (as it normally is not) the + smallest drive (or partition) sets the size, though + if there is a variance among the drives of greater + than 1%, a warning is issued. + + +FFoorr aasssseemmbbllee:: + --uu, ----uuuuiidd== + uuid of array to assemble. Devices which don't have + this uuid are excluded + + + --mm, ----ssuuppeerr--mmiinnoorr== + Minor number of device that array was created for. + Devices which don't have this minor number are + excluded. If you create an array as /dev/md1, then + all superblock will contain the minor number 1, + even if the array is later assembled as /dev/md2. + + + --cc, ----ccoonnffiigg== + config file. Default is //eettcc//mmddaaddmm..ccoonnff. + + + --ss, ----ssccaann + scan config file for missing information + + + --ff, ----ffoorrccee + Assemble the array even if some superblocks appear + out-of-date + + + --RR, ----rruunn + Attempt to start the array even if fewer drives + were given than are needed for a full array. Nor- + mally if not all drives are found and ----ssccaann is not + used, then the array will be assembled but not + started. With ----rruunn an attempt will be made to + start it anyway. + + +GGeenneerraall mmaannaaggeemmeenntt + --aa, ----aadddd + hotadd listed devices. + + + --rr, ----rreemmoovvee + remove listed devices. The must not be active. + i.e. they should be failed or spare devices. + + + --ff, ----ffaaiill + mark listed devices as faulty. + + + ----sseett--ffaauullttyy + same as --fail. + + + --RR, ----rruunn + start a partially built array. + + + --SS, ----ssttoopp + deactivate array, releasing all resources. + + + --oo, ----rreeaaddoonnllyy + mark array as readonly. + + + --ww, ----rreeaaddwwrriittee + mark array as readwrite. + + + +AASSSSEEMMBBLLYY MMOODDEE + Usage: mmddaaddmm ----aasssseemmbbllee _d_e_v_i_c_e _o_p_t_i_o_n_s_._._. + + Usage: mmddaaddmm ----aasssseemmbbllee ----ssccaann _o_p_t_i_o_n_s_._._. + + + This usage assembles one or more raid arrays from pre- + existing components. For each array, mdadm needs to know + the md device, the identity of the array, and a number of + sub devices. These can be found in a number of ways. + + The md device is either given before ----ssccaann or is found + from the config file. In the latter case, multiple md + devices can be started with a single mdadm command. + + The identity can be given with the ----uuuuiidd option, with the + ----ssuuppeerr--mmiinnoorr option, can be found in in the config file, + or will be taken from the super block on the first subde- + vice listed on the command line. + + Devices can be given on the ----aasssseemmbbllee command line or + from the config file. Only devices which have an md + superblock which contains the right identity will be con- + sidered for any device. + + The config file is only used if explicitly named with + ----ccoonnffiigg or requested with ----ssccaann.. In the later case, + //eettcc//mmddaaddmm..ccoonnff is used. + + If ----ssccaann is not given, then the config file will only be + used to find the identity of md arrays. + + Normally the array will be started after it is assembled. + However is ----ssccaann is not given and insufficient drives + were lists to start a complete (non-degraded) array, then + the array is not started (to guard against usage errors). + To insist that the array be started in this case (as may + work for RAID1 or RAID5), give the ----rruunn flag. + + + +BBUUIILLDD MMOODDEE + Usage: mmddaaddmm ----bbuuiilldd _d_e_v_i_c_e ----cchhuunnkk==_X ----lleevveell==_Y ----rraaiidd-- + ddiisskkss==_Z _d_e_v_i_c_e_s + + + This usage is similar to ----ccrreeaattee. The difference is that + it creates a legacy array without a superblock. With these + arrays there is no difference between initially creating + the array and subsequently assembling the array, except + that hopefully there is useful data there in the second + case. + + The level may only be 0, raid0, or linear. All devices + must be listed and the array will be started once com- + plete. + + +CCRREEAATTEE MMOODDEE + Usage: mmddaaddmm ----ccrreeaattee _d_e_v_i_c_e ----cchhuunnkk==_X ----lleevveell==_Y + ----rraaiidd--ddiisskkss==_Z _d_e_v_i_c_e_s + + + This usage will initialise a new md array, associate some + devices with it, and activate the array. + + As devices are added, they are checked to see if they con- + tain raid superblocks or filesystems. They are also check + to see if the variance in device size exceeds 1%. + + If any discrepancy is found, the array will not automati- + cally be run, though the presence of a ----rruunn can override + this caution. + + + The General Management options that are valid with --cre- + ate are: + + ----rruunn insist of running the array even if some devices + look like they might be in use. + + + ----rreeaaddoonnllyy + start the array readonly - not supported yet. + + +DDEETTAAIILL MMOODDEE + Usage: mmddaaddmm ----ddeettaaiill [----bbrriieeff] _d_e_v_i_c_e _._._. + + + This usage sill print out the details of the given array + including a list of component devices. To determine names + for the devices, mmddaaddmm searches //ddeevv for device files with + the right major and minor numbers. + + With ----bbrriieeff mmddaaddmm prints a single line that identifies + the level, number of disks, and UUID of the array. This + line is suitable for inclusion in //eettcc//mmddaaddmm..ccoonnff. + + +EEXXAAMMIINNEE MMOODDEE + Usage: mmddaaddmm ----eexxaammiinnee [----ssccaann] [----bbrriieeff] _d_e_v_i_c_e _._._. + + This usage will examine some block devices to see if that + have a valid RAID superblock on them. The information in + each valid raid superblock will be printed. + + If ----ssccaann is used, the no devices should be listed, and + the complete set of devices identified in the configura- + tion file are checked. ----ssccaann implies ----bbrriieeff but this + implication can be countered by specifying ----vveerrbboossee. + + With ----bbrriieeff mmddaaddmm will output an config file entry of + each distinct array that was found. This entry will list + the UUID, the raid level, and a list of the individual + devices on which a superblock for that array was found. + This output will by syntactically suitable for inclusion + in the configuration file, but should NNOOTT be used blindly. + Often the array description that you want in the configu- + ration file is much less specific than that given by mmddaaddmm + --BBss. For example, you normally do not want to list the + devices, particularly if they are SCSI devices. + + + +FFIILLEESS + //pprroocc//mmddssttaatt + If you're using the //pprroocc filesystem, //pprroocc//mmddssttaatt gives + you informations about md devices status. This file is + not currently used by mmddaaddmm. + + + //eettcc//mmddaaddmm..ccoonnff + The config file is line oriented with, as usual, blank + lines and lines beginning with a hash (or pound sign or + sharp or number sign, whichever you like to call it) + ignored. Lines that start with a blank are treated as + continuations of the previous line (I don't like trailing + slashes). + + Each line contains a sequence of space-separated words, + the first of which identified the type of line. Keywords + are case-insensitive, and the first work on a line can be + abbreviated to 3 letters. + + There are two types of lines. ARRAY and DEVICE. + + The DEVICE lines usually come first. All remaining words + on the line are treated as names of devices, possibly con- + taining wild cards (see _g_l_o_b(7)). These list all the + devices that mmddaaddmm is allowed to scan when looking for + devices with RAID superblocks. Each line can contain mul- + tiple device names, and there can be multiple DEVICE + lines. For example: + + DEVICE /dev/hda* /dev/hdc* + DEV /dev/sd* + DEVICE /dev/discs/disc*/disc + + The ARRAY lines identify actual arrays. The second word + on the line should be the name of the device where the + array is normally assembled, such as /dev/md1. Subsequent + words identify the array. If multiple identities are + given, then the array much match ALL identities to be con- + sidered a match. Each identity word has a tag, and equals + sign, and some value. The options are: + + + uuuuiidd== The value should be a 128 bit uuid in hexadecimal, + with punctuation interspersed if desired. This + must match the uuid stored in the superblock. + + ssuuppeerr--mmiinnoorr== + The value is an integer which indicates the minor + number that was stored in the superblock when the + array was created. When an array is created as + /dev/mdX, then the minor number X is stored. + + ddeevviicceess== + The value is a comma separated list of device + names. Precisely these devices will be used to + assemble the array. Note that the devices listed + there must also be listed on a DEVICE line. + + lleevveell== The value is a raid level. This is normally used + to identify an array, but is supported so that the + output of mmddaaddmm ----eexxaammiinnee ----ssccaann can be use + directly in the configuration file. + + ddiisskkss== The value is the number of disks in a complete + active array. As with lleevveell== this is mainly for + compatibility with the output of mmddaaddmm ----eexxaammiinnee + ----ssccaann. + + +TTOODDOO + Finish and document Follow mode. + + +SSEEEE AALLSSOO + For information on the various levels of RAID, check out: + + + http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/ + + for new releases of the RAID driver check out: + + + ftp://ftp.kernel.org/pub/linux/kernel/peo- + ple/mingo/raid-patches + + or + + http://www.cse.unsw.edu.au/~neilb/patches/linux- + stable/ + + _r_a_i_d_t_a_b(5), _r_a_i_d_0_r_u_n(8), _r_a_i_d_s_t_o_p(8), _m_k_r_a_i_d(8) + + + + mdadm(8) diff --git a/mdctl.8 b/mdctl.8 deleted file mode 100644 index 153d7b5..0000000 --- a/mdctl.8 +++ /dev/null @@ -1,575 +0,0 @@ -.\" -*- nroff -*- -.TH mdctl 8 -.SH NAME -mdctl \- manage MD devices -.I aka -Linux Software Raid. - -.SH SYNOPSIS - -.BI mdctl " [mode] [options] " - -.SH DESCRIPTION -RAID devices are virtual devices created from two or more -real block devices. This allows multiple devices (typically disk -drives or partitions there-of) to be combined into a single device to -hold (for example) a single filesystem. -Some RAID levels included redundancy and so can survive some degree of -device failure. - -Linux Software RAID devices are implemented through the md (Multiple Devices) device driver. - -Currently, Linux supports -.B LINEAR -md devices, -.B RAID0 -(striping), -.B RAID1 -(mirroring), -.B RAID4 -and -.B RAID5. - -Recent kernels (2002) also support a mode known as -.BR MULTIPATH . -.B mdctl -does not support MULTIPATH as yet. - -.B mdctl -is a program that can be used to create and manage MD devices. As -such it provides a similar set of functionality to the -.B raidtools -packages. -The key differences between -.B mdctl -and -.B raidtools -are: -.IP \(bu 4 -.B mdctl -is a single program and not a collection of programs. -.IP \(bu 4 -.B mdctl -can perform (almost) all of its functions without having a -configuration file. Also mdctl helps with management of the configuration -file. -.IP \(bu 4 -.B mdctl -can provide information about your arrays (through Detail and Examine) -that -.B raidtools -cannot. -.IP \(bu 4 -.B raidtools -can manage MULTIPATH devices which -.B mdctl -cannot yet manage. - -.SH MODES -mdctl has 7 major modes of operation: -.TP -.B Assemble -Assemble the parts of a previously created -array into an active array. Components can be explicitly given -or can be searched for. -.B mdctl -checks that the components -do form a bona fide array, and can, on request, fiddle superblock -information so as to assemble a faulty array. - -.TP -.B Build -Build a legacy array without per-device superblocks. - -.TP -.B Create -Create a new array with per-device superblocks. -'''It can progress -'''in several step create-add-add-run or it can all happen with one command. - -.TP -.B Detail -Display the details of a given md device. Details include the RAID -level, the number of devices, which ones are faulty (if any), and the -array UUID. - -.TP -.B Examine -Examine a device to see if it is part of an md array, and print out -the details of that array. -This mode can also be used to examine a large number of devices and to -print out a summary of the arrays found in a format suitable for the -.B mdctl.conf -configuration file. - -.TP -.B "Follow or Monitor" -Monitor one or more md devices and act on any state changes. - -.TP -.B Manage -This is for odd bits an pieces like hotadd, hotremove, setfaulty, stop, -readonly, readwrite. -'''If an array is only partially setup by the -'''Create or Assemble commands, subsequent Manage commands can finish the -'''job. - -.SH OPTIONS - -Available options are: - -.TP -.BR -A ", " --assemble -Assemble an existing array. - -.TP -.BR -B ", " --build -Build a legacy array without superblocks. - -.TP -.BR -C ", " --create -Create a new array. - -.TP -.BR -D ", " --detail -Print detail of one or more md devices. - -.TP -.BR -E ", " --examine -Print content of md superblock on device(s). - -.TP -.BR -F ", " --follow ", " --monitor -Select -.B Monitor -mode. - -.TP -.BR -h ", " --help -Display help message or, after above option, mode specific help message. - -.TP -.BR -V ", " --version -Print version information for mdctl. - -.TP -.BR -v ", " --verbose -Be more verbose about what is happening. - -.TP -.BR -b ", " --brief -Be less verbose. This is used with -.B --detail -and -.BR --examine . - -.SH For create or build: - -.TP -.BR -c ", " --chunk= -Specify chunk size of kibibytes. The default is 64. - -.TP -.BR --rounding= -Specify rounding factor for linear array (==chunk size) - -.TP -.BR -l ", " --level= -Set raid level. Options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid5, 4, -raid5, 5. Obviously some of these are synonymous. -Only the first 4 are valid when Building. - -.TP -.BR -p ", " --parity= -Set raid5 parity algorithm. Options are: -{left,right}-{,a}symmetric, la, ra, ls, rs. The default is left-symmetric. - -.TP -.BR --layout= -same as --parity - -.TP -.BR -n ", " --raid-disks= -number of active devices in array. - -.TP -.BR -x ", " --spare-disks= -number of spare (eXtra) disks in initial array. Spares can be added -and removed later. - -.TP -.BR -z ", " --size= -Amount (in Kibibytes) of space to use from each drive in RAID1/4/5. -This must be a multiple of the chunk size, and must leave about 128Kb -of space at the end of the drive for the RAID superblock. -If this is not specified -(as it normally is not) the smallest drive (or partition) sets the -size, though if there is a variance among the drives of greater than 1%, a warning is -issued. - -.SH For assemble: - -.TP -.BR -u ", " --uuid= -uuid of array to assemble. Devices which don't have this uuid are -excluded - -.TP -.BR -m ", " --super-minor= -Minor number of device that array was created for. Devices which -don't have this minor number are excluded. If you create an array as -/dev/md1, then all superblock will contain the minor number 1, even if -the array is later assembled as /dev/md2. - -.TP -.BR -c ", " --config= -config file. Default is -.BR /etc/mdctl.conf . - -.TP -.BR -s ", " --scan -scan config file for missing information - -.TP -.BR -f ", " --force -Assemble the array even if some superblocks appear out-of-date - -.TP -.BR -R ", " --run -Attempt to start the array even if fewer drives were given than are -needed for a full array. Normally if not all drives are found and -.B --scan -is not used, then the array will be assembled but not started. -With -.B --run -an attempt will be made to start it anyway. - -.SH General management - -.TP -.BR -a ", " --add -'''add, or -hotadd listed devices. - -.TP -.BR -r ", " --remove -remove listed devices. The must not be active. i.e. they should -be failed or spare devices. - -.TP -.BR -f ", " --fail -mark listed devices as faulty. - -.TP -.BR --set-faulty -same as --fail. - -.TP -.BR -R ", " --run -start a partially built array. - -.TP -.BR -S ", " --stop -deactivate array, releasing all resources. - -.TP -.BR -o ", " --readonly -mark array as readonly. - -.TP -.BR -w ", " --readwrite -mark array as readwrite. - - -.SH ASSEMBLY MODE - -.HP 12 -Usage: -.B mdctl --assemble -.I device options... -.HP 12 -Usage: -.B mdctl --assemble --scan -.I options... - -.PP -This usage assembles one or more raid arrays from pre-existing components. -For each array, mdctl needs to know the md device, the identity of the -array, and a number of sub devices. These can be found in a number of ways. - -The md device is either given before -.B --scan -or is found from the config file. In the latter case, multiple md devices -can be started with a single mdctl command. - -The identity can be given with the -.B --uuid -option, with the -.B --super-minor -option, can be found in in the config file, or will be taken from the -super block on the first subdevice listed on the command line. - -Devices can be given on the -.B --assemble -command line or from the config file. Only devices which have an md -superblock which contains the right identity will be considered for any device. - -The config file is only used if explicitly named with -.B --config -or requested with -.B --scan. -In the later case, -.B /etc/mdctl.conf -is used. - -If -.B --scan -is not given, then the config file will only be used to find the -identity of md arrays. - -Normally the array will be started after it is assembled. However is -.B --scan -is not given and insufficient drives were lists to start a complete -(non-degraded) array, then the array is not started (to guard against -usage errors). To insist that the array be started in this case (as -may work for RAID1 or RAID5), give the -.B --run -flag. - - -.SH BUILD MODE - -.HP 12 -Usage: -.B mdctl --build -.I device -.BI --chunk= X -.BI --level= Y -.BI --raid-disks= Z -.I devices - -.PP -This usage is similar to -.BR --create . -The difference is that it creates a legacy array without a superblock. With -these arrays there is no difference between initially creating the array and -subsequently assembling the array, except that hopefully there is useful -data there in the second case. - -The level may only be 0, raid0, or linear. All devices must be listed -and the array will be started once complete. - -.SH CREATE MODE - -.HP 12 -Usage: -.B mdctl --create -.I device -.BI --chunk= X -.BI --level= Y -.br -.BI --raid-disks= Z -.I devices - -.PP -This usage will initialise a new md array, associate some devices with -it, and activate the array. - -As devices are added, they are checked to see if they contain raid -superblocks or filesystems. They are also check to see if the variance in -device size exceeds 1%. - -If any discrepancy is found, the array will not automatically be run, though -the presence of a -.B --run -can override this caution. - -'''If the -'''.B --size -'''option is given, it is not necessary to list any subdevices in this command. -'''They can be added later, before a -'''.B --run. -'''If no -'''.B --size -'''is given, the apparent size of the smallest drive given is used. - -The General Management options that are valid with --create are: -.TP -.B --run -insist of running the array even if some devices look like they might -be in use. - -.TP -.B --readonly -start the array readonly - not supported yet. - -.SH DETAIL MODE -.HP 12 -Usage: -.B mdctl --detail -.RB [ --brief ] -.I device ... -.PP - -This usage sill print out the details of the given array including a -list of component devices. To determine names for the devices, -.B mdctl -searches -.B /dev -for device files with the right major and minor numbers. - -With -.B --brief -.B mdctl -prints a single line that identifies the level, number of disks, and -UUID of the array. This line is suitable for inclusion in -.BR /etc/mdctl.conf . - -.SH EXAMINE MODE -.HP 12 -Usage: -.B mdctl --examine -.RB [ --scan ] -.RB [ --brief ] -.I device ... -.PP -This usage will examine some block devices to see if that have a valid -RAID superblock on them. The information in each valid raid -superblock will be printed. - -If -.B --scan -is used, the no devices should be listed, and the complete set of -devices identified in the configuration file are checked. -.B --scan -implies -.B --brief -but this implication can be countered by specifying -.BR --verbose . - -With -.B --brief -.B mdctl -will output an config file entry of each distinct array that was -found. This entry will list the UUID, the raid level, and a list of -the individual devices on which a superblock for that array was found. -This output will by syntactically suitable for inclusion in the -configuration file, but should -.B NOT -be used blindly. Often the array description that you want in the -configuration file is much less specific than that given by -.BR "mdctl -Bs" . -For example, you normally do not want to list the devices, -particularly if they are SCSI devices. - -'''.SH BUGS -'''no known bugs. - -.SH FILES - -.SS /proc/mdstat - -If you're using the -.B /proc -filesystem, -.B /proc/mdstat -gives you informations about md devices status. -This file is not currently used by -.BR mdctl . - -.SS /etc/mdctl.conf - -The config file is line oriented with, as usual, blank lines and lines -beginning with a hash (or pound sign or sharp or number sign, -whichever you like to call it) ignored. -Lines that start with a blank are treated as continuations of the -previous line (I don't like trailing slashes). - -Each line contains a sequence of space-separated words, the first of -which identified the type of line. Keywords are case-insensitive, and -the first work on a line can be abbreviated to 3 letters. - -There are two types of lines. ARRAY and DEVICE. - -The DEVICE lines usually come first. All remaining words on the line -are treated as names of devices, possibly containing wild cards (see -.IR glob (7)). -These list all the devices that -.B mdctl -is allowed to scan -when looking for devices with RAID superblocks. -Each line can contain multiple device names, and there can be multiple -DEVICE lines. For example: -.IP -DEVICE /dev/hda* /dev/hdc* -.br -DEV /dev/sd* -.br -DEVICE /dev/discs/disc*/disc -.PP -The ARRAY lines identify actual arrays. The second word on the line -should be the name of the device where the array is normally -assembled, such as /dev/md1. -Subsequent words identify the array. If multiple identities are given, -then the array much match ALL identities to be considered a match. -Each identity word has a tag, and equals sign, and some value. -The options are: - -.TP -.B uuid= -The value should be a 128 bit uuid in hexadecimal, with punctuation -interspersed if desired. This must match the uuid stored in the -superblock. -.TP -.B super-minor= -The value is an integer which indicates the minor number that was -stored in the superblock when the array was created. When an array is -created as /dev/mdX, then the minor number X is stored. -.TP -.B devices= -The value is a comma separated list of device names. Precisely these -devices will be used to assemble the array. Note that the devices -listed there must also be listed on a DEVICE line. -.TP -.B level= -The value is a raid level. This is normally used to identify an -array, but is supported so that the output of -.B "mdctl --examine --scan" -can be use directly in the configuration file. -.TP -.B disks= -The value is the number of disks in a complete active array. As with -.B level= -this is mainly for compatibility with the output of -.BR "mdctl --examine --scan" . - -.SH TODO - -Finish and document Follow mode. - -.SH SEE ALSO -For information on the various levels of -RAID, check out: - -.IP -.UR http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/ -http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/ -.UE -.PP -for new releases of the RAID driver check out: - -.IP -.UR ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches -ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches -.UE -.PP -or -.IP -.UR http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/ -http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/ -.URk -.PP -.IR raidtab (5), -.IR raid0run (8), -.IR raidstop (8), -.IR mkraid (8) diff --git a/mdctl.c b/mdctl.c deleted file mode 100644 index 054fbc4..0000000 --- a/mdctl.c +++ /dev/null @@ -1,540 +0,0 @@ -/* - * mdctl - manage Linux "md" devices aka RAID arrays. - * - * Copyright (C) 2001-2002 Neil Brown - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Neil Brown - * Email: - * Paper: Neil Brown - * School of Computer Science and Engineering - * The University of New South Wales - * Sydney, 2052 - * Australia - */ - -#include "mdctl.h" -#include "md_p.h" - -int open_mddev(char *dev) -{ - int mdfd = open(dev, O_RDWR, 0); - if (mdfd < 0) - fprintf(stderr,Name ": error opening %s: %s\n", - dev, strerror(errno)); - else if (md_get_version(mdfd) <= 0) { - fprintf(stderr, Name ": %s does not appear to be an md device\n", - dev); - close(mdfd); - mdfd = -1; - } - return mdfd; -} - - - -int main(int argc, char *argv[]) -{ - char mode = '\0'; - int opt; - char *help_text; - char *c; - int rv; - int i; - - int chunk = 0; - int size = 0; - int level = -10; - int layout = -1; - int raiddisks = 0; - int sparedisks = 0; - struct mddev_ident_s ident; - char *configfile = NULL; - char *cp; - int scan = 0; - char devmode = 0; - int runstop = 0; - int readonly = 0; - mddev_dev_t devlist = NULL; - mddev_dev_t *devlistend = & devlist; - mddev_dev_t dv; - int devs_found = 0; - int verbose = 0; - int brief = 0; - int force = 0; - - char *mailaddr = NULL; - char *program = NULL; - int delay = 0; - - int mdfd = -1; - - ident.uuid_set=0; - ident.level = -10; - ident.raid_disks = -1; - ident.super_minor= -1; - ident.devices=0; - - while ((opt=getopt_long(argc, argv, - short_options, long_options, - NULL)) != -1) { - - switch(opt) { - case '@': /* just incase they say --manage */ - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - /* setting mode - only once */ - if (mode) { - fprintf(stderr, Name ": --%s/-%c not allowed, mode already set to %s\n", - long_options[opt-'A'+1].name, - long_options[opt-'A'+1].val, - long_options[mode-'A'+1].name); - exit(2); - } - mode = opt; - continue; - - case 'h': - help_text = Help; - switch (mode) { - case 'C': help_text = Help_create; break; - case 'B': help_text = Help_build; break; - case 'A': help_text = Help_assemble; break; - } - fputs(help_text,stderr); - exit(0); - - case 'V': - fputs(Version, stderr); - exit(0); - - case 'v': verbose = 1; - continue; - - case 'b': brief = 1; - continue; - - case 1: /* an undecorated option - must be a device name. - * Depending on mode, it could be that: - * All devices listed are "md" devices : --Detail, -As - * No devices are "md" devices : --Examine - * First device is "md", others are component: -A,-B,-C - * Only accept on device before mode is determined. - * If mode is @, then require devmode for other devices. - */ - if (devs_found > 0 && !mode ) { - fprintf(stderr, Name ": Must give mode flag before second device name at %s\n", optarg); - exit(2); - } - if (devs_found > 0 && mode == '@' && !devmode) { - fprintf(stderr, Name ": Must give on of -a/-r/-f for subsequent devices at %s\n", optarg); - exit(2); - } - dv = malloc(sizeof(*dv)); - if (dv == NULL) { - fprintf(stderr, Name ": malloc failed\n"); - exit(3); - } - dv->devname = optarg; - dv->disposition = devmode; - dv->next = NULL; - *devlistend = dv; - devlistend = &dv->next; - - devs_found++; - continue; - - case ':': - case '?': - fputs(Usage, stderr); - exit(2); - default: - /* force mode setting - @==manage if nothing else */ - if (!mode) mode = '@'; - } - - /* We've got a mode, and opt is now something else which - * could depend on the mode */ -#define O(a,b) ((a<<8)|b) - switch (O(mode,opt)) { - case O('C','c'): - case O('B','c'): /* chunk or rounding */ - if (chunk) { - fprintf(stderr, Name ": chunk/rounding may only be specified once. " - "Second value is %s.\n", optarg); - exit(2); - } - chunk = strtol(optarg, &c, 10); - if (!optarg[0] || *c || chunk<4 || ((chunk-1)&chunk)) { - fprintf(stderr, Name ": invalid chunk/rounding value: %s\n", - optarg); - exit(2); - } - continue; - - case O('C','z'): /* size */ - if (size) { - fprintf(stderr, Name ": size may only be specified once. " - "Second value is %s.\n", optarg); - exit(2); - } - size = strtol(optarg, &c, 10); - if (!optarg[0] || *c || size < 4) { - fprintf(stderr, Name ": invalid size: %s\n", - optarg); - exit(2); - } - continue; - - case O('C','l'): - case O('B','l'): /* set raid level*/ - if (level != -10) { - fprintf(stderr, Name ": raid level may only be set once. " - "Second value is %s.\n", optarg); - exit(2); - } - level = map_name(pers, optarg); - if (level == -10) { - fprintf(stderr, Name ": invalid raid level: %s\n", - optarg); - exit(2); - } - if (level > 0 && mode == 'B') { - fprintf(stderr, Name ": Raid level %s not permitted with --build.\n", - optarg); - exit(2); - } - if (sparedisks > 0 && level < 1) { - fprintf(stderr, Name ": raid level %s is incompatible with spare-disks setting.\n", - optarg); - exit(2); - } - ident.level = level; - continue; - - case O('C','p'): /* raid5 layout */ - if (layout >= 0) { - fprintf(stderr,Name ": layout may only be sent once. " - "Second value was %s\n", optarg); - exit(2); - } - switch(level) { - default: - fprintf(stderr, Name ": layout now meaningful for %s arrays.\n", - map_num(pers, level)); - exit(2); - case -10: - fprintf(stderr, Name ": raid level must be given before layout.\n"); - exit(2); - - case 5: - layout = map_name(r5layout, optarg); - if (layout==-10) { - fprintf(stderr, Name ": layout %s not understood for raid5.\n", - optarg); - exit(2); - } - break; - } - continue; - - case O('C','n'): - case O('B','n'): /* number of raid disks */ - if (raiddisks) { - fprintf(stderr, Name ": raid-disks set twice: %d and %s\n", - raiddisks, optarg); - exit(2); - } - raiddisks = strtol(optarg, &c, 10); - if (!optarg[0] || *c || raiddisks<=0 || raiddisks > MD_SB_DISKS) { - fprintf(stderr, Name ": invalid number of raid disks: %s\n", - optarg); - exit(2); - } - ident.raid_disks = raiddisks; - continue; - - case O('C','x'): /* number of spare (eXtra) discs */ - if (sparedisks) { - fprintf(stderr,Name ": spare-disks set twice: %d and %s\n", - sparedisks, optarg); - exit(2); - } - if (level > -10 && level < 1) { - fprintf(stderr, Name ": spare-disks setting is incompatible with raid level %d\n", - level); - exit(2); - } - sparedisks = strtol(optarg, &c, 10); - if (!optarg[0] || *c || sparedisks < 0 || sparedisks > MD_SB_DISKS - raiddisks) { - fprintf(stderr, Name ": invalid number of spare disks: %s\n", - optarg); - exit(2); - } - continue; - case O('C','f'): /* force honouring of device list */ - force=1; - continue; - - /* now for the Assemble options */ - case O('A','f'): /* force assembly */ - force = 1; - continue; - case O('A','u'): /* uuid of array */ - if (ident.uuid_set) { - fprintf(stderr, Name ": uuid cannot be set twice. " - "Second value %s.\n", optarg); - exit(2); - } - if (parse_uuid(optarg, ident.uuid)) - ident.uuid_set = 1; - else { - fprintf(stderr,Name ": Bad uuid: %s\n", optarg); - exit(2); - } - continue; - - case O('A','m'): /* super-minor for array */ - if (ident.super_minor >= 0) { - fprintf(stderr, Name ": super-minor cannot be set twice. " - "Second value: %s.\n", optarg); - exit(2); - } - ident.super_minor = strtoul(optarg, &cp, 10); - if (!optarg[0] || *cp) { - fprintf(stderr, Name ": Bad super-minor number: %s.\n", optarg); - exit(2); - } - continue; - - case O('A','c'): /* config file */ - case O('F','c'): - if (configfile) { - fprintf(stderr, Name ": configfile cannot be set twice. " - "Second value is %s.\n", optarg); - exit(2); - } - configfile = optarg; - /* FIXME possibly check that config file exists. Even parse it */ - continue; - case O('A','s'): /* scan */ - case O('E','s'): - scan = 1; - continue; - - case O('F','m'): /* mail address */ - if (mailaddr) - fprintf(stderr, Name ": only specify one mailaddress. %s ignored.\n", - optarg); - else - mailaddr = optarg; - continue; - - case O('F','p'): /* alert program */ - if (program) - fprintf(stderr, Name ": only specify one alter program. %s ignored.\n", - optarg); - else - program = optarg; - continue; - - case O('F','d'): /* delay in seconds */ - if (delay) - fprintf(stderr, Name ": only specify delay once. %s ignored.\n", - optarg); - else { - delay = strtol(optarg, &c, 10); - if (!optarg[0] || *c || delay<1) { - fprintf(stderr, Name ": invalid delay: %s\n", - optarg); - exit(2); - } - } - continue; - - - /* now the general management options. Some are applicable - * to other modes. None have arguments. - */ - case O('@','a'): - case O('C','a'): - case O('B','a'): - case O('A','a'): /* add a drive */ - devmode = 'a'; - continue; - case O('@','r'): /* remove a drive */ - devmode = 'r'; - continue; - case O('@','f'): /* set faulty */ - devmode = 'f'; - continue; - case O('@','R'): - case O('A','R'): - case O('B','R'): - case O('C','R'): /* Run the array */ - if (runstop < 0) { - fprintf(stderr, Name ": Cannot both Stop and Run an array\n"); - exit(2); - } - runstop = 1; - continue; - case O('@','S'): - if (runstop > 0) { - fprintf(stderr, Name ": Cannot both Run and Stop an array\n"); - exit(2); - } - runstop = -1; - continue; - - case O('@','o'): - if (readonly < 0) { - fprintf(stderr, Name ": Cannot have both readonly and readwrite\n"); - exit(2); - } - readonly = 1; - continue; - case O('@','w'): - if (readonly > 0) { - fprintf(stderr, "mkdctl: Cannot have both readwrite and readonly.\n"); - exit(2); - } - readonly = -1; - continue; - } - /* We have now processed all the valid options. Anything else is - * an error - */ - fprintf(stderr, Name ": option %c not valid in mode %c\n", - opt, mode); - exit(2); - - } - - if (!mode) { - fputs(Usage, stderr); - exit(2); - } - /* Ok, got the option parsing out of the way - * hopefully it's mostly right but there might be some stuff - * missing - * - * That is mosty checked in ther per-mode stuff but... - * - * For @,B,C and A without -s, the first device listed must be an md device - * we check that here and open it. - */ - - if (mode=='@' || mode == 'B' || mode == 'C' || (mode == 'A' && ! scan)) { - if (devs_found < 1) { - fprintf(stderr, Name ": an md device must be given in this mode\n"); - exit(2); - } - mdfd = open_mddev(devlist->devname); - if (mdfd < 0) - exit(1); - } - - - rv = 0; - switch(mode) { - case '@':/* Management */ - /* readonly, add/remove, readwrite, runstop */ - if (readonly>0) - rv = Manage_ro(devlist->devname, mdfd, readonly); - if (!rv && devs_found>1) - rv = Manage_subdevs(devlist->devname, mdfd, - devlist->next); - if (!rv && readonly < 0) - rv = Manage_ro(devlist->devname, mdfd, readonly); - if (!rv && runstop) - rv = Manage_runstop(devlist->devname, mdfd, runstop); - break; - case 'A': /* Assemble */ - if (!scan) - rv = Assemble(devlist->devname, mdfd, &ident, configfile, - devlist->next, - readonly, runstop, verbose, force); - else if (devs_found>0) - for (dv = devlist ; dv ; dv=dv->next) { - mddev_ident_t array_ident = conf_get_ident(configfile, dv->devname); - mdfd = open_mddev(dv->devname); - if (mdfd < 0) { - rv |= 1; - continue; - } - if (array_ident == NULL) { - fprintf(stderr, Name ": %s not identified in config file.\n", - dv->devname); - rv |= 1; - continue; - } - rv |= Assemble(dv->devname, mdfd, array_ident, configfile, - NULL, - readonly, runstop, verbose, force); - } - else { - mddev_ident_t array_list = conf_get_ident(configfile, NULL); - if (!array_list) { - fprintf(stderr, Name ": No arrays found in config file\n"); - rv = 1; - } else - for (; array_list; array_list = array_list->next) { - mdu_array_info_t array; - mdfd = open_mddev(array_list->devname); - if (mdfd < 0) { - rv |= 1; - continue; - } - if (ioctl(mdfd, GET_ARRAY_INFO, &array)>=0) - /* already assembled, skip */ - continue; - rv |= Assemble(array_list->devname, mdfd, - array_list, configfile, - NULL, - readonly, runstop, verbose, force); - } - } - break; - case 'B': /* Build */ - rv = Build(devlist->devname, mdfd, chunk, level, raiddisks, devlist->next); - break; - case 'C': /* Create */ - rv = Create(devlist->devname, mdfd, chunk, level, layout, size, - raiddisks, sparedisks, - devs_found-1, devlist->next, runstop, verbose, force); - break; - case 'D': /* Detail */ - for (dv=devlist ; dv; dv=dv->next) - rv |= Detail(dv->devname, brief); - break; - case 'E': /* Examine */ - if (devlist == NULL && scan==0) { - fprintf(stderr, Name ": No devices to examine\n"); - exit(2); - } - rv = Examine(devlist, devlist?brief:!verbose, configfile); - break; - case 'F': /* Follow */ - rv= Monitor(devlist, mailaddr, program, - delay?delay:60, configfile); - } - exit(rv); -} diff --git a/mdctl.h b/mdctl.h deleted file mode 100644 index 5aa61ce..0000000 --- a/mdctl.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * mdctl - manage Linux "md" devices aka RAID arrays. - * - * Copyright (C) 2001-2002 Neil Brown - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Neil Brown - * Email: - * Paper: Neil Brown - * School of Computer Science and Engineering - * The University of New South Wales - * Sydney, 2052 - * Australia - */ - -#define __USE_LARGEFILE64 -#include -extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence)); - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#define MD_MAJOR 9 - - -#include "md_u.h" - -#define Name "mdctl" - -extern char short_options[]; -extern struct option long_options[]; -extern char Version[], Usage[], Help[], Help_create[], Help_build[], Help_assemble[]; - -/* structures read from config file */ -/* List of mddevice names and identifiers - * Identifiers can be: - * uuid=128-hex-uuid - * super-minor=decimal-minor-number-from-superblock - * devices=comma,separated,list,of,device,names,with,wildcards - * - * If multiple fields are present, the intersection of all matching - * devices is considered - */ -typedef struct mddev_ident_s { - char *devname; - - int uuid_set; - __u32 uuid[4]; - - int super_minor; /* -1 if not set */ - - char *devices; /* comma separated list of device - * names with wild cards - */ - int level; /* -10 if not set */ - int raid_disks; /* -1 if not set */ - char *spare_group; - struct mddev_ident_s *next; -} *mddev_ident_t; - -/* List of device names - wildcards expanded */ -typedef struct mddev_dev_s { - char *devname; - char disposition; /* 'a' for add, 'r' for remove, 'f' for fail. - * Not set for names read from .config - */ - struct mddev_dev_s *next; -} *mddev_dev_t; - -typedef struct mapping { - char *name; - int num; -} mapping_t; - -#ifndef Sendmail -#define Sendmail "/usr/lib/sendmail -t" -#endif - -extern char *map_num(mapping_t *map, int num); -extern int map_name(mapping_t *map, char *name); -extern mapping_t r5layout[], pers[]; - -extern char *map_dev(int major, int minor); - - -extern int Manage_ro(char *devname, int fd, int readonly); -extern int Manage_runstop(char *devname, int fd, int runstop); -extern int Manage_subdevs(char *devname, int fd, - mddev_dev_t devlist); - - -extern int Assemble(char *mddev, int mdfd, - mddev_ident_t ident, - char *conffile, - mddev_dev_t devlist, - int readonly, int runstop, - int verbose, int force); - -extern int Build(char *mddev, int mdfd, int chunk, int level, - int raiddisks, - mddev_dev_t devlist); - - -extern int Create(char *mddev, int mdfd, - int chunk, int level, int layout, int size, int raiddisks, int sparedisks, - int subdevs, mddev_dev_t devlist, - int runstop, int verbose, int force); - -extern int Detail(char *dev, int brief); -extern int Examine(mddev_dev_t devlist, int brief, char *conffile); -extern int Monitor(mddev_dev_t devlist, - char *mailaddr, char *alert_cmd, - int period, - char *config); - -extern int md_get_version(int fd); -extern int get_linux_version(); -extern int parse_uuid(char *str, int uuid[4]); -extern int check_ext2(int fd, char *name); -extern int check_reiser(int fd, char *name); -extern int check_raid(int fd, char *name); - -extern mddev_ident_t conf_get_ident(char *, char*); -extern mddev_dev_t conf_get_devs(char *); - -extern char *human_size(long kbytes); diff --git a/mdctl.man b/mdctl.man deleted file mode 100644 index 682bc82..0000000 --- a/mdctl.man +++ /dev/null @@ -1,476 +0,0 @@ -mdctl(8) mdctl(8) - - - -NNAAMMEE - mdctl - manage MD devices _a_k_a Linux Software Raid. - - -SSYYNNOOPPSSIISS - mmddccttll _[_m_o_d_e_] _<_r_a_i_d_d_e_v_i_c_e_> _[_o_p_t_i_o_n_s_] _<_s_u_b_d_e_v_i_c_e_s_> - - -DDEESSCCRRIIPPTTIIOONN - RAID devices are virtual devices created from two or more - real block devices. This allows multiple devices (typi- - cally disk drives or partitions there-of) to be combined - into a single device to hold (for example) a single - filesystem. Some RAID levels included redundancy and so - can survive some degree of device failure. - - Linux Software RAID devices are implemented through the md - (Multiple Devices) device driver. - - Currently, Linux supports LLIINNEEAARR md devices, RRAAIIDD00 (strip- - ing), RRAAIIDD11 (mirroring), RRAAIIDD44 and RRAAIIDD55.. - - Recent kernels (2002) also support a mode known as MMUULLTTII-- - PPAATTHH. mmddccttll does not support MULTIPATH as yet. - - mmddccttll is a program that can be used to create and manage - MD devices. As such it provides a similar set of func- - tionality to the rraaiiddttoooollss packages. The key differences - between mmddccttll and rraaiiddttoooollss are: - - +o mmddccttll is a single program and not a collection of pro- - grams. - - +o mmddccttll can perform (almost) all of its functions with- - out having a configuration file. Also mdctl helps - with management of the configuration file. - - +o mmddccttll can provide information about your arrays - (through Detail and Examine) that rraaiiddttoooollss cannot. - - +o rraaiiddttoooollss can manage MULTIPATH devices which mmddccttll - cannot yet manage. - - -MMOODDEESS - mdctl has 7 major modes of operation: - - AAsssseemmbbllee - Assemble the parts of a previously created array - into an active array. Components can be explicitly - given or can be searched for. mmddccttll checks that - the components do form a bona fide array, and can, - on request, fiddle superblock information so as to - assemble a faulty array. - - - BBuuiilldd Build a legacy array without per-device - superblocks. - - - CCrreeaattee Create a new array with per-device superblocks. - - - DDeettaaiill Display the details of a given md device. Details - include the RAID level, the number of devices, - which ones are faulty (if any), and the array UUID. - - - EExxaammiinnee - Examine a device to see if it is part of an md - array, and print out the details of that array. - This mode can also be used to examine a large num- - ber of devices and to print out a summary of the - arrays found in a format suitable for the - mmddccttll..ccoonnff configuration file. - - - FFoollllooww oorr MMoonniittoorr - Monitor one or more md devices and act on any state - changes. - - - MMaannaaggee This is for odd bits an pieces like hotadd, - hotremove, setfaulty, stop, readonly, readwrite. - - -OOPPTTIIOONNSS - Available options are: - - - --AA, ----aasssseemmbbllee - Assemble an existing array. - - - --BB, ----bbuuiilldd - Build a legacy array without superblocks. - - - --CC, ----ccrreeaattee - Create a new array. - - - --DD, ----ddeettaaiill - Print detail of one or more md devices. - - - --EE, ----eexxaammiinnee - Print content of md superblock on device(s). - - - --FF, ----ffoollllooww, ----mmoonniittoorr - Select MMoonniittoorr mode. - - - --hh, ----hheellpp - Display help message or, after above option, mode - specific help message. - - - --VV, ----vveerrssiioonn - Print version information for mdctl. - - - --vv, ----vveerrbboossee - Be more verbose about what is happening. - - - --bb, ----bbrriieeff - Be less verbose. This is used with ----ddeettaaiill and - ----eexxaammiinnee. - - -FFoorr ccrreeaattee oorr bbuuiilldd:: - --cc, ----cchhuunnkk== - Specify chunk size of kibibytes. The default is - 64. - - - ----rroouunnddiinngg== - Specify rounding factor for linear array (==chunk - size) - - - --ll, ----lleevveell== - Set raid level. Options are: linear, raid0, 0, - stripe, raid1, 1, mirror, raid5, 4, raid5, 5. - Obviously some of these are synonymous. Only the - first 4 are valid when Building. - - - --pp, ----ppaarriittyy== - Set raid5 parity algorithm. Options are: - {left,right}-{,a}symmetric, la, ra, ls, rs. The - default is left-symmetric. - - - ----llaayyoouutt== - same as --parity - - - --nn, ----rraaiidd--ddiisskkss== - number of active devices in array. - - - --xx, ----ssppaarree--ddiisskkss== - number of spare (eXtra) disks in initial array. - Spares can be added and removed later. - - - --zz, ----ssiizzee== - Amount (in Kibibytes) of space to use from each - drive in RAID1/4/5. This must be a multiple of the - chunk size, and must leave about 128Kb of space at - the end of the drive for the RAID superblock. If - this is not specified (as it normally is not) the - smallest drive (or partition) sets the size, though - if there is a variance among the drives of greater - than 1%, a warning is issued. - - -FFoorr aasssseemmbbllee:: - --uu, ----uuuuiidd== - uuid of array to assemble. Devices which don't have - this uuid are excluded - - - --mm, ----ssuuppeerr--mmiinnoorr== - Minor number of device that array was created for. - Devices which don't have this minor number are - excluded. If you create an array as /dev/md1, then - all superblock will contain the minor number 1, - even if the array is later assembled as /dev/md2. - - - --cc, ----ccoonnffiigg== - config file. Default is //eettcc//mmddccttll..ccoonnff. - - - --ss, ----ssccaann - scan config file for missing information - - - --ff, ----ffoorrccee - Assemble the array even if some superblocks appear - out-of-date - - - --RR, ----rruunn - Attempt to start the array even if fewer drives - were given than are needed for a full array. Nor- - mally if not all drives are found and ----ssccaann is not - used, then the array will be assembled but not - started. With ----rruunn an attempt will be made to - start it anyway. - - -GGeenneerraall mmaannaaggeemmeenntt - --aa, ----aadddd - hotadd listed devices. - - - --rr, ----rreemmoovvee - remove listed devices. The must not be active. - i.e. they should be failed or spare devices. - - - --ff, ----ffaaiill - mark listed devices as faulty. - - - ----sseett--ffaauullttyy - same as --fail. - - - --RR, ----rruunn - start a partially built array. - - - --SS, ----ssttoopp - deactivate array, releasing all resources. - - - --oo, ----rreeaaddoonnllyy - mark array as readonly. - - - --ww, ----rreeaaddwwrriittee - mark array as readwrite. - - - -AASSSSEEMMBBLLYY MMOODDEE - Usage: mmddccttll ----aasssseemmbbllee _d_e_v_i_c_e _o_p_t_i_o_n_s_._._. - - Usage: mmddccttll ----aasssseemmbbllee ----ssccaann _o_p_t_i_o_n_s_._._. - - - This usage assembles one or more raid arrays from pre- - existing components. For each array, mdctl needs to know - the md device, the identity of the array, and a number of - sub devices. These can be found in a number of ways. - - The md device is either given before ----ssccaann or is found - from the config file. In the latter case, multiple md - devices can be started with a single mdctl command. - - The identity can be given with the ----uuuuiidd option, with the - ----ssuuppeerr--mmiinnoorr option, can be found in in the config file, - or will be taken from the super block on the first subde- - vice listed on the command line. - - Devices can be given on the ----aasssseemmbbllee command line or - from the config file. Only devices which have an md - superblock which contains the right identity will be con- - sidered for any device. - - The config file is only used if explicitly named with - ----ccoonnffiigg or requested with ----ssccaann.. In the later case, - //eettcc//mmddccttll..ccoonnff is used. - - If ----ssccaann is not given, then the config file will only be - used to find the identity of md arrays. - - Normally the array will be started after it is assembled. - However is ----ssccaann is not given and insufficient drives - were lists to start a complete (non-degraded) array, then - the array is not started (to guard against usage errors). - To insist that the array be started in this case (as may - work for RAID1 or RAID5), give the ----rruunn flag. - - - -BBUUIILLDD MMOODDEE - Usage: mmddccttll ----bbuuiilldd _d_e_v_i_c_e ----cchhuunnkk==_X ----lleevveell==_Y ----rraaiidd-- - ddiisskkss==_Z _d_e_v_i_c_e_s - - - This usage is similar to ----ccrreeaattee. The difference is that - it creates a legacy array without a superblock. With these - arrays there is no difference between initially creating - the array and subsequently assembling the array, except - that hopefully there is useful data there in the second - case. - - The level may only be 0, raid0, or linear. All devices - must be listed and the array will be started once com- - plete. - - -CCRREEAATTEE MMOODDEE - Usage: mmddccttll ----ccrreeaattee _d_e_v_i_c_e ----cchhuunnkk==_X ----lleevveell==_Y - ----rraaiidd--ddiisskkss==_Z _d_e_v_i_c_e_s - - - This usage will initialise a new md array, associate some - devices with it, and activate the array. - - As devices are added, they are checked to see if they con- - tain raid superblocks or filesystems. They are also check - to see if the variance in device size exceeds 1%. - - If any discrepancy is found, the array will not automati- - cally be run, though the presence of a ----rruunn can override - this caution. - - - The General Management options that are valid with --cre- - ate are: - - ----rruunn insist of running the array even if some devices - look like they might be in use. - - - ----rreeaaddoonnllyy - start the array readonly - not supported yet. - - -DDEETTAAIILL MMOODDEE - Usage: mmddccttll ----ddeettaaiill [----bbrriieeff] _d_e_v_i_c_e _._._. - - - This usage sill print out the details of the given array - including a list of component devices. To determine names - for the devices, mmddccttll searches //ddeevv for device files with - the right major and minor numbers. - - With ----bbrriieeff mmddccttll prints a single line that identifies - the level, number of disks, and UUID of the array. This - line is suitable for inclusion in //eettcc//mmddccttll..ccoonnff. - - -EEXXAAMMIINNEE MMOODDEE - Usage: mmddccttll ----eexxaammiinnee [----ssccaann] [----bbrriieeff] _d_e_v_i_c_e _._._. - - This usage will examine some block devices to see if that - have a valid RAID superblock on them. The information in - each valid raid superblock will be printed. - - If ----ssccaann is used, the no devices should be listed, and - the complete set of devices identified in the configura- - tion file are checked. ----ssccaann implies ----bbrriieeff but this - implication can be countered by specifying ----vveerrbboossee. - - With ----bbrriieeff mmddccttll will output an config file entry of - each distinct array that was found. This entry will list - the UUID, the raid level, and a list of the individual - devices on which a superblock for that array was found. - This output will by syntactically suitable for inclusion - in the configuration file, but should NNOOTT be used blindly. - Often the array description that you want in the configu- - ration file is much less specific than that given by mmddccttll - --BBss. For example, you normally do not want to list the - devices, particularly if they are SCSI devices. - - - -FFIILLEESS - //pprroocc//mmddssttaatt - If you're using the //pprroocc filesystem, //pprroocc//mmddssttaatt gives - you informations about md devices status. This file is - not currently used by mmddccttll. - - - //eettcc//mmddccttll..ccoonnff - The config file is line oriented with, as usual, blank - lines and lines beginning with a hash (or pound sign or - sharp or number sign, whichever you like to call it) - ignored. Lines that start with a blank are treated as - continuations of the previous line (I don't like trailing - slashes). - - Each line contains a sequence of space-separated words, - the first of which identified the type of line. Keywords - are case-insensitive, and the first work on a line can be - abbreviated to 3 letters. - - There are two types of lines. ARRAY and DEVICE. - - The DEVICE lines usually come first. All remaining words - on the line are treated as names of devices, possibly con- - taining wild cards (see _g_l_o_b(7)). These list all the - devices that mmddccttll is allowed to scan when looking for - devices with RAID superblocks. Each line can contain mul- - tiple device names, and there can be multiple DEVICE - lines. For example: - - DEVICE /dev/hda* /dev/hdc* - DEV /dev/sd* - DEVICE /dev/discs/disc*/disc - - The ARRAY lines identify actual arrays. The second word - on the line should be the name of the device where the - array is normally assembled, such as /dev/md1. Subsequent - words identify the array. If multiple identities are - given, then the array much match ALL identities to be con- - sidered a match. Each identity word has a tag, and equals - sign, and some value. The options are: - - - uuuuiidd== The value should be a 128 bit uuid in hexadecimal, - with punctuation interspersed if desired. This - must match the uuid stored in the superblock. - - ssuuppeerr--mmiinnoorr== - The value is an integer which indicates the minor - number that was stored in the superblock when the - array was created. When an array is created as - /dev/mdX, then the minor number X is stored. - - ddeevviicceess== - The value is a comma separated list of device - names. Precisely these devices will be used to - assemble the array. Note that the devices listed - there must also be listed on a DEVICE line. - - lleevveell== The value is a raid level. This is normally used - to identify an array, but is supported so that the - output of mmddccttll ----eexxaammiinnee ----ssccaann can be use - directly in the configuration file. - - ddiisskkss== The value is the number of disks in a complete - active array. As with lleevveell== this is mainly for - compatibility with the output of mmddccttll ----eexxaammiinnee - ----ssccaann. - - -TTOODDOO - Finish and document Follow mode. - - -SSEEEE AALLSSOO - For information on the various levels of RAID, check out: - - - http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/ - - for new releases of the RAID driver check out: - - - ftp://ftp.kernel.org/pub/linux/kernel/peo- - ple/mingo/raid-patches - - or - - http://www.cse.unsw.edu.au/~neilb/patches/linux- - stable/ - - _r_a_i_d_t_a_b(5), _r_a_i_d_0_r_u_n(8), _r_a_i_d_s_t_o_p(8), _m_k_r_a_i_d(8) - - - - mdctl(8) diff --git a/mdctl.spec b/mdctl.spec index a40a1a4..e1f6eec 100644 --- a/mdctl.spec +++ b/mdctl.spec @@ -1,20 +1,20 @@ -Summary: mdctl is used for controlling Linux md devices (aka RAID arrays) -Name: mdctl +Summary: mdadm is used for controlling Linux md devices (aka RAID arrays) +Name: mdadm Version: 0.5 Release: 1 -Source0: http://www.cse.unsw.edu.au/~neilb/source/mdctl/mdctl-%{version}.tgz -URL: http://www.cse.unsw.edu.au/~neilb/source/mdctl/ +Source0: http://www.cse.unsw.edu.au/~neilb/source/mdadm/mdadm-%{version}.tgz +URL: http://www.cse.unsw.edu.au/~neilb/source/mdadm/ Copyright: GPL Group: Utilities/System BuildRoot: /var/tmp/%{name}-root Packager: Danilo Godec %description -mdctl is a single program that can be used to control Linux md devices. It +mdadm is a single program that can be used to control Linux md devices. It is intended to provide all the functionality of the mdtools and raidtools but with a very different interface. -mdctl can perform all functions without a configuration file. There is the +mdadm can perform all functions without a configuration file. There is the option of using a configuration file, but not in the same way that raidtools uses one. @@ -25,7 +25,7 @@ stopping a raid array, which needs to know nothing about the array. %prep -%setup -q -n mdctl +%setup -q -n mdadm %build make @@ -33,7 +33,7 @@ make %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/sbin -install -m755 mdctl $RPM_BUILD_ROOT/sbin/ +install -m755 mdadm $RPM_BUILD_ROOT/sbin/ %clean rm -rf $RPM_BUILD_ROOT diff --git a/util.c b/util.c index 17a7e87..5c70a83 100644 --- a/util.c +++ b/util.c @@ -1,5 +1,5 @@ /* - * mdctl - manage Linux "md" devices aka RAID arrays. + * mdadm - manage Linux "md" devices aka RAID arrays. * * Copyright (C) 2001-2002 Neil Brown * @@ -27,7 +27,7 @@ * Australia */ -#include "mdctl.h" +#include "mdadm.h" #include "md_p.h" #include -- cgit