announce: tiny raidtools-alike for use e.g. in initrd
http://www.corpit.ru/mjt/mdctl.c - a very small utility similar to raidtools suite. I wrote this program to use it inside an initrd to bring raid arrays up at boot time - where the size of executable and simplicity is at premium. Differences between this implementation and raidtools are:
- size. When compiled with dietlibc, executable is about 7kb on i386.
- it does not have mkraid utility and other fun stuff. Supported are
- raidstart
- raidstop
- raidhot{add,remove,generateerror)
- raidsetfaulty
i.e., only "simple" commands - just ioctls in fact.
- it uses NO config file like all the raidtools suite. I.e., it is more like mdadm in this respect. All parameters are accepted in the command line. This makes the utility handy inside read-only boot-time environment (you may e.g. parse md=... kernel parameter and convert it into mdctl commandline)
- `mdctl start' tries to bring an array using ALL components of the array given in the command line, until successeful (raidstart tries only first component, and if that is missing but other component(s) are available, operation will fail).
Usage:
mdctl start /dev/mdN /dev/hda1 /dev/hdb1 /dev/hdc1
equivalent to md=N,/dev/hda1,/dev/hdb1,/dev/hdc1 boot parameter, but you can't specify raid level (it will be read from the superblock), and kernel may choose to bring up another mdN (as indicated by super-minor)
mdctl {stop,readonly,ro,readwrite,rw} /dev/mdN
mdctl {add,remove,setfaulty,generaterror} /dev/mdN /dev/hda1
This tiny code released under GPL licence... in a hope it will be useful to someone else too, not only to me ;)
Enjoy.
/mjt
well, since it is announce week :)))
I made a small patch to mdadm to build a subset of mdadm with diet-libc, for use in initrds. (it is 44k statically linked)
I cannot rebuild whole mdadm with dietlibc due to dietlibc not understanding non option arguments beetween option (optarg starting with "-")
to build use:
diet gcc -DCONFFILE="\"/etc/mdadm.conf\"" -o mdassemble \
mdassemble.c Assemble.c config.c dlink.c util.c
mdassemble will just scan /etc/mdadm.conf and try to assemble everything it finds like running "mdadm -A -s".
regards,
L.
Signature · 6 lines
Luca Berra -- [email protected] Communication Media & Services S.r.l. /"\ \ / ASCII RIBBON CAMPAIGN X AGAINST HTML MAIL / \
/me should drink more coffee in the morning
heres the patch: (it is vs 1.3.0, but it applies on 1.4.0 as well)
Quoted 16 lines · Luca Berra
well, since it is announce week :)))
I made a small patch to mdadm to build a subset of mdadm with diet-libc, for use in initrds. (it is 44k statically linked)
I cannot rebuild whole mdadm with dietlibc due to dietlibc not understanding non option arguments beetween option (optarg starting with "-")
to build use:
diet gcc -DCONFFILE="\"/etc/mdadm.conf\"" -o mdassemble \
mdassemble.cAssemble.cconfig.cdlink.cutil.cmdassemble will just scan
/etc/mdadm.confand try to assemble everything it finds like running "mdadm -A -s".
Signature · 6 lines
Luca Berra -- [email protected] Communication Media & Services S.r.l. /"\ \ / ASCII RIBBON CAMPAIGN X AGAINST HTML MAIL / \