Adventures in ZFS: Splitting a Zpool

Adventures in ZFS: Splitting a Zpool

Today we are going to go through the process of splitting a zpool.  This is not something that you will do often, but when you do it, you must be very precise and do it properly.

Create Our Test Zpool

First we will create a ZFS to hold our disk images.

# zfs create rpool/testdisks

Next we will create the disk images.

# mkfile 1g /rpool/testdisks/disk0
# mkfile 1g /rpool/testdisks/disk1
# mkfile 1g /rpool/testdisks/disk2
# mkfile 1g /rpool/testdisks/disk3

Finally we will create our zpool, which in this case is tank.

# zpool create tank mirror /rpool/testdisks/disk0 /rpool/testdisks/disk1

Examine Our Zpool

Lets take a look at our zpool.

# zpool status

pool: tank
state: ONLINE
scan: none requested
config:

NAME STATE READ WRITE CKSUM
tank ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
/rpool/testdisks/disk0 ONLINE 0 0 0
/rpool/testdisks/disk1 ONLINE 0 0 0

Lets also check the guid, this is the identifier of the zpool, this must be unique on the system.

# zpool get guid tank
NAME PROPERTY VALUE SOURCE
tank guid 1170921204903719619 -

Expand Our Zpool

This step isn’t required, however I feel it is more illustrative of what we are doing if we have a larger pool.

# zpool add tank mirror /rpool/testdisks/disk2 /rpool/testdisks/disk3

Review the differences in the pool, since adding additional disks, notice we still have redundancy.

# zpool status tank
pool: tank
state: ONLINE
scan: none requested
config:

NAME STATE READ WRITE CKSUM
tank ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
/rpool/testdisks/disk0 ONLINE 0 0 0
/rpool/testdisks/disk1 ONLINE 0 0 0
mirror-1 ONLINE 0 0 0
/rpool/testdisks/disk2 ONLINE 0 0 0
/rpool/testdisks/disk3 ONLINE 0 0 0

errors: No known data errors

Split the Zpool

Now we will split the pool.

# zpool split tank tank2 /rpool/testdisks/disk1 /rpool/testdisks/disk3

Import the Second Zpool

Since we used the split command we are able to import the second pool as it now has a different guid.

# zpool import -d /rpool/testdisks/
pool: tank2
id: 2770700438906871327
state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:

tank2 ONLINE
/rpool/testdisks/disk1 ONLINE
/rpool/testdisks/disk3 ONLINE
# zpool import -d /rpool/testdisks/ tank2

Compare the Guids of the Zpools

Lets confirm that the GUIDs are in fact different.

# zpool get guid tank
NAME PROPERTY VALUE SOURCE
tank guid 1170921204903719619 -
# # zpool get guid tank2
NAME PROPERTY VALUE SOURCE
tank2 guid 2770700438906871327 -

There you go those are definitely different.