Changeset 3018894


Ignore:
Timestamp:
08/12/13 05:56:37 (12 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
667321a
Parents:
ce67c5a
Message:

Large update to pc-sysinstall:

  • Improve how we create disk layouts for ZFS mirror/raidz disks
  • Do not blindly create a single freebsd-zfs partition
  • Create partition / sizes to match the parent disk
  • When adding freebsd-swap to a ZFS mirror/raidz parent, we will now setup gmirror on the swap devices and label it as such
Location:
src-sh/pc-sysinstall/backend
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src-sh/pc-sysinstall/backend/functions-bsdlabel.sh

    r68ab4df r3018894  
    105105{ 
    106106  _nZFS="" 
     107  SOUT="$4" 
    107108 
    108109  # Check if the target disk is using GRUB 
     
    127128    is_disk "$_zvars" >/dev/null 2>/dev/null 
    128129    if [ $? -eq 0 ] ; then 
     130 
     131      # Save this disk as one we want to clone the original disk setup to 
     132      ZFS_CLONE_DISKS="$ZFS_CLONE_DISKS ${_zvars}" 
     133      export ZFS_CLONE_DISKS 
     134 
    129135      echo "Setting up ZFS disk $_zvars" >>${LOGOUT} 
    130136      init_gpt_full_disk "$_zvars" "$_tBL" >/dev/null 2>/dev/null 
    131       rc_halt "gpart add -a 4k -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null 
     137      #rc_halt "gpart add ${SOUT} -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null 
    132138 
    133139      # If we are not using GRUB we need to add pmbr / gptzfsboot 
     
    140146    fi   
    141147  done 
    142   echo "$ZTYPE $2 `echo $_nZFS | tr -s ' '`" 
     148 
     149  # Export the ZXTRAOPTS 
     150  ZXTRAOPTS="$ZTYPE $2 `echo $_nZFS | tr -s ' '`" 
     151  export ZXTRAOPTS 
    143152} ; 
    144153 
     
    243252    fi 
    244253  fi 
     254 
     255  # Unset ZFS_CLONE_DISKS 
     256  #ZFS_CLONE_DISKS="" 
    245257 
    246258  while read line 
     
    372384      if [ $? -eq 0 -a "$FS" = "ZFS" ] ; then 
    373385        if [ "${_pType}" = "gpt" -o "${_pType}" = "gptslice" ] ; then 
    374           XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}" "${_pDisk}") 
     386          setup_zfs_mirror_parts "${XTRAOPTS}" "${_pDisk}p${CURPART}" "${_pDisk}" "${SOUT}" 
     387          XTRAOPTS="${ZXTRAOPTS}" 
    375388        elif [ "${_pType}" = "apm" ] ; then 
    376           XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}s${CURPART}" "${_pDisk}") 
     389          setup_zfs_mirror_parts "${XTRAOPTS}" "${_pDisk}s${CURPART}" "${_pDisk}" "${SOUT}" 
     390          XTRAOPTS="${ZXTRAOPTS}" 
    377391        else 
    378           XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}${PARTLETTER}" "${_pDisk}") 
     392          setup_zfs_mirror_parts "${XTRAOPTS}" "${_wSlice}${PARTLETTER}" "${_pDisk}" "${SOUT}" 
     393          XTRAOPTS="${ZXTRAOPTS}" 
    379394        fi 
    380395      fi 
     
    389404      # Create the partition 
    390405      if [ "${_pType}" = "gpt" ] ; then 
    391         if [ "$CURPART" = "2" ] ; then 
    392           # If this is GPT, make sure first partition is aligned to 4k 
    393           sleep 2 
    394           rc_halt "gpart add -a 4k ${SOUT} -t ${PARTYPE} ${_pDisk}" 
    395         else 
    396           sleep 2 
    397           rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}" 
    398         fi 
     406        sleep 2 
     407        aCmd="gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}" 
    399408      elif [ "${_pType}" = "gptslice" ]; then 
    400409        sleep 2 
    401         rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_wSlice}" 
     410        aCmd="gpart add ${SOUT} -t ${PARTYPE} ${_wSlice}" 
    402411      elif [ "${_pType}" = "apm" ]; then 
    403412        sleep 2 
    404         rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}" 
     413        aCmd="gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}" 
    405414      else 
    406415        sleep 2 
     
    413422           aOpt="-a 512b" 
    414423        fi 
    415         rc_halt "gpart add ${SOUT} ${aOpt} -t ${PARTYPE} -i ${CURPART} ${_wSlice}" 
     424        aCmd="gpart add ${SOUT} ${aOpt} -t ${PARTYPE} -i ${CURPART} ${_wSlice}" 
     425      fi 
     426 
     427      # Run the gpart add command now 
     428      rc_halt "$aCmd" 
     429 
     430      # Check if we need to clone this layout to a ZFS mirror/raidz disk 
     431      if [ -n "$ZFS_CLONE_DISKS" ] ; then 
     432         for zC in $ZFS_CLONE_DISKS 
     433         do 
     434            echo_log "Cloning disk layout to ZFS disk ${zC}" 
     435            rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${zC}" 
     436            if [ "$PARTYPE" = "freebsd-swap" ] ; then 
     437               # If this is the first device, save the original swap dev 
     438               if [ -z "$ZFS_SWAP_DEVS" ] ; then 
     439                  ZFS_SWAP_DEVS="${_pDisk}p${CURPART}" 
     440               fi 
     441               # Save this swap device, we will gmirror it later 
     442               ZFS_SWAP_DEVS="${ZFS_SWAP_DEVS} ${zC}p${CURPART}" 
     443               export ZFS_SWAP_DEVS 
     444            fi 
     445         done 
    416446      fi 
    417447 
  • src-sh/pc-sysinstall/backend/functions-cleanup.sh

    rcce092d r3018894  
    388388  # Check if we need to run any gmirror setup 
    389389  ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null 
    390   if [ $? -eq 0 ] 
     390  if [ $? -eq 0 -o -n "$ZFS_SWAP_DEVS" ] 
    391391  then 
    392392    # Lets setup gmirror now 
  • src-sh/pc-sysinstall/backend/functions-disk.sh

    racdd4b9 r3018894  
    288288  for gprov in $GPROV  
    289289  do 
    290     gmirror list | grep -q "Name: ${DISK}" 2>/dev/null 
    291     if [ $? -eq 0 ] 
    292     then 
    293       echo_log "Stopping mirror $gprov $DISK" 
    294       rc_nohalt "gmirror remove $gprov $DISK" 
    295       rc_nohalt "dd if=/dev/zero of=/dev/${DISK} count=4096" 
    296     fi 
     290    dName=`gmirror list | grep -v 'mirror/' | grep "Name: " | awk '{print $3}'` 
     291    for rmDisk in $dName 
     292    do 
     293      echo_log "Stopping mirror $gprov $rmDisk" 
     294      rc_nohalt "gmirror remove $gprov $rmDisk" 
     295      rc_nohalt "dd if=/dev/zero of=/dev/${rmDisk} count=4096" 
     296    done 
    297297  done 
    298298}; 
  • src-sh/pc-sysinstall/backend/functions-mountdisk.sh

    r3f8cc13 r3018894  
    247247         ZFS) mount_partition ${PARTDEV} ${PARTFS} ${PARTMNT} ;; 
    248248         SWAP) 
     249 
     250                if [ -n "$ZFS_SWAP_DEVS" ] ; then 
     251                  SWAPDEV="/dev/mirror/swapmirror" 
     252                else 
     253                  SWAPDEV="$PARTDEV" 
     254                fi 
     255 
    249256                   # Lets enable this swap now 
    250257           if [ "$PARTENC" = "ON" ] 
    251258           then 
    252              echo_log "Enabling encrypted swap on ${PARTDEV}" 
    253              rc_halt "geli onetime -d -e 3des ${PARTDEV}" 
     259             echo_log "Enabling encrypted swap on ${SWAPDEV}" 
     260             rc_halt "geli onetime -d -e 3des ${SWAPDEV}" 
    254261             sleep 5 
    255              rc_halt "swapon ${PARTDEV}.eli" 
     262             rc_halt "swapon ${SWAPDEV}.eli" 
    256263           else 
    257              echo_log "swapon ${PARTDEV}" 
     264             echo_log "swapon ${SWAPDEV}" 
    258265             sleep 5 
    259              rc_halt "swapon ${PARTDEV}" 
     266             rc_halt "swapon ${SWAPDEV}" 
    260267            fi 
    261268            ;; 
  • src-sh/pc-sysinstall/backend/functions-newfs.sh

    rfe5d5c8 r3018894  
    257257      SWAP) 
    258258        rc_halt "sync" 
    259         rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}"  
     259        if [ -n "$ZFS_SWAP_DEVS" ] ; then 
     260          setup_gmirror_swap "$ZFS_SWAP_DEVS" 
     261          sleep 5 
     262          rc_halt "glabel label ${PARTLABEL} /dev/mirror/swapmirror"  
     263        else 
     264          rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}"  
     265        fi 
    260266        rc_halt "sync" 
    261267        sleep 2 
     
    272278  done 
    273279}; 
     280 
     281 
     282# Takes a list of args to setup as a swapmirror 
     283setup_gmirror_swap() 
     284{ 
     285  rc_halt "gmirror label swapmirror ${@}" 
     286} 
Note: See TracChangeset for help on using the changeset viewer.