Home NAS, Part 2: Replacing Disks and Adding Storage
July 21, 2016

There are two ways to expand the capacity of a zpool: replace every disk with larger ones or add vdevs to the pool. It is good to practice these scenarios when your dataset is newly created and not storing critical data yet.

Replace each disk

ZFS can use files instead of physical disks and I will be using them for demonstration purposes. Starting with two files in a mirrored vdev configuration, it is possible to increase the total storage available to the pool by replacing each of the files with larger files.

    sudo zpool create testpool mirror /home/gary/file.1 /home/gary/file.2
    
    sudo zpool list
    NAME       SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
    testpool   992M    50K   992M         -     0%     0%  1.00x  ONLINE  -
  

Create two larger files to be used as replacements:

    dd if=/dev/zero of=/home/gary/file.3 bs=1024k count=2000
    dd if=/dev/zero of=/home/gary/file.4 bs=1024k count=2000
  

Replace the old files:

    sudo zpool replace testpool /home/gary/file.1 /home/gary/file.3
    sudo zpool replace testpool /home/gary/file.2 /home/gary/file.4
  

Update the configuration:

    sudo zpool set autoexpand=off testpool
    sudo zpool set autoexpand=on testpool
    sudo zpool online -e testpool /home/gary/file.3
    sudo zpool online -e testpool /home/gary/file.4
  

Check the pool:

    sudo zpool list

    NAME       SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
    testpool  1.94G   122K  1.94G         -     0%     0%  1.00x  ONLINE  -
  

The pool is now showing double the capacity at 1.94G.

Add more vdevs to the pool

Starting back at the original setup:

    sudo zpool destroy testpool
    sudo zpool create testpool mirror /home/gary/file.1 /home/gary/file.2
    sudo zpool status

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

    NAME                   STATE     READ WRITE CKSUM
    testpool               ONLINE       0     0     0
      mirror-0             ONLINE       0     0     0
        /home/gary/file.1  ONLINE       0     0     0
        /home/gary/file.2  ONLINE       0     0     0

    errors: No known data errors
  

Add a new vdev with the other 2GB files:

    sudo zpool add testpool mirror /home/gary/file.3 /home/gary/file.4
    sudo zpool list

    NAME       SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
    testpool  2.91G   100K  2.91G         -     0%     0%  1.00x  ONLINE  -

    sudo zpool status

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

    NAME                   STATE     READ WRITE CKSUM
        testpool               ONLINE       0     0     0
          mirror-0             ONLINE       0     0     0
            /home/gary/file.1  ONLINE       0     0     0
            /home/gary/file.2  ONLINE       0     0     0
          mirror-1             ONLINE       0     0     0
            /home/gary/file.3  ONLINE       0     0     0
            /home/gary/file.4  ONLINE       0     0     0

    errors: No known data errors
  

The pool is now showing 992M (mirror-0) + 1.94G (mirror-1) = 2.91G (testpool)



© 2016 |