Project

General

Profile

pool-replace.sh

Richard Kojedzinszky, 02/21/2017 03:17 AM

 
1
#!/bin/sh
2

    
3
create_dev()
4
{
5
	local size="$1"
6
	local dev=$(mdconfig -a -t swap -s $size)
7
	
8
	gpart create -s gpt $dev > /dev/null
9
	gpart add -t freebsd-zfs $dev > /dev/null
10

    
11
	echo "${dev}"
12
}
13

    
14
destroy_dev()
15
{
16
	local dev="$1"
17

    
18
	mdconfig -d -u $dev
19
}
20

    
21
d0=$(create_dev 200M)
22
d1=$(create_dev 100M)
23
d2=$(create_dev 100M)
24

    
25
# create the pool with different sized members, the pool size will be the min
26
zpool create -f pool mirror ${d0}p1 ${d1}p1
27
zpool detach pool ${d1}p1
28
zpool attach pool ${d0}p1 ${d2}p1
29

    
30
zpool export pool
31
destroy_dev $d2
32
destroy_dev $d1
33
destroy_dev $d0