Tuesday, November 27, 2012

Re-create a ZFS Root Pool and Restore Root Pool Snapshots


All the steps are performed on the local system.
  1. Boot from an installation DVD or the network.
    • SPARC - Select one of the following boot methods:
      ok boot net -s
      ok boot cdrom -s
      If you don't use -s option, you'll need to exit the installation program.
    • x86 – Select the option for booting from the DVD or the network. Then, exit the installation program.
  2. Mount the remote snapshot file system if you have sent the root pool snapshots as a file to the remote system.For example:
    # mount -F nfs remote-system:/rpool/snaps /mnt
    If your network services are not configured, you might need to specify the remote-system's IP address.
  3. If the root pool disk is replaced and does not contain a disk label that is usable by ZFS, you must relabel the disk.
  4. Relabeling the Root Pool Disk

    You might need to replace a disk in the root pool for the following reasons:
  5. The root pool is too small and you want to replace it with a larger disk
  6. The root pool disk is failing. If the disk is failing so that the system won't boot, you'll need to boot from an alternate media, such as a CD or the network, before you replace the root pool disk.
Part of recovering the root pool might be to replace or relabel the root pool disk. Follow the steps below to relabel and replace the root pool disk.
  1. Physically attach the replacement disk.
  2. If the replacement disk has an EFI label, the fdisk output looks similar to the following on an x86 system.
    # fdisk /dev/rdsk/c1t1d0p0
    selecting c1t1d0p0
      Total disk size is 8924 cylinders
                 Cylinder size is 16065 (512 byte) blocks
    
                                                   Cylinders
          Partition   Status    Type          Start   End   Length    %
          =========   ======    ============  =====   ===   ======   ===
              1                 EFI               0  8924    8925    100
    .
    .
    .
    Enter Selection: 6
    Use fdisk to change this to a Solaris partition.
  3. Select one of the following to create a Solaris fdisk partition for a disk on an x86 system or create an SMI label for a disk on a SPARC system.
    • On an x86 system, create a Solaris fdisk partition that can be used for booting by selecting 1=SOLARIS2. You can create a Solaris partition by using the fdisk -B option that creates one Solaris partition that uses the whole disk. Beware that the following command uses the whole disk.
      # fdisk -B /dev/rdsk/c1t1d0p0
      Display the newly created Solaris partition. For example:
       Total disk size is 8924 cylinders
                   Cylinder size is 16065 (512 byte) blocks
      
                                                     Cylinders
            Partition   Status    Type          Start   End   Length    %
            =========   ======    ============  =====   ===   ======   ===
                1       Active    Solaris2          1  8923    8923    100
      .
      .
      .
      Enter Selection: 6
    • On a SPARC based system, make sure you have an SMI label. Use the format -e command to determine if the disk label is EFI or SMI and relabel the disk, if necessary. In the output below, the disk label includes sectors and not cylinders. This is an EFI label.
      # format -e
      Searching for disks...done
      AVAILABLE DISK SELECTIONS:
             0. c1t0d0 
                /pci@8,600000/SUNW,qlc@4/fp@0,0/ssd@w21000004cf7fac8a,0
             1. c1t1d0 
                /pci@8,600000/SUNW,qlc@4/fp@0,0/ssd@w21000004cf7fad21,0
      Specify disk (enter its number): 1
      selecting c1t1d0
      [disk formatted]
      format> p
      partition> p
      Current partition table (original):
      Total disk sectors available: 71116541 + 16384 (reserved sectors)
      
      Part      Tag    Flag     First Sector        Size        Last Sector
        0        usr    wm                34      33.91GB         71116541    
        1 unassigned    wm                 0          0              0    
        2 unassigned    wm                 0          0              0    
        3 unassigned    wm                 0          0              0    
        4 unassigned    wm                 0          0              0    
        5 unassigned    wm                 0          0              0    
        6 unassigned    wm                 0          0              0    
        7 unassigned    wm                 0          0              0    
        8   reserved    wm          71116542       8.00MB         71132925    
      partition> label
      [0] SMI Label
      [1] EFI Label
      Specify Label type[1]: 0
      Auto configuration via format.dat[no]? 
      Auto configuration via generic SCSI-2[no]? 
      partition>  
  1. Re-create the root pool.For example:
    # zpool create -f -o failmode=continue -R /a -m legacy -o cachefile=
    /etc/zfs/zpool.cache rpool c1t1d0s0
  2. Restore the root pool snapshots.This step might take some time. For example:
    # cat /mnt/rpool.0804 | zfs receive -Fdu rpool
    Using the -u option means that the restored archive is not mounted when the zfs receive operation completes.
    To restore the actual root pool snapshots that are stored in a pool on a remote system, use syntax similar to the following:
    # rsh remote-system zfs send -Rb tank/snaps/rpool@snap1 | zfs receive -F rpool
  3. Verify that the root pool datasets are restored.For example:
    # zfs list
  4. Set the bootfs property on the root pool BE.For example:
    # zpool set bootfs=rpool/ROOT/zfsBE rpool
  5. Install the boot blocks on the new disk.
    • SPARC:
      # installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c1t1d0s0
    • x86:
      # installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1t1d0s0
  6. Reboot the system.
    # init 6

No comments:

Post a Comment