Print this page
Modernize CDDL license text and copyrights for OmniTI-original code.
Checkpoint for find-and-install
Generalize rpool to variable RPOOL in disk_help.sh
        
*** 1,31 ****
  #!/usr/bin/bash
  #
! # CDDL HEADER START
  #
! # The contents of this file are subject to the terms of the
! # Common Development and Distribution License, Version 1.0 only
! # (the "License").  You may not use this file except in compliance
! # with the License.
  #
! # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
! # or http://www.opensolaris.org/os/licensing.
! # See the License for the specific language governing permissions
! # and limitations under the License.
  #
! # When distributing Covered Code, include this CDDL HEADER in each
! # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
! # If applicable, add the following below this CDDL HEADER, with the
! # fields enclosed by brackets "[]" replaced with your own identifying
! # information: Portions Copyright [yyyy] [name of copyright owner]
  #
! # CDDL HEADER END
! #
! #
! # Copyright 2012 OmniTI Computer Consulting, Inc.  All rights reserved.
! # Use is subject to license terms.
! #
  ListDisks() {
    declare -A disksize
    declare -A diskname
    for rdsk in $(prtconf -v | grep dev_link | awk -F= '/\/dev\/rdsk\/c.*p0/{print $2;}')
    do
--- 1,22 ----
  #!/usr/bin/bash
+ 
  #
! # This file and its contents are supplied under the terms of the
! # Common Development and Distribution License ("CDDL"), version 1.0.
! # You may only use this file in accordance with the terms of version
! # 1.0 of the CDDL.
  #
! # A full copy of the text of the CDDL should have accompanied this
! # source.  A copy of the CDDL is also available via the Internet at
! # http://www.illumos.org/license/CDDL.
  #
! 
  #
! # Copyright 2017 OmniTI Computer Consulting, Inc.  All rights reserved.
  #
! 
  ListDisks() {
    declare -A disksize
    declare -A diskname
    for rdsk in $(prtconf -v | grep dev_link | awk -F= '/\/dev\/rdsk\/c.*p0/{print $2;}')
    do
*** 90,106 ****
    for term in $*; do
      ListDisksAnd $term
    done | sort | uniq | xargs
  }
  
! BuildRpool() {
    ztype=""
    ztgt=""
    disks=`ListDisksUnique $*`
!   log "Disks being used for rpool: $disks"
    if [[ -z "$disks" ]]; then
!     bomb "No matching disks found to build rpool"
    fi
    rm -f /tmp/kayak-disk-list
    for i in $disks
    do
      if [[ -n "$ztgt" ]]; then
--- 81,97 ----
    for term in $*; do
      ListDisksAnd $term
    done | sort | uniq | xargs
  }
  
! BuildRpoolOnly() {
    ztype=""
    ztgt=""
    disks=`ListDisksUnique $*`
!   log "Disks being used for root pool $RPOOL: $disks"
    if [[ -z "$disks" ]]; then
!     bomb "No matching disks found to build root pool $RPOOL"
    fi
    rm -f /tmp/kayak-disk-list
    for i in $disks
    do
      if [[ -n "$ztgt" ]]; then
*** 108,122 ****
      fi
      ztgt="$ztgt ${i}"
      # Keep track of disks for later...
      echo ${i} >> /tmp/kayak-disk-list
    done
!   log "zpool destroy rpool (just in case we've been run twice)"
!   zpool destroy rpool 2> /dev/null
!   log "Creating rpool with: zpool create -f rpool $ztype $ztgt"
    # Just let "zpool create" do its thing. We want GPT disks now.
!   zpool create -f rpool $ztype $ztgt || bomb "Failed to create rpool"
    BuildBE
  }
  GetTargetVolSize() {
      # Aim for 25% of physical memory (minimum 1G)
      # prtconf always reports in megabytes
--- 99,116 ----
      fi
      ztgt="$ztgt ${i}"
      # Keep track of disks for later...
      echo ${i} >> /tmp/kayak-disk-list
    done
!   log "zpool destroy $RPOOL (just in case we've been run twice)"
!   zpool destroy $RPOOL 2> /dev/null
!   log "Creating root pool with: zpool create -f $RPOOL $ztype $ztgt"
    # Just let "zpool create" do its thing. We want GPT disks now.
!   zpool create -f $RPOOL $ztype $ztgt || bomb "Failed to create root pool $RPOOL"
! }
! BuildRpool() {
!   BuildRpoolOnly $*
    BuildBE
  }
  GetTargetVolSize() {
      # Aim for 25% of physical memory (minimum 1G)
      # prtconf always reports in megabytes
*** 128,138 ****
          local vsize=`printf %0.f $quart`
      fi
      echo $vsize
  }    
  GetRpoolFree() {
!     local zfsavail=`/sbin/zfs list -H -o avail rpool`
      if [[ ${zfsavail:(-1)} = "G" ]]; then
          local avail=`printf %0.f ${zfsavail::-1}`
      elif [[ ${zfsavail:(-1)} = "T" ]]; then
          local gigs=`echo "scale=1;${zfsavail::-1}*1024" | /bin/bc`
          avail=`printf %0.f $gigs`
--- 122,132 ----
          local vsize=`printf %0.f $quart`
      fi
      echo $vsize
  }    
  GetRpoolFree() {
!     local zfsavail=`/sbin/zfs list -H -o avail $RPOOL` 
      if [[ ${zfsavail:(-1)} = "G" ]]; then
          local avail=`printf %0.f ${zfsavail::-1}`
      elif [[ ${zfsavail:(-1)} = "T" ]]; then
          local gigs=`echo "scale=1;${zfsavail::-1}*1024" | /bin/bc`
          avail=`printf %0.f $gigs`
*** 169,180 ****
          finalsize=$size
          savecore="-y"
      fi
  
      for volname in swap dump; do
!         /sbin/zfs create -V ${finalsize}G rpool/$volname || \
!             bomb "Failed to create rpool/$volname"
      done
!     printf "/dev/zvol/dsk/rpool/swap\t-\t-\tswap\t-\tno\t-\n" >> $ALTROOT/etc/vfstab
!     Postboot /usr/sbin/dumpadm $savecore -d /dev/zvol/dsk/rpool/dump
      return 0
  }
--- 163,174 ----
          finalsize=$size
          savecore="-y"
      fi
  
      for volname in swap dump; do
!         /sbin/zfs create -V ${finalsize}G $RPOOL/$volname || \
!             bomb "Failed to create $RPOOL/$volname"
      done
!     printf "/dev/zvol/dsk/$RPOOL/swap\t-\t-\tswap\t-\tno\t-\n" >> $ALTROOT/etc/vfstab
!     Postboot /usr/sbin/dumpadm $savecore -d /dev/zvol/dsk/$RPOOL/dump
      return 0
  }