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