CVS commit: othersrc/external/bsd/genraidconf

2011-05-18 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Thu May 19 00:24:22 UTC 2011

Modified Files:
othersrc/external/bsd/genraidconf: genraidconf.sh

Log Message:
one less magic number - make it obvious what the NetBSD partition id is.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 othersrc/external/bsd/genraidconf/genraidconf.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/genraidconf/genraidconf.sh
diff -u othersrc/external/bsd/genraidconf/genraidconf.sh:1.4 othersrc/external/bsd/genraidconf/genraidconf.sh:1.5
--- othersrc/external/bsd/genraidconf/genraidconf.sh:1.4	Wed May 18 19:17:21 2011
+++ othersrc/external/bsd/genraidconf/genraidconf.sh	Thu May 19 00:24:22 2011
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $NetBSD: genraidconf.sh,v 1.4 2011/05/18 19:17:21 agc Exp $
+# $NetBSD: genraidconf.sh,v 1.5 2011/05/19 00:24:22 agc Exp $
 
 # Copyright (c) 2011 Alistair Crooks 
 # All rights reserved.
@@ -49,6 +49,7 @@
 
 doit=""
 raiddev=raid0
+netbsdpartid=169
 minraid5=3 # per mrg, no hotswap
 raidlevel=1 # default is RAID1 protection
 spare=0
@@ -155,7 +156,7 @@
 if ${doslabel}; then
 	for d in ${disks}; do
 		secs=$(expr ${sectorc} - 2048)
-		${doit} fdisk -u -a -i -f -3 -s 169/2048/${secs} -b 100/1/${sectorc} -A 2048/2048 ${d}a
+		${doit} fdisk -u -a -i -f -3 -s ${netbsdpartid}/2048/${secs} -b 100/1/${sectorc} -A 2048/2048 ${d}a
 	done
 fi
 



CVS commit: othersrc/external/bsd/genraidconf

2011-05-18 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Wed May 18 19:17:21 UTC 2011

Modified Files:
othersrc/external/bsd/genraidconf: genraidconf.sh

Log Message:
unconfigure the generated raid set at the end of this utility


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/genraidconf/genraidconf.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/genraidconf/genraidconf.sh
diff -u othersrc/external/bsd/genraidconf/genraidconf.sh:1.3 othersrc/external/bsd/genraidconf/genraidconf.sh:1.4
--- othersrc/external/bsd/genraidconf/genraidconf.sh:1.3	Wed May 18 01:41:31 2011
+++ othersrc/external/bsd/genraidconf/genraidconf.sh	Wed May 18 19:17:21 2011
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $NetBSD: genraidconf.sh,v 1.3 2011/05/18 01:41:31 agc Exp $
+# $NetBSD: genraidconf.sh,v 1.4 2011/05/18 19:17:21 agc Exp $
 
 # Copyright (c) 2011 Alistair Crooks 
 # All rights reserved.
@@ -253,4 +253,7 @@
 	${doit} raidctl -A root ${raiddev}
 fi
 
+# unconfigure the raid device
+${doit} raidctl -u ${raiddev}
+
 exit 0



CVS commit: othersrc/external/bsd/genraidconf

2011-05-17 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Wed May 18 01:41:31 UTC 2011

Modified Files:
othersrc/external/bsd/genraidconf: genraidconf.sh

Log Message:
put a comment at the start of the generated raid config file that the file was
generated by genraidconf(8)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/genraidconf/genraidconf.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/genraidconf/genraidconf.sh
diff -u othersrc/external/bsd/genraidconf/genraidconf.sh:1.2 othersrc/external/bsd/genraidconf/genraidconf.sh:1.3
--- othersrc/external/bsd/genraidconf/genraidconf.sh:1.2	Wed May 18 01:37:58 2011
+++ othersrc/external/bsd/genraidconf/genraidconf.sh	Wed May 18 01:41:31 2011
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $NetBSD: genraidconf.sh,v 1.2 2011/05/18 01:37:58 agc Exp $
+# $NetBSD: genraidconf.sh,v 1.3 2011/05/18 01:41:31 agc Exp $
 
 # Copyright (c) 2011 Alistair Crooks 
 # All rights reserved.
@@ -213,6 +213,8 @@
 case "${doit}" in
 "")
 	cat > /etc/${raiddev}.conf << EOF
+# automatically generated by genraidconf at $(date)
+
 START array
 #numrow numcol numspare
 1 ${devc} 0



CVS commit: othersrc/external/bsd/genraidconf

2011-05-17 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Wed May 18 01:37:58 UTC 2011

Modified Files:
othersrc/external/bsd/genraidconf: genraidconf.sh

Log Message:
work out the partition letter of the first partition properly

invoke fdisk properly

use the correct partition letter in the raidN.conf file

invoke ci with a default description of the file as well as a commit message.

with these changes, we properly configure and initialise a raid1 set on 2 vnd
devices.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/genraidconf/genraidconf.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/genraidconf/genraidconf.sh
diff -u othersrc/external/bsd/genraidconf/genraidconf.sh:1.1.1.1 othersrc/external/bsd/genraidconf/genraidconf.sh:1.2
--- othersrc/external/bsd/genraidconf/genraidconf.sh:1.1.1.1	Tue May 17 03:48:50 2011
+++ othersrc/external/bsd/genraidconf/genraidconf.sh	Wed May 18 01:37:58 2011
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $NetBSD: genraidconf.sh,v 1.1.1.1 2011/05/17 03:48:50 agc Exp $
+# $NetBSD: genraidconf.sh,v 1.2 2011/05/18 01:37:58 agc Exp $
 
 # Copyright (c) 2011 Alistair Crooks 
 # All rights reserved.
@@ -80,14 +80,16 @@
 
 # work out whether we use a dos disk lebel
 case $(sysctl kern.rawpartition) in
-2)	wholedisk=c
+*2)	wholedisk=c
 	firstpart=d
 	doslabel=false
 	;;
-3)	wholedisk=d
+*3)	wholedisk=d
 	firstpart=e
 	doslabel=true
 	;;
+*)	die "can't find raw partition number"
+	;;
 esac
 
 # count number of devices
@@ -104,7 +106,11 @@
 sectorc=0
 devs=""
 while [ $# -gt ${lastdev} ]; do
-	devs="${devs}|/dev/$1${firstpart}"
+	case "$1" in
+	vnd*)	part1=a ;;
+	*)	part1=${firstpart} ;;
+	esac
+	devs="${devs}|/dev/$1${part1}"
 	nsectorc=$(disklabel $1 2>/dev/null | awk '/^total sectors:/ {print $3;exit}')
 	case "${nsectorc}" in
 	"")	die "device $1 not found on computer" ;;
@@ -148,7 +154,8 @@
 # put an fdisk label on there
 if ${doslabel}; then
 	for d in ${disks}; do
-		${doit} fdisk -uai -A 2048 ${d}a
+		secs=$(expr ${sectorc} - 2048)
+		${doit} fdisk -u -a -i -f -3 -s 169/2048/${secs} -b 100/1/${sectorc} -A 2048/2048 ${d}a
 	done
 fi
 
@@ -185,7 +192,7 @@
 if [ -e /etc/${raiddev}.conf ]; then
 	echo "Preserving previous ${raiddev}.conf in /etc/RCS"
 	${doit} mkdir -p /etc/RCS
-	(cd /etc && ${doit} ci -l -m"creating new ${raiddev}.conf" ${raiddev}.conf)
+	(cd /etc && ${doit} ci -l -m"creating new ${raiddev}.conf" -t-"new ${raiddev}.conf file" ${raiddev}.conf)
 fi
 
 # set up spare definitions if we need one
@@ -195,8 +202,12 @@
 	spare2=""
 	;;
 1)
+	case "$1" in
+	vnd*)	part1=a ;;
+	*)	part1=${firstpart} ;;
+	esac
 	spare1="START spare"
-	spare2="/dev/${1}${firstpart}"
+	spare2="/dev/${1}${part1}"
 	;;
 esac
 case "${doit}" in



CVS commit: othersrc/external/bsd/genraidconf

2011-05-17 Thread Thomas Klausner
Module Name:othersrc
Committed By:   wiz
Date:   Tue May 17 11:23:41 UTC 2011

Modified Files:
othersrc/external/bsd/genraidconf: genraidconf.8

Log Message:
Various improvements.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/genraidconf/genraidconf.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/genraidconf/genraidconf.8
diff -u othersrc/external/bsd/genraidconf/genraidconf.8:1.2 othersrc/external/bsd/genraidconf/genraidconf.8:1.3
--- othersrc/external/bsd/genraidconf/genraidconf.8:1.2	Tue May 17 03:51:40 2011
+++ othersrc/external/bsd/genraidconf/genraidconf.8	Tue May 17 11:23:41 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: genraidconf.8,v 1.2 2011/05/17 03:51:40 agc Exp $
+.\" $NetBSD: genraidconf.8,v 1.3 2011/05/17 11:23:41 wiz Exp $
 .\"
 .\" Copyright (c) 2011 Alistair Crooks 
 .\" All rights reserved.
@@ -28,14 +28,14 @@
 .Os
 .Sh NAME
 .Nm genraidconf
-.Nd Utility to configure RAID sets
+.Nd utility to configure RAID sets
 .Sh SYNOPSIS
 .Nm
 .Fl nv
 .Op Fl d Ar raidN
 .Op Fl o Ar raid1|raid5|root|spare|zero
 .Op Fl r Ar 1|5
-components
+.Ar components
 .Sh DESCRIPTION
 The
 .Nm
@@ -43,12 +43,11 @@
 It uses various pieces of information to construct a
 number of disklabels for the RAID set component disks using
 .Xr disklabel 8 ,
-and a configuration file for RAID frame itself,
-.Xr raid 4 
+and a configuration file for RAIDframe itself,
+.Xr raid 4
 producing a file as described in
 .Xr raidctl 8 .
 .Pp
-.Pp
 The following options are available:
 .Bl -tag -width raidN123
 .It Fl d Ar raidN
@@ -60,11 +59,11 @@
 .It Fl n
 Do not do any processing - echo the commands which would otherwise be performed.
 .It Fl o Ar raid1
-Generate a configuration for RAID1 protection
+Generate a configuration for RAID1 protection.
 .It Fl o Ar raid5
-Generate a configuration for RAID5 protection
+Generate a configuration for RAID5 protection.
 .It Fl o Ar root
-Enable the generated root device to be used as a root device
+Enable the generated root device to be used as a root device.
 .It Fl o Ar spare
 In a RAID 5 device, use one of the given disks as a hot-spare.
 The component that will be used as the hot spare is the final
@@ -75,9 +74,9 @@
 than raidframe in completing this task, and so this step has been
 added as a separate option.
 .It Fl r Ar 1
-Generate a configuration for RAID1 protection
+Generate a configuration for RAID1 protection.
 .It Fl r Ar 5
-Generate a configuration for RAID5 protection
+Generate a configuration for RAID5 protection.
 .It Fl v
 Perform operations in a verbose manner (useful for debugging)
 .El
@@ -97,7 +96,7 @@
 .Nm
 utility will also zero the components prior to configuring them
 if the
-.Fl z
+.Fl o Ar zero
 option is provided on the command line.
 .Pp
 Various sanity checks are performed, such as whether there are enough component



CVS commit: othersrc/external/bsd/genraidconf

2011-05-16 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Tue May 17 03:51:40 UTC 2011

Modified Files:
othersrc/external/bsd/genraidconf: genraidconf.8

Log Message:
invoke the commands in the example properly


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/genraidconf/genraidconf.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/genraidconf/genraidconf.8
diff -u othersrc/external/bsd/genraidconf/genraidconf.8:1.1.1.1 othersrc/external/bsd/genraidconf/genraidconf.8:1.2
--- othersrc/external/bsd/genraidconf/genraidconf.8:1.1.1.1	Tue May 17 03:48:50 2011
+++ othersrc/external/bsd/genraidconf/genraidconf.8	Tue May 17 03:51:40 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: genraidconf.8,v 1.1.1.1 2011/05/17 03:48:50 agc Exp $
+.\" $NetBSD: genraidconf.8,v 1.2 2011/05/17 03:51:40 agc Exp $
 .\"
 .\" Copyright (c) 2011 Alistair Crooks 
 .\" All rights reserved.
@@ -116,7 +116,7 @@
 .Bd -literal
 % uname -m
 amd64
-% genraidconf.sh -n -o raid5 -d raid0 sd0 sd1 sd2
+% genraidconf -n -o raid5 -d raid0 sd0 sd1 sd2
 fdisk -uai -A 2048 sd0a
 fdisk -uai -A 2048 sd1a
 fdisk -uai -A 2048 sd2a
@@ -126,9 +126,9 @@
 raidctl -I 20110516143616 raid0
 raidctl -i raid0
 raidctl -A yes raid0
-% genraidconf.sh -n -o raid1 -d raid1 sd0 sd1 sd2
+% genraidconf -n -o raid1 -d raid1 sd0 sd1 sd2
 RAIDframe RAID1 requires 2 disks
-% genraidconf.sh -n -r 1 -d raid1 sd0 sd1
+% genraidconf -n -r 1 -d raid1 sd0 sd1
 fdisk -uai -A 2048 sd0a
 fdisk -uai -A 2048 sd1a
 disklabel -R sd0 /tmp/label.26009a
@@ -136,7 +136,7 @@
 raidctl -I 20110516143702 raid1
 raidctl -i raid1
 raidctl -A yes raid1
-% genraidconf.sh -n -o raid1 -d raid1 -o zero sd0 sd1
+% genraidconf -n -o raid1 -d raid1 -o zero sd0 sd1
 dd if=/dev/zero bs=32k of=/dev/rsd0a
 dd if=/dev/zero bs=32k of=/dev/rsd1a
 fdisk -uai -A 2048 sd0a
@@ -146,7 +146,7 @@
 raidctl -I 20110516143710 raid1
 raidctl -i raid1
 raidctl -A yes raid1
-% genraidconf.sh -n -o raid1 -d raid1 -o zero -o root sd0 sd1
+% genraidconf -n -o raid1 -d raid1 -o zero -o root sd0 sd1
 dd if=/dev/zero bs=32k of=/dev/rsd0a
 dd if=/dev/zero bs=32k of=/dev/rsd1a
 fdisk -uai -A 2048 sd0a



CVS commit: othersrc/external/bsd/genraidconf

2011-05-16 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Tue May 17 03:48:50 UTC 2011

Update of /cvsroot/othersrc/external/bsd/genraidconf
In directory ivanova.netbsd.org:/tmp/cvs-serv2114

Log Message:
initial import of genraidconf, an embryonic RAIDframe configuration file
generator, into opthersrc.

 The genraidconf command constructs a configuration file for a RAID set.
 It uses various pieces of information to construct a number of disklabels
 for the RAID set component disks using disklabel(8), and a configuration
 file for RAID frame itself, raid(4) producing a file as described in
 raidctl(8).

It also can zero components before use, performs some basic sanity checks
on its inputs, and, in general, prepares the RAID set to the stage where a
newfs(8) may occur on it.

This utility is embryonic, since it needs much more testing. As such, it
must be considered experimental at this stage.

Examples of sage:

 % uname -m
 amd64
 % genraidconf.sh -n -o raid5 -d raid0 sd0 sd1 sd2
 fdisk -uai -A 2048 sd0a
 fdisk -uai -A 2048 sd1a
 fdisk -uai -A 2048 sd2a
 disklabel -R sd0 /tmp/label.20322a
 disklabel -R sd1 /tmp/label.20322a
 disklabel -R sd2 /tmp/label.20322a
 raidctl -I 20110516143616 raid0
 raidctl -i raid0
 raidctl -A yes raid0
 % genraidconf.sh -n -o raid1 -d raid1 sd0 sd1 sd2
 RAIDframe RAID1 requires 2 disks
 % genraidconf.sh -n -r 1 -d raid1 sd0 sd1
 fdisk -uai -A 2048 sd0a
 fdisk -uai -A 2048 sd1a
 disklabel -R sd0 /tmp/label.26009a
 disklabel -R sd1 /tmp/label.26009a
 raidctl -I 20110516143702 raid1
 raidctl -i raid1
 raidctl -A yes raid1
 % genraidconf.sh -n -o raid1 -d raid1 -o zero sd0 sd1
 dd if=/dev/zero bs=32k of=/dev/rsd0a
 dd if=/dev/zero bs=32k of=/dev/rsd1a
 fdisk -uai -A 2048 sd0a
 fdisk -uai -A 2048 sd1a
 disklabel -R sd0 /tmp/label.23760a
 disklabel -R sd1 /tmp/label.23760a
 raidctl -I 20110516143710 raid1
 raidctl -i raid1
 raidctl -A yes raid1
 % genraidconf.sh -n -o raid1 -d raid1 -o zero -o root sd0 sd1
 dd if=/dev/zero bs=32k of=/dev/rsd0a
 dd if=/dev/zero bs=32k of=/dev/rsd1a
 fdisk -uai -A 2048 sd0a
 fdisk -uai -A 2048 sd1a
 disklabel -R sd0 /tmp/label.25286a
 disklabel -R sd1 /tmp/label.25286a
 raidctl -I 20110516143738 raid1
 raidctl -i raid1
 raidctl -A yes raid1
 raidctl -A root raid1
 %

With a huge thankyou to Matthew Green for guidance on a number of
issues.


Status:

Vendor Tag: CROOKS
Release Tags:   genraidconf-base

N othersrc/external/bsd/genraidconf/genraidconf.8
N othersrc/external/bsd/genraidconf/genraidconf.sh
N othersrc/external/bsd/genraidconf/Makefile

No conflicts created by this import