Go to main content

Managing ZFS File Systems in Oracle® Solaris 11.4

Exit Print View

Updated: July 2019
 
 

Replacing Disks in a ZFS Root Pool

You might need to replace a disk in the root pool for the following reasons:

  • The root pool is too small and you want to replace it with a larger disk

  • The root pool disk is failing. In a non-redundant pool, if the disk is failing and the system no longer boots, boot from another source such as a CD or the network. Then, replace the root pool disk.

You can replace disks by using one of two methods:

  • Using the zpool replace command.

    This method involves scrubbing and clearing the root pool of dirty time logs (DTLs), then replacing the disk. After the new disk is installed, you apply the boot blocks manually.

  • Using the zpool detach|attach commands.

    This method involves attaching the new disk and verifying that it is working properly, then detaching the faulty disk.

If you are replacing root pool disks that have the SMI (VTOC) label, ensure that you fulfill the following requirements:

How to Replace a Disk in a ZFS Root Pool

This procedure uses the zpool attach|detach commands to replace the disk.

  1. Physically connect the replacement disk.
  2. Attach the new disk to the root pool.
    $ zpool attach root-pool current-disk new-disk

    Where current-disk becomes old-disk to be detached at the end of this procedure.

    The correct disk labeling and the boot blocks are applied automatically.


    Note -  If the disks have SMI (VTOC) labels, make sure that you include the slice when specifying the disk, such as c2t0d0s0.
  3. View the root pool status to confirm that resilvering is complete.

    If resilvering has been completed, the output includes a message similar to the following:

    scan: resilvered 11.6G in 0h5m with 0 errors on Fri Jul 20 13:57:25 2014
  4. Verify that you can boot successfully from the new disk.
  5. After a successful boot, detach the old disk.
    $ zpool detach root-pool old-disk

    Where old-disk is the current-disk of Step 2.


    Note -  If the disks have SMI (VTOC) labels, make sure that you include the slice when specifying the disk, such as c2t0d0s0.
  6. If the attached disk is larger than the existing disk, enable the ZFS autoexpand property.
    $ zpool set autoexpand=on root-pool
  7. Set the system to boot automatically from the new disk.
    • SPARC: Use either the eeprom command or the setenv command from the boot PROM.

    • x86: Reconfigure the system BIOS.

  8. If necessary, physically remove the replaced disk from the system.
Example 19  Replacing a Disk in a ZFS Root Pool (SPARC or x86/EFI (GPT)

This example replaces c2t0d0 in the root pool named rpool by using the zpool attach|detach commands. It assumes that the replacement disk c2t1d0 is already physically connected to the system.

$ zpool attach rpool c2t0d0 c2t1d0
Make sure to wait until resilver is done before rebooting.

$ zpool status rpool
pool: rpool 
state: ONLINE 
scan: resilvered 11.7G in 0h5m with 0 errors on Fri Jul 20 13:45:37 2012 
config:

NAME         STATE   READ  WRITE  CKSUM
rpool        ONLINE     0      0      0
  mirror-0   ONLINE     0      0      0
    c2t0d0   ONLINE     0      0      0
    c2t1d0   ONLINE     0      0      0 

errors: No known data errors

After completing the boot test from the new disk c2t1d0, you would detach c2t0d0 and, if necessary, enable the autoexpand property.

$ zpool detach rpool c2t0d0
$ zpool list rpool
NAME   SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
rpool  29.8G   152K  29.7G   0%  1.00x  ONLINE  -
$ zpool set autoexpand=on rpool
$ zpool list rpool
NAME   SIZE  ALLOC  FREE  CAP  DEDUP  HEALTH  ALTROOT
rpool  279G   146K  279G   0%  1.00x  ONLINE  -

You would complete the operation by setting the system to automatically boot from the new disk.

Example 20  Replacing SATA Disks in a Root Pool (SPARC or x86/EFI (GPT))

This example replaces c1t0d0 by using the zpool replace command.

Systems with SATA disks require that before replacing a failed disk with the zpool replace command, you take the disk offline and unconfigure it. As a best practice, scrub and clear the root pool first before replacing the disk.

Suppose that you are replacing c1t0d0 on the system. You would issue the following commands:

$ zpool scrub rpool
$ zpool clear rpool
$ zpool offline rpool c1t0d0
$ cfgadm -c unconfigure c1::dsk/c1t0d0

At this point, you would physically remove the failed disk c1t0d0 and insert the replacement disk on the same slot. Thus, the new disk is still c1t0d0. On some hardware, you do not have to bring the disk online or reconfigure the replacement disk after it is inserted.

$ cfgadm -c configure c1::dsk/c1t0d0
$ zpool online rpool c1t0d0
$ zpool replace rpool c1t0d0
$ zpool status rpool

After resilvering is completed, you would install the boot blocks.

$ bootadm install-bootloader
Example 21  Replacing a Disk in a ZFS Root Pool (SPARC or x86/VTOC)

This example uses the zpool attach|detach commands to replace c2t0d0s0 in the root pool named rpool. It assumes that the replacement disk c2t1d0s0 is already physically connected to the system.

$ zpool attach rpool c2t0d0s0 c2t1d0s0
Make sure to wait until resilver is done before rebooting.

$ zpool status rpool
pool: rpool 
state: ONLINE 
scan: resilvered 11.7G in 0h5m with 0 errors on Fri Jul 20 13:45:37 2012 
config:

NAME         STATE   READ  WRITE  CKSUM
rpool        ONLINE     0      0      0
  mirror-0   ONLINE     0      0      0
    c2t0d0s0 ONLINE     0      0      0
    c2t1d0s0 ONLINE     0      0      0 

errors: No known data errors

You would test booting from the new disk c2t1d0s0. You would also test booting from the old disk c2t0d0s0 in case c2t1d0s0 fails.

ok boot /pci@1f,700000/scsi@2/disk@1,0

ok boot /pci@1f,700000/scsi@2/disk@0,0

After completing the boot tests, you would detach c2t0d0s0 and, if necessary, enable the autoexpand property.

$ zpool detach rpool c2t0d0s0
$ zpool list rpool
NAME   SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
rpool  29.8G   152K  29.7G   0%  1.00x  ONLINE  -
$ zpool set autoexpand=on rpool
$ zpool list rpool
NAME   SIZE  ALLOC  FREE  CAP  DEDUP  HEALTH  ALTROOT
rpool  279G   146K  279G   0%  1.00x  ONLINE  -

You would complete the operation by setting the system to automatically boot from the new disk.

Example 22  Replacing SATA Disks in a Root Pool (SPARC or x86 (VTOC))

This example replaces c1t0d0 by using the zpool replace command.

Systems with SATA disks require that before replacing a failed disk with the zpool replace command, you take the disk offline and unconfigure it. As a best practice, scrub and clear the root pool first before replacing the disk.

Suppose that you are replacing c1t0d0 on the system. You would issue the following commands:

$ zpool scrub rpool
$ zpool clear rpool
$ zpool offline rpool c1t0d0s0
$ cfgadm -c unconfigure c1::dsk/c1t0d0

At this point, you would physically remove the failed disk c1t0d0 and insert the replacement disk on the same slot. Thus the new disk is still c1t0d0. On some hardware, you do not have to bring the disk online or reconfigure the replacement disk after it is inserted.

$ cfgadm -c configure c1::dsk/c1t0d0

After confirming that the replacement disk c1t0d0s0 has an SMI label and a slice 0, you would issue the zpool replace command and proceed with the replacement process.

$ zpool replace rpool c1t0d0s0
$ zpool online rpool c1t0d0s0
$ zpool status rpool

After resilvering is completed, you install the boot blocks.

$ bootadm install-bootloader