Replace custom zpool configs with generic configs
[zfs.git] / scripts / zpool-config / zpool-raidz.sh
1 #!/bin/bash
2 #
3 # Zpool Raid-Z Configuration
4 #
5 # This script is used to simplify testing with the /dev/disk/zpool/[A-Z][1-n]
6 # devices.  It assumes that you have already populated /dev/disk/zpool/ by
7 # creating an /etc/zfs/zdev.conf file based on your system design.  You may
8 # use the zpool_layout command or manually create your own config file.
9 #
10 # You can then use either the zpool-create.sh or the zpios.sh test script to
11 # test various Raid-Z configurations by adjusting the following tunables.
12 # For example if you wanted to create and test a single 4-disk Raid-Z2
13 # configuration using disks [A-D]1 with dedicated ZIL and L2ARC devices
14 # you could run the following.
15 #
16 # ZIL="log A2" L2ARC="cache B2" RANKS=1 CHANNELS=4 LEVEL=2 \
17 # zpool-create.sh -c zpool-raidz
18 #
19 # zpool status tank
20 #   pool: tank
21 #  state: ONLINE
22 #  scan: none requested
23 # config:
24
25 #       NAME        STATE     READ WRITE CKSUM
26 #       tank        ONLINE       0     0     0
27 #         raidz2-0  ONLINE       0     0     0
28 #           A1      ONLINE       0     0     0
29 #           B1      ONLINE       0     0     0
30 #           C1      ONLINE       0     0     0
31 #           D1      ONLINE       0     0     0
32 #       logs
33 #         A2        ONLINE       0     0     0
34 #       cache
35 #         B2        ONLINE       0     0     0
36 #  
37 # errors: No known data errors
38
39
40 # Number of interior vdevs to create using the following rank ids.
41 RANKS=${RANKS:-1}
42 RANK_LIST=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 )
43
44 # Number of devices per vdev using the following channel ids.
45 CHANNELS=${CHANNELS:-8}
46 CHANNEL_LIST=( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z )
47
48 # Raid-Z Level: 1, 2, or 3.
49 LEVEL=${LEVEL:-2}
50
51 # Create a ZIL vdev as follows.
52 ZIL=${ZIL:-}
53
54 # Create an L2ARC vdev as follows.
55 L2ARC=${L2ARC:-}
56
57
58 raidz_setup() {
59         local RANKS=$1
60         local CHANNELS=$2
61
62         RAIDZS=()
63         for (( i=0; i<${RANKS}; i++ )); do
64                 RANK=${RANK_LIST[$i]}
65                 RAIDZ=("raidz${LEVEL}")
66
67                 for (( j=0, k=1; j<${CHANNELS}; j++, k++ )); do
68                         RAIDZ[$k]="${CHANNEL_LIST[$j]}${RANK}"
69                 done
70
71                 RAIDZS[$i]="${RAIDZ[*]}"
72         done
73
74         return 0
75 }
76
77 zpool_create() {
78         raidz_setup ${RANKS} ${CHANNELS}
79
80         ZPOOL_DEVICES="${RAIDZS[*]} ${ZIL} ${L2ARC}"
81         msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${ZPOOL_DEVICES}
82         ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${ZPOOL_DEVICES} || exit 1
83 }
84
85 zpool_destroy() {
86         msg ${ZPOOL} destroy ${ZPOOL_NAME}
87         ${ZPOOL} destroy ${ZPOOL_NAME}
88 }