ZFS Extend ZFS mirror volume

circus78

Active Member

Reaction score: 7
Messages: 204

Hi,
I am using FreeBSD 11.0-RELEASE-p1.
I have mirrored zpool volume:

Code:
# zpool status
  pool: zroot
 state: ONLINE
  scan: none requested
config:

        NAME         STATE     READ WRITE CKSUM
        zroot        ONLINE       0     0     0
          mirror-0   ONLINE       0     0     0
            mfid0p3  ONLINE       0     0     0
            mfid1p3  ONLINE       0     0     0

errors: No known data errors
Code:
# df -h
Filesystem            Size    Used   Avail Capacity  Mounted on
zroot/ROOT/default    1.9T    1.3T    607G    69%    /
devfs                 1.0K    1.0K      0B   100%    /dev
zroot/tmp             607G    128K    607G     0%    /tmp
zroot/usr/home        607G    320K    607G     0%    /usr/home
zroot/usr/ports       607G     96K    607G     0%    /usr/ports
zroot/usr/src         607G     96K    607G     0%    /usr/src
zroot/var/audit       607G     96K    607G     0%    /var/audit
zroot/var/crash       607G     96K    607G     0%    /var/crash
zroot/var/log         607G    800K    607G     0%    /var/log
zroot/var/mail        607G     96K    607G     0%    /var/mail
zroot/var/tmp         607G     96K    607G     0%    /var/tmp
zroot                 607G     96K    607G     0%    /zroot
I need to replace two physical disks with bigger ones (from 2 TB to 4 TB each).
What is the correct way to do this?
Thank you!
 

phoenix

Administrator
Staff member
Administrator
Moderator

Reaction score: 1,205
Messages: 4,044

If you have empty drive bays and connectors, the "best" way to do it is:
Code:
<attach new drive, comes up as something like mfid1>
<partition it in a similar fashion as the others>
# zpool attach zroot mfid0p3 mfid2p3
<wait for it to resilver>
# zpool detach zroot mfid0p3
Repeat for the other drive.

This converts the 2-way mirror vdev into a 3-way mirror vdev, does the resilver, then converts it back to a 2-way mirror vdev. This way, you never lose redundancy in the vdev.

Once both drives have been replaced, then you may need to tell the pool to use the extra space:
Code:
# zpool online -e zroot mfid0p3
# zpool online -e zroot mdid1p3
 
OP
OP
C

circus78

Active Member

Reaction score: 7
Messages: 204

Hi phoenix, unfortunately I have no other bays.
Is it possible to do this in a different way (I mean: replacing one physical disk at time)?
Thank you very much
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 6,926
Messages: 28,850

Is it possible to do this in a different way (I mean: replacing one physical disk at time)?
Yes. I've done this with a 4 disk RAID-Z but a mirror should work the same. Offline one of the drives, physically remove it, replace with bigger. Wait for resilver to complete, repeat for the other drive.

Once both disks have been replaced and synced, use gpart resize to extend the freebsd-zfs partitions.

I am using FreeBSD 11.0-RELEASE-p1.
Plan your updates. FreeBSD 11.0 has been End-of-Life since November 2017 and is not supported any more.
 

phoenix

Administrator
Staff member
Administrator
Moderator

Reaction score: 1,205
Messages: 4,044

Hi phoenix, unfortunately I have no other bays.
Is it possible to do this in a different way (I mean: replacing one physical disk at time)?
Thank you very much
Code:
# zpool offline zroot mfid0p3
<remove drive from bay 1>
<insert new drive into bay 1>
<partition new drive same as the others, but with the extra space>
# zpool replace zroot mfid0p3
<wait for it to resilver>
Repeat for the drive in bay 2.

Code:
# zpool online -e mfid0p3
# zpool online -e mfid1p3
Voila!

Be sure to install the boot code onto the new drives, otherwise you won't be able to boot. :)
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 6,926
Messages: 28,850

It might not have been obvious but make sure to copy the partition tables to the new disk before adding it back to the pool. And make sure you're replacing mfid1p3, not mfid1.
 
Top