Discussion:
Convert Raid-Z to Mirror
Brian King
2007-09-14 18:45:27 UTC
Permalink
Is there a way to convert a 2 disk raid-z file system to a mirror without backing up the data and restoring?

We have this:

bash-3.00# zpool status
pool: archives
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
archives ONLINE 0 0 0
raidz1 ONLINE 0 0 0
c1t2d0 ONLINE 0 0 0
c1t3d0 ONLINE 0 0 0

... and what I would like to be able to do is to:

- remove c1t3d0 from the raidz, leaving it in degraded mode momentarily.
- Create a new pool with the single disk c1t3d0
- copy the data from the current pool to the new pool
- destroy the current pool
- attach c1t2d0 to the new pool, creating a mirror

I can't seem to find any way to remove c1t3d0 from the raidz pool. The best I can do is "offline" it, which proves the pool can still run without the disk, but I can't seem to free the disk.

Any ideas?

Brian


This message posted from opensolaris.org
Patrick Bachmann
2007-09-14 19:49:38 UTC
Permalink
Hello Brian,
Post by Brian King
Is there a way to convert a 2 disk raid-z file system to a mirror without backing up the data and restoring?
Currently there isn't a way to do this without having some
additional buffer disk space available.
What you can do is attach some vdev to your current raidz. This
will create a mirror. After the resync, detach your raidz, do
whatever you want to do, like attach the first disk of your
raidz. Now you may either detach your buffer-vdev or attach the
second disk from your former raidz. The order doesn't really
matter that much. And you have moved your pool around without
backing up the data.
You have to watch the exact sizes of the disks/vdev though, since
the space in a mirror only occupies the size of the smallest
vdev and grows with the size of the smallest vdev.
Last weekend, I had to move a pool around and attached an
external USB-drive with a disk considerably larger than my zpool.
So I created a zpool on the disk and used a zvol as the
buffer-vdev.

HTH,

Patrick
Brian King
2007-09-15 14:05:02 UTC
Permalink
Thanks for your idea. That would be useful if we had the extra space. After playing with a test zpool for a bit, I found that this also works, but you have to make the pool unavailable for a while. I'm just posting it in case it helps someone else.

- destroy the raidz pool
- reuse one of the disks in a new pool
- recover the raidz pool in degraded mode
- copy the files to the new pool
- destroy the original pool again
- attach the final disk to the new pool as a mirror

e.g.

# mkfile 64m a
# mkfile 64m b
# zpool create raidz temp `pwd`/a `pwd`/b
# echo test >/temp/test
# cat /temp/test
test
# zpool destroy temp
# zpool create -f temp2 `pwd`/b # note -f to force to overwrite 1/2 of old pool
# zpool import -d `pwd` temp
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
temp 119M 453K 119M 0% DEGRADED -
temp2 59.5M 83.5K 59.4M 0% ONLINE -

# cat /temp/test
test
# mv /temp/* /temp
# zpool destroy temp
# zpool attach temp2 `pwd`/b `pwd`/a


I would recommend Patrick's suggestion or backing up and restoring (if those options are available) though. This way is riskier since there are times when your data is unavailable and depending on a recover to bring it back.


This message posted from opensolaris.org
Brian King
2007-10-04 18:45:51 UTC
Permalink
Update to this. Before destroying the original pool the first time, offline the disk you plan on re-using in the new pool. Otherwise when you destroy the original pool for the second time it causes issues with the new pool. In fact, if you attempt to destroy the new pool immediately after destroying the original pool, the system will panic.


This message posted from opensolaris.org

Continue reading on narkive:
Loading...