Software >> OS >> Unix >> Solaris >> 11 >> ZFS >> How to expand root pool (rpool) by attaching and migrating to a bigger disk


## Our test environment is using IDE disk c1d0 of size 30GB as the ZFS root pool
## we have added a new IDE disk c1d1 of size 100GB
## we want to attach c1d1 to create a mirror with c1d0
## then split the mirror and then detach c1d0

## List the available disks

root@solaris11:~# echo | format
Searching for disks...done


AVAILABLE DISK SELECTIONS:
       0. c1d0 <VBOX HAR-8d863925-302723f-0001-31.25GB>
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
       1. c1d1 <VBOX HAR-66d06e8c-40fd842-0001-100.00GB>
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0
Specify disk (enter its number): Specify disk (enter its number):


## attach 2nd disk to create zfs mirror

root@solaris11:~# zpool attach rpool c1d0 c1d1
Make sure to wait until resilver is done before rebooting.


## Check status continously until resilvering of the new disk is completed

root@solaris11:~# zpool status
  pool: rpool
 state: ONLINE
  scan: resilvered 8.85G in 1m43s with 0 errors on Sat Jun  4 21:28:25 2022

config:

        NAME        STATE      READ WRITE CKSUM
        rpool       ONLINE        0     0     0
          mirror-0  ONLINE        0     0     0
            c1d0    ONLINE        0     0     0
            c1d1    ONLINE        0     0     0

errors: No known data errors



## Reboot to confirm the mirror works

root@solaris11:~# reboot


## Detach the 1st disk (c1d0) from the mirror

root@solaris11:~# zpool split rpool oldrpool c1d0


## Check status

root@solaris11:~# zpool status
  pool: rpool
 state: ONLINE
  scan: resilvered 8.85G in 1m43s with 0 errors on Sat Jun  4 21:28:25 2022

config:

        NAME    STATE      READ WRITE CKSUM
        rpool   ONLINE        0     0     0
          c1d1  ONLINE        0     0     0

errors: No known data errors


## Show current size

root@solaris11:~# zpool list
NAME    SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
rpool  30.8G  12.9G  17.9G  41%  1.00x  ONLINE  -


## Enable zfs autoexpand

root@solaris11:~# zpool set autoexpand=on rpool


## Check the size again
## notice it has expanded to use all available space

root@solaris11:~# zpool list
NAME    SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
rpool  99.5G  12.9G  86.6G  12%  1.00x  ONLINE  -


## The following is yet to be verified if necessary
## Install the boot loader on the new disk
## for solaris x86_64 version 11.1 onwards

root@solaris11:~# bootadm install-bootloader -P rpool


## for solaris x86_64 version 11.0 or earlier

root@solaris11:~# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1d1