Monday, February 3, 2014

MegaCli

Managing LSI Raid Cards
Docs:
General Parameters
  • Adapter parameter -aN
    The parameter -aN (where N is a number starting with zero or the string ALL) specifies the adapter ID. If you have only one controller it’s safe to use ALL instead of a specific ID, but you’re encouraged to use the ID for everything that make changes to your RAID configuration.
  • Physical drive parameter -PhysDrv [E:S]
    For commands that operate on one or more pysical drives, the -PhysDrv [E:S] parameter is used, where E is the enclosure device ID in which the drive resides and S the slot number (starting with zero). You can get the enclosure device ID using MegaCli -EncInfo -aALL. The E:S syntax is also used for specifying the physical drives when creating a new RAID virtual drive.
  • Virtual drive parameter -Lx
    The parameter -Lx is used for specifying the virtual drive (where x is a number starting with zero or the string all).

Gather information
  • Controller information
    # MegaCli -AdpAllInfo -aALL # MegaCli -CfgDsply -aALL # MegaCli -AdpEventLog -GetEvents -f events.log -a0 -nolog # MegaCli -fwtermlog -dsply -a0
  • Enclosure information
    # MegaCli -EncInfo -aAll
  • Virtual drive information
    # MegaCli -LDInfo -Lall -aALL
  • Physical drive information
    # MegaCli -PDList -aALL # MegaCli -PDInfo -PhysDrv [E:S] -aALL
  • Battery backup information
    # MegaCli -AdpBbuCmd -aALL
  • Show Consistancy check progress

  • Background initialization (ongoing processes)
    # MegaCli -LDBI -ShowProg|-ProgDsply -aAll
    Set background initialization rate to 90%
    # MegaCli -AdpSetProp BgiRate 90 -aAll

Controller Management
  • Silence active alarm
    # MegaCli -AdpSetProp AlarmSilence -aALL
  • Disable alarm
    # MegaCli -AdpSetProp AlarmDsbl -aALL
  • Enable alarm
    # MegaCli -AdpSetProp AlarmEnbl -aALL
  • Disable battery backup warning on system boot
    # MegaCli -AdpSetProp BatWarnDsbl -a0
  • Change adpater rebuild rate to 60%
    # MegaCli -AdpSetProp {RebuildRate -60} -aALL
Virtual Drive Management
  • Create RAID 0,1,5 drive
    # MegaCli -CfgLdAdd -r(0|1|5) [E:S, E:S, ...] -aN
  • Create RAID 10 drive
    # MegaCli -CfgSpanAdd -r10 -Array0[E:S,E:S] -Array1[E:S,E:S] -aN
  • Remove drive
    # MegaCli -CfgLdDel -Lx -aN
Physical Drive Management
  • Set state to offline
    # MegaCli -PDOffline -PhysDrv [E:S] -aN
  • Set state to online
    # MegaCli -PDOnline -PhysDrv [E:S] -aN
  • Mark as missing
    # MegaCli -PDMarkMissing -PhysDrv [E:S] -aN
  • Prepare for removal
    # MegaCli -PdPrpRmv -PhysDrv [E:S] -aN
  • Show missing drive
    # MegaCli -PDGetMissing -a0
  • Replace missing drive
    # MegaCli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN
    * The number N of the array parameter is the Span Reference you get using 
    MegaCli -CfgDsply -aALL and the number N of the row parameter is the Physical Disk in that span or array starting with zero (it’s not the physical disk’s slot!).
  • Rebuild drive, drive status should be "Firmware state: Rebuild"
    # MegaCli -PDRbld -Start|-Stop|-ShowProg|-ProgDsply -PhysDrv [E:S] -aN
  • Clear drive
    # MegaCli -PDClear -Start|-Stop|-ShowProg -PhysDrv [E:S] -aN
  • Bad to good
    # MegaCli -PDMakeGood -PhysDrv[E:S] -aN
  • Blink the fron LED to help locate a particular drive
    # MegaCli -AdpSetProp \{UseDiskActivityforLocate -1\}  -aALL# MegaCli -PdLocate -start -physdrv\[E:S\]  -aALL
    Stop the blinking
    # MegaCli -PdLocate -stop  -physdrv\[E:S\]  -aALL

Hot Spare Management
  • Set global hot spare
    # MegaCli -PDHSP -Set -PhysDrv [E:S] -aN
  • Remove hot spare
    # MegaCli -PDHSP -Rmv -PhysDrv [E:S] -aN
  • Set dedicated hot spare
    # MegaCli -PDHSP -Set -Dedicated -ArrayN,M,... -PhysDrv [E:S] -aN

Rebuild a drive that is marked 'Foreign' when inserted:

  1. Bad to Good
    # MegaCli -PDMakeGood -PhysDrv [E:S]  -aALL
  2. Clear foreign setting
    # MegaCli -CfgForeign -Scan -aALL
    # MegaCli -CfgForeign -Clear -aALL
  3. set global hot spare
    # MegaCli -PDHSP -Set -PhysDrv [E:S] -aN
MegaCli -PDList -aAll | grep --before-context=12 Firmware Find drive that the "Firmware state" is not "online"

Change/Replace a drive

  1. Enable autorebuild
    # # MegaCli -AdpAutoRbld -Enbl -a0
  2. set the drive offline
    # MegaCli -PDOffline -PhysDrv [E:S] -aN
  3. mark the drive as missing
    # MegaCli -PDMarkMissing -PhysDrv [E:S] -aN
  4. prepare drive for removal
    # MegaCli -PDPrpRmv -PhysDrv [E:S] -aN
  5. change/replace the drive
  6. if you are using hot spares, the replaced drive should become new hot spare
    # MegaCli -PDHSP -Set -PhysDrv [E:S] -aN
    if you are not using hot spares, you must re-add the new drive to your RAID virtual drive and start the rebuilding
    # MegaCli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN
    # MegaCli -PDRbld -Start -PhysDrv [E:S] -aN

To identify the problem drive:
  • Gather information:
    MegaCli -LDInfo -Lall -aALL
    MegaCli -PDList -a0
    MegaCli -CfgDsply -aALL
    MegaCli -AdpGetProp AlarmDsply -aAll
    MegaCli -LDCC -ShowProg -L0 -a0 -Nolog
    MegaCli -FwTermLog -Dsply -a0
  • Locate a physical drive: MegaCli64 -PdLocate -start -physdrv [E:S] -a0
  • To Clear Terminal Log: MegaCli -FwTermLog -Clear -aN
  • Check battery status: MegaCli -AdpBbuCmd -aAll
  • Check BBU (battery backup unit) status:
    MegaCli -AdpBbuCmd -GetBbuStatus -a0 -NoLog | egrep 'charge|battery'
  • Work with bad BBU: MegaCli -LDSetProp CachedBadBBU -LAll -aAll -NoLog
  • To find enclosure IDs: MegaCli -EncInfo -aN
  • To view a particular physical drive: MegaCli -pdinfo -PhysDrv [E:S] -aN
  • To replace a drive:
    MegaCli -PDOffline -PhysDrv [E:S] -aN
    MegaCli -PDMarkMissing -PhysDrv [E:S] -aN
    MegaCli -PDPrpRmv -PhysDrv [E:S] -aN
    ** swap the drive **
    MegaCli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN
    Note: The number N of the array parameter is the Span Reference you get using MegaCli -CfgDsply -aALL and the number N of the row parameter is the Physical Disk in that span which you are replacing, not the slot number. S is the slot number of the NEW disk.
    For example: to replace physical disk 0 in span 1 using disk ID 25 you would use the following command: MegaCli -PdReplaceMissing -PhysDrv [:25] -Array1 -row0 -a0
Warning: Drive rebuilds do not start automatically! You have to actually tell the controller to start rebuilding the drive.
MegaCli -PDRbld -Start -PhysDrv [E:S] -aN
To rebuild a drive that has a "foreign" configuration:
  • Mark the drive as good: MegaCli -PDMakeGood -PhysDrv [E:S] -aALL
  • Clear the foreign setting: MegaCli -CfgForeign -Clear -a0
  • Set global hot spare - drive should start rebuilding after this:
    MegaCli -PDHSP -Set -PhysDrv [E:S] -aN
  • Stop consistency check:MegaCli -LDCC -Abort -L0 -a0 -Nolog
  • Silence Alarm Beeps: MegaCli -AdpSetProp -AlarmSilence -aN
  • Show Rebuild Status:
    watch -n 10 /opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ShowProg PhysDrv [E:S] -a0
-----
Dump the log file
${megacli} -fwtermlog -dsply -aall > /tmp/ttylog.txt
~/tmp $ grep -n ErrLba ttylog.txt
    The ErrLba= indicates a hardware error on the specified block.  It seems
    the raid controller attempted to read the data, and found it to be
    corrupted.  But, it then wrote it back, and all is now okay again


~/tmp $ grep -n orrected ttylog.txt
    if it sees many of these errors (many being a loose
    definition which varies from disk to disk) the controller will raise a
    predictive failure error.  Until then, we ignore it.

----------


~]# MegaCLI -help
 
      MegaCLI SAS RAID Management Tool  Ver 1.01.39 Aug 01, 2007
 
    (c)Copyright 2007, LSI Logic Corporation, All Rights Reserved.
${megacli} -v 
${megacli} -help|-h|? 
${megacli} -adpCount 
${megacli} -AdpSetProp {CacheFlushInterval -val}|{ RebuildRate -val} 
    |{PatrolReadRate -val}|{BgiRate -val}|{CCRate -val} 
    |{ReconRate -val}|{SpinupDriveCount -val}|{SpinupDelay -val} 
    |{CoercionMode -val}|{ClusterEnable -val}|{PredFailPollInterval -val} 
    |{BatWarnDsbl -val} |{EccBucketSize -val} | {EccBucketLeakRate -val} 
    |{AbortCCOnError val} | AlarmEnbl | AlarmDsbl | AlarmSilence -aN|-a0,1,2|-aALL 
${megacli} -AdpGetProp CacheFlushInterval | RebuildRate | PatrolReadRate | BgiRate 
    | CCRate | ReconRate | SpinupDriveCount | SpinupDelay | CoercionMode
    | PredFailPollInterval | EccBucketSize | EccBucketLeakRate | EccBucketCount
    | ClusterEnable | BatWarnDsbl | AbortCCOnError | AlarmDsply -aN|-a0,1,2|-aALL 
${megacli} -AdpAllInfo -aN|-a0,1,2|-aALL  
${megacli} -AdpGetTime -aN|-a0,1,2|-aALL  
${megacli} -AdpSetTime yyyymmdd hh:mm:ss -aN   
${megacli} -AdpSetVerify -f fileName -aN|-a0,1,2|-aALL  
${megacli} -AdpBIOS -Enbl |-Dsbl | -SOE | -BE | -Dsply -aN|-a0,1,2|-aALL 
${megacli} -AdpBootDrive {-Set -Lx}|-Get -aN|-a0,1,2|-aALL 
${megacli} -AdpAutoRbld -Enbl|-Dsbl|-Dsply -aN|-a0,1,2|-aALL
${megacli} -AdpCacheFlush -aN|-a0,1,2|-aALL
${megacli} -AdpPR -Dsbl|EnblAuto|EnblMan|Start|Stop|Info|{SetDelay Val} 
         -aN|-a0,1,2|-aALL
${megacli} -AdpCcSched -Dsbl|-Info|{-ModeConc | -ModeSeq [-ExcludeLD -LN|-L0,1,2]
   [-SetStartTime yyyymmdd hh ] [-SetDelay val ] } -aN|-a0,1,2|-aALL
${megacli} -AdpCcSched -SetStartTime yyyymmdd hh -aN|-a0,1,2|-aALL
${megacli} -AdpCcSched -SetDelay val  -aN|-a0,1,2|-aALL
${megacli} -FwTermLog -BBUoff|BBUoffTemp|BBUon|BBUGet|Dsply|Clear -aN|-a0,1,2|-aALL
${megacli} -AdpShutDown -aN|-a0,1,2|-aALL
${megacli} -PDList -aN|-a0,1,2|-aALL 
${megacli} -PDGetNum -aN|-a0,1,2|-aALL 
${megacli} -pdInfo -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL  
${megacli} -PDOnline  -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
${megacli} -PDOffline -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
${megacli} -PDMakeGood -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
${megacli} -PDHSP {-Set [-Dedicated [-ArrayN|-Array0,1,2...]] [-EnclAffinity] [-nonRevertible]} 
         |-Rmv -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
${megacli} -PDRbld -Start|-Stop|-ShowProg |-ProgDsply 
        -PhysDrv [E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL  
${megacli} -PDClear -Start|-Stop|-ShowProg |-ProgDsply 
        -PhysDrv [E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL  
${megacli} -PdLocate {[-start] | -stop} -physdrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
${megacli} -PdMarkMissing -physdrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
${megacli} -PdGetMissing -aN|-a0,1,2|-aALL 
${megacli} -PdReplaceMissing -physdrv[E0:S0] -arrayA, -rowB -aN 
${megacli} -PdPrpRmv [-UnDo] -physdrv[E0:S0] -aN|-a0,1,2|-aALL  
${megacli} -EncInfo -aN|-a0,1,2|-aALL 
${megacli} -PhyInfo -phyM -aN|-a0,1,2|-aALL  
${megacli} -LDInfo -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL 
${megacli} -LDSetProp  {-Name LdNamestring} | -RW|RO|Blocked | WT|WB|RA|NORA|ADRA 
        | Cached|Direct | -EnDskCache|DisDskCache | CachedBadBBU|NoCachedBadBBU
        -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL 
${megacli} -LDGetProp  -Cache | -Access | -Name | -DskCache -Lx|-L0,1,2|-LALL  
        -aN|-a0,1,2|-aALL 
${megacli} -LDInit {-Start [-full]}|-Abort|-ShowProg|-ProgDsply -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL 
${megacli} -LDCC -Start|-Abort|-ShowProg|-ProgDsply -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL 
${megacli} -LDBI -Enbl|-Dsbl|-getSetting|-Abort|-ShowProg|-ProgDsply -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL  
${megacli} -LDRecon {-Start -rX [{-Add | -Rmv} -Physdrv[E0:S0,...]]}|-ShowProg|-ProgDsply 
        -Lx -aN 
${megacli} -LdPdInfo -aN|-a0,1,2|-aALL 
${megacli} -LDGetNum -aN|-a0,1,2|-aALL 
${megacli} -CfgLdAdd -rX[E0:S0,E1:S1,...] [WT|WB] [NORA|RA|ADRA] [Direct|Cached]
        [CachedBadBBU|NoCachedBadBBU] [-szXXX [-szYYY ...]]
        [-strpszM] [-Hsp[E0:S0,...]] [-AfterLdX] -aN 
${megacli} -CfgEachDskRaid0 [WT|WB] [NORA|RA|ADRA] [Direct|Cached] 
        [CachedBadBBU|NoCachedBadBBU] [-strpszM] -aN|-a0,1,2|-aALL
${megacli} -CfgClr -aN|-a0,1,2|-aALL 
${megacli} -CfgDsply -aN|-a0,1,2|-aALL 
${megacli} -CfgLdDel -LX|-L0,2,5...|-LALL -aN|-a0,1,2|-aALL 
${megacli} -CfgFreeSpaceinfo -aN|-a0,1,2|-aALL 
${megacli} -CfgSpanAdd -r10 -Array0[E0:S0,E1:S1] -Array1[E0:S0,E1:S1] [-ArrayX[E0:S0,E1:S1] ...] 
        [WT|WB] [NORA|RA|ADRA] [Direct|Cached] [CachedBadBBU|NoCachedBadBBU]
        [-szXXX[-szYYY ...]][-strpszM][-AfterLdX] -aN
${megacli} -CfgSpanAdd -r50 -Array0[E0:S0,E1:S1,E2:S2,...] -Array1[E0:S0,E1:S1,E2:S2,...] 
        [-ArrayX[E0:S0,E1:S1,E2:S2,...] ...] [WT|WB] [NORA|RA|ADRA] [Direct|Cached] 
        [CachedBadBBU|NoCachedBadBBU][-szXXX[-szYYY ...]][-strpszM][-AfterLdX] -aN
${megacli} -CfgSave -f filename -aN   
${megacli} -CfgRestore -f filename -aN   
${megacli} -CfgForeign -Scan -aN|-a0,1,2|-aALL    
${megacli} -CfgForeign -Dsply [x] -aN|-a0,1,2|-aALL    
${megacli} -CfgForeign -Preview [x] -aN|-a0,1,2|-aALL    
${megacli} -CfgForeign -Import [x] -aN|-a0,1,2|-aALL    
${megacli} -CfgForeign -Clear [x] -aN|-a0,1,2|-aALL    
        x - index of foreign configurations. Optional. All by default. 
${megacli} -AdpEventLog -GetEventLogInfo -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -GetEvents         -f  -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -GetSinceShutdown  -f  -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -GetSinceReboot    -f  -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -IncludeDeleted    -f  -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -GetLatest n -f  -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -GetCCIncon -f  -LX|-L0,2,5...|-LALL -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -Clear -aN|-a0,1,2|-aALL 
${megacli} -AdpBbuCmd -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -GetBbuStatus -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -GetBbuCapacityInfo -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -GetBbuDesignInfo -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -GetBbuProperties -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -BbuLearn -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -BbuMfgSleep -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -BbuMfgSeal -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -SetBbuProperties -f  -aN|-a0,1,2|-aALL 
${megacli} -AdpFacDefSet -aN 
${megacli} -AdpFwFlash -f filename [-NoSigChk] [-NoVerChk] -aN|-a0,1,2|-aALL  
${megacli} -AdpGetConnectorMode -ConnectorN|-Connector0,1|-ConnectorAll -aN|-a0,1,2|-aALL  
${megacli} -AdpSetConnectorMode -Internal|-External -ConnectorN|-Connector0,1|-ConnectorAll -aN|-a0,1,2|-aALL  
${megacli} -PhyErrorCounters -aN|-a0,1,2|-aALL  
${megacli} -DirectPdMapping -Enbl|-Dsbl|-Dsply -aN|-a0,1,2|-aALL  
 
    Note: The directly connected drives can be specified as [:S] 
 
    Wildcard '?' can be used to specify the enclosure ID for the drive in the 
      only enclosure without direct connected device or the direct connected 
      drives with no enclosure in the system.
 
    The following options may be given at the end of any command above: 
 
      [-Silent] [-AppLogFile filename] [-NoLog]
----------
 Description MegaCLI Command
System Commands
Show the software version  MegaCLI -v
Show help information  MegaCLI -help|-h|?
Show the number of controllers connected  MegaCLI -adpCount
Controller Commands
Show the status of properties related to the controllers MegaCli -AdpGetProp
            <PropertyName>-aN|-a0,1,2|-aALL
The following properties can be used with this command:
            abortcconerror
            alarmdsply
            autodetectbackplanedsbl
            Autoenhancedimportdsply
            autosnapshotspace
            batwarndsbl
            bgirate
            bootwithpinnedcache
            cachebypass
            ccrate
            clusterenable
            coercionmode
            copybackdsbl
            Defaultldpspolicy
            defaultsnapshotspace
            defaultviewspace
            disableldpsinterval
            disableldpstime
            disableocr
            dsbl
            eccbucketcount
            eccbucketleakrate
            eccbucketsize
            enableeghsp
            enableesmarter
            enableeug|
            enablejbod
            enblspindownunconfigdrvs
            loadbalancemode
            maintainpdfailhistoryenbl
            ncqdsply
            patrolreadrate
            perfmode
            predfailpollinterval
            rebuildrate
            reconrate
            rstrhotspareoninsert
            smartcpybkenbl
            spindowntime
            spinupdelay
            spinupdrivecount
            spinupencdelay
            spinupencdrvcnt
            ssdsmartcpybkenbl
            usediskactivityforlocate
            usefdeonlyencrypt
Set properties on the selected controllers
           
Megacli -AdpSetProp
            <propertyname>-an|-a0,1,2|-aall
            The following properties can be set using this
            command:
            abortcconerror
            alarmdsply
            autodetectbackplanedsbl
            autoenhancedimportdsply
            autosnapshotspace
            batwarndsbl
            bgirate
            bootwithpinnedcache
            cachebypass
            ccrate
            clusterenable
            coercionmode
            copybackdsbl
            defaultldpspolicy
            defaultsnapshotspace
            defaultviewspace
            disableldpsinterval
            disableldpstime
            disableocr
            dsbl
            eccbucketcount
            eccbucketleakrate
            eccbucketsize
            enableeghsp
            enableesmarter
            enableeug|
            enablejbod
            enblspindownunconfigdrvs
            loadbalancemode
            maintainpdfailhistoryenbl
            ncqdsply
            patrolreadrate
            perfmode
            predfailpollinterval
            rebuildrate
            reconrate
            rstrhotspareoninsert
            smartcpybkenbl
            spindowntime
            spinupdelay
            spinupdrivecount
            spinupencdelay
Set properties on the selected controllers autocarve=<on|off>
            autodetect=<on|off >
            disk=<p:-p>|all
            autorebuild=<on|off>
            carvesize=<1024..32768>
            dpmstat=<on|off>
            ondegrade=<cacheoff|follow>
            rebuild=<enable|disable|><1..5>
            rebuildmode=<adaptive|lowlatency>
            rebuildrate=<1..5>
            selftest=<enable|disable>
            spinup=<value>
            stagger=<value>
            verify=advanced|basic|<1..5>
            verify=basic [pref=ddd:hh]where
            hh={00..23} and
            ddd={mon|tue|wed|thu|fri|sat|sun}
            verify=enable|disable|<1..5>
            verifymode=<adaptive|lowlatency>
            verifyrate=<1..5>
            spinupencdrvcnt
            sdsmartcpybkenbl
            usediskactivityforlocate
            usefdeonlyencrypt
Show the number of controllers connected MegaCLI -adpCount
           
Show all information about the adapter, such as cluster state, BIOS, alarm, firmware, version, and so on MegaCli -AdpAllInfo -aN|-a0,1,2|-aALL
Show the freespace available in the controller MegaCLI -CfgFreeSpaceinfo -aN|-a0,1,2|-aALL
Download the controller firmware MegaCli -AdpFwFlash -f filename [-NoSigChk]
[-NoVerChk] -aN|-a0,1,2|-aALL
Show the preserved cache status MegaCLI-GetPreservedCacheList -aN|-a0,1,2|-aALL
Set the controller time MegaCLI –AdpSetTime yyyymmdd hh:mm:ss
-aN|-a0,1,2|-aALL
Set the controller time  MegaCLI –AdpGetTime -aN
RAID Configuration commands
Create a RAID configuration of RAID type 0, 1, 5, and 6 MegaCli –CfgLDAdd
            -R0|-R1|-R5|-R6[E0:S0,E1:S1,...]
            [WT|WB] [NORA|RA|ADRA]
            [Direct|Cached]
            [CachedBadBBU|NoCachedBadBBU]
            [-szXXXXXXXX [-szYYYYYYYY [... ]]]
            [-strpszM] [–Hsp[E5:S5,...]]
            [–afterLdX] -aN
Create a CacheCade virtual drive MegaCLI -CfgCacheCadeAdd [-rX]
            -Physdrv[E0:S0,...] {-Name LdNamestring}
[WT|WB|ForcedWB]
            [-assign -LX|L0,2,5..|LALL]
            -aN|-a0,1,2|-Aall
Create a RAID configuration of RAID type 10, 50, and 60 MegaCli –CfgSpanAdd
            -aN|-a0,1,2|-aALL
            -R10|-R50|R60
            –Array0[E0:S0,E1:S1,...]
            –Array1[E0:S0,E1:S1,...] [...]
            [WT | WB] [NORA | RA | ADRA]
            [Direct | Cached]
            [CachedBadBBU|NoCachedBadBBU]
            [-szXXXXXXXX [-szYYYYYYYY [... ]]]
            [-strpszM] [–afterLdX] -aN
Delete a virtual drive MegaCli -CfgClr [-Force] -aN|-a0,1,2|-aALL
Show the topology information of the drive group MegaCLI -CfgDsply -aN|-a0,1,2|-Aall
Show information for a CacheCade virtual drive MegaCLI -CfgCacheCadeDsply -aN|-a0,1,2|-Aall
Delete a virtual drive hosting the operating system MegaCLI -CfgLdDel -LX|-L0,2,5...|-LALL [-Force]
            -aN|-a0,1,2|-aALL
Delete a CacheCade virtual drive MegaCLI -CfgCacheCadeDel -LX|-L0,2,5...|-LALL
            -aN|-a0,1,2|-Aall
Show, delete, and import the foreign configuration commands MegaCli –CfgForeign –Scan |
{-Preview | –Dsply| -Import |
            -Clear[FID]} -aN|-a0,1,2|-aALL"
Patrol Read Commands
Show the patrol read status and patrol read parameters, if any in progress MegaCli -AdpPR -info -aN|-a0,1,2|-aALL
Set the patrol read options on a single adapter, multiple adapters, or all adapters (x = single controller) MegaCli -AdpPR
            –Dsbl|EnblAuto|EnblMan|Start|Stop|
            Info|Suspend|Resume|Stop|
            SSDPatrolReadEnbl |
            SSDPatrolReadDsbl
            |{SetDelay Val}|{-SetStartTime
            yyyymmdd hh}|{maxConcurrentPD Val}
            -aN|-a0,1,2|-aALL
Disable patrol read MegaCli -AdpPR -Dsbl -aN|-a0,1,2|-aALL
Enable automatic patrol read. MegaCli -AdpPR -EnblAuto -aN|-a0,1,2|-aALL
Enable manual patrol read. MegaCli -AdpPR -EnblMan -aN|-a0,1,2|-aALL
Start patrol read. MegaCli -AdpPR -Start -aN|-a0,1,2|-aALL
Suspend a running patrol read MegaCli -AdpPR -Suspend -aN|-a0,1,2|-aALL
Resume a suspended patrol read MegaCli -AdpPR -Resume -aN|-a0,1,2|-aALL
Stop a running patrol read MegaCli -AdpPR -Stop -aN|-a0,1,2|-aALL
Include SSD drives in patrol read MegaCli -AdpPR -SSDPatrolReadEnbl
-aN|-a0,1,2|-aALL
Exclude SSD drives in patrol read  MegaCli -AdpPR -SSDPatrolReadDsbl
-aN|-a0,1,2|-aALL
Delay a patrol read MegaCli -AdpPR -SetDelay Val -aN|-a0,1,2|-aALL
Schedule a patrol read MegaCli -AdpPR -SetStartTime yyyymmdd hh
-aN|-a0,1,2|-aALL
Set the value for maximum concurrent physical drives for the patrol read MegaCli -AdpPR -maxConcurrentPD Val
-aN|-a0,1,2|-aALL
Consistency Check Commands
Schedule a consistency check MegaCLI -AdpCcSched -Dsbl|-Info|
            {-ModeConc | -ModeSeq [-ExcludeLD
            -LN|-L0,1,2] [-SetStartTime yyyymmdd
            hh ] [-SetDelay val ] }
            -aN|-a0,1,2|-aALL
Show consistency check status and consistency parameters, in progress, if any  MegaCLI -AdpCcSched -Info
OPROM BIOS Commands
Schedule a consistency check MegaCli -AdpBIOS -Dsply -aN|-a0,1,2|-aALL
Show consistency check status and consistency parameters, if any in progress MegaCli -AdpBootDrive
{-Set {-Lx|-physdrv[E0:S0]}} -aN|-a0,1,2|-aALL
Sets the BIOS properties for the controller MegaCli -AdpBIOS -Enbl | -Dsbl | -Dsply | SOE | BE
            EnblAutoSelectBootLd | DsblAutoSelectBootLd
            -aN|-a0,1,2|-aALL
Battery (BBU) Commands
Show battery-related information MegaCli -AdpBbuCmd -aN|-a0,1,2|-aALL
Show the battery learn properties MegaCli -AdpBbuCmd -GetBbuProperties
            -aN|-a0,1,2|-aALL
Show the battery information, firmware status, and the gas gauge status MegaCli -AdpBbuCmd -GetBbuStatus
            -aN|-a0,1,2|-aALL
Show battery capacity information MegaCli -AdpBbuCmd -GetBbuCapacityInfo
            -aN|-a0,1,2|-aALL
Show battery design information MegaCli -AdpBbuCmd -GetBbuDesignInfo
            -aN|-a0,1,2|-aALL
Set battery properties MegaCli -AdpBbuCmd -SetBbuProperties
            -f <fileName> -aN|-a0,1,2|-aALL
Start battery learn cycle MegaCli -AdpBbuCmd -BbuLearn -aN|-a0,1,2|-aALL
Set the battery to low power storage mode MegaCli -AdpBbuCmd -BbuMfgSleep
            -aN|-a0,1,2|-aALL
Seal the gas gauge EEPROM write access MegaCli -AdpBbuCmd -BbuMfgSeal
            -aN|-a0,1,2|-aALL
Security Commands
Set the key ID for the controller MegaCli -CreateSecurityKey
            -SecurityKey sssssssssss |
            [-Passphrase sssssssssss] |
            [-KeyID kkkkkkkkkkk] -aN
Change the security key for the controller MegaCli -ChangeSecurityKey
            -OldSecurityKey sssssssssss |
            -SecurityKey sssssssssss|
            [-Passphrase sssssssssss] |
            [-KeyID kkkkkkkkkkk] -aN
Delete the security key MegaCLI -DestroySecurityKey | [-Force] -aN
Set the security key for the controller MegaCli -SetKeyID -KeyID kkkkkkkkkkk -aN
Virtual Drive Commands
Show the virtual drive information  MegaCli –LDInfo –Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL
Set virtual drive properties MegaCli –LDSetProp
            WT|WB|NORA|RA|ADRA|-Cached|Direct|
CachedBadBBU|NoCachedBadBBU|
            -RW|RO|Blocked |{-Name nameString} |
            -EnDskCache|DisDskCache –Lx|
            -L0,1,2|-Lall -aN|-a0,1,2|-aALL
Set power-saving (dimmer switch) properties MegaCli -LDSetPowerPolicy -Default|
            -Automatic| -None| -Maximum|
            -MaximumWithoutCaching
            -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL
Show virtual drive expansion information MegaCli -getLdExpansionInfo -Lx|-L0,1,2|-Lall
            -aN|-a0,1,2|-aALL
Expand the virtual drive within the existing array; also use if you replace the drives with larger drives, beyond the size of the existing array MegaCli -LdExpansion -pN -dontExpandArray
            -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL
Secure the virtual drive MegaCLI –LDMakeSecure -Lx|-L0,1,2,...|-Lall –An
Show specific properties of virtual drives MegaCli –LDGetProp
            -Cache|-Access|-Name|-DskCache
            -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL
Start virtual drive initialization MegaCli –LDInit –Start [Fast|Full] -Lx|-L0,1,2|-Lall
            -aN|-a0,1,2|-aALL
Stop a running virtual drive initialization. MegaCli –LDInit -Abort -Lx|-L0,1,2|-Lall
            -aN|-a0,1,2|-aALL
Show the initialization progress MegaCli –LDInit –ShowProg -Lx|-L0,1,2|-Lall
            -aN|-a0,1,2|-aALL
Start a consistency check on an uninitialized virtual drive MegaCli –LDCC –Start –Lx|-L0,1,2|-Lall
            -aN|-a0,1,2|-aALL
Start, stop, suspend, resume, and show the progress of a consistency check operation MegaCli -LDCC
            -Start|-Abort|-Suspend|-Resume|-ShowProg|
            -ProgDsply -Lx|-L0,1,2|-LALL
            -aN|-a0,1,2|-aALL
Enable/disable automatic background initialization. Show, stop, pause, resume, and show the progress of the background initialization MegaCLI -LDBI -Enbl|-Dsbl|
            -getSetting|-Abort|-Suspend|-Resume|-ShowProg|-ProgDsply
            -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-Aall
Start and show progress for a migrate operation MegaCli –LDRecon {–Start –Rx [Add|Rmv PhysDrv[E0:S0,E1:S1,...] ] }
            | –ShowProg|-ProgDsply –Lx –aN
Delete preserved cache MegaCLI -DiscardPreservedCache
            -Lx|-L0,1,2|-Lall -force -aN|-a0,1,2|-aALL
Assign the CacheCade virtual drive MegaCLI -Cachecade -assign|-remove
            -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL
Physical Drive Commands
Show drive information MegaCli -pdInfo -PhysDrv[E0:S0,E1:S1,...]
            -aN|-a0,1,2|-aALL
Start, stop, suspend, or resume an ongoing rebuild operation. MegaCLI PDRbld -Start|-Stop|-Suspend|-Resume|
-ShowProg|-ProgDsply
            -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
Start, stop, pause, resume, or show the progress of a copyback operation
           
MegaCLI PDCpyBk -Start|-Stop |-Suspend|-Resume|
-ShowProg|-ProgDsply
            -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
Mark a drive as missing MegaCli -PdMarkMissing -physdrv[E0:S0,E1:S1,...]
            -aN|-a0,1,2|-aALL
Show missing drive information MegaCli -PdGetMissing -aN|-a0,1,2|-aALL
Replace the configured drive that is identified as missing, and then start an automatic rebuild MegaCli -PdReplaceMissing -physdrv[E0:S0]
            -arrayA, -rowB -aN
Set the drive state to online MegaCli –PDOnline -PhysDrv[E0:S0,E1:S1....]
            -aN|-a0,1,2
Set the drive state to offline MegaCli –PDOffline -PhysDrv[E0:S0,E1:S1....]
            -aN|-a0,1,2|-aALL
Set the drive state to JBOD MegaCli –PDMakeGood -PhysDrv[E0:S0,E1:S1....]
            -aN|-a0,1,2|-aALL
Add and delete hotspare drives MegaCli –PDHSP {–Set
            [{-Dedicated -ArrayN |-Array0,1...}]
            [-EnclAffinity] [-nonRevertible] } |-Rmv
            -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
Start, stop, pause, resume or show the progress of an initialization process MegaCli –PDClear
            -Start |-Stop|-ShowProg |-ProgDsply
            - PhysDrv[E0:S0,E1:S1....] -aN|-a0,1,2|-aALL
Start a drive locate and activate (blink) the drive’s LED or stop a drive locate (LED blinking) and deactivate the drive’s LED MegaCli –PDLocate {[-start] |-stop}
            -physdrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
Spin down an unconfigured drive and prepare it for removal or spin up spun-down drive and mark the drive state as unconfigured good MegaCli -PDPrpRmv [-Undo]
            -PhysDrv[E0:S0,E1:S1....] -aN|-a0,1,2|-aALL
Show physical drive information of all connected drives MegaCli –PDList -aN|-a0,1..|-aAll
Flash the physical drive firmware MegaCLI PdFwDownload[offline]
            [ForceActivate] {[-SataBridge] -PhysDrv[0:1]}|
{-EncdevId[devId1]} -f <filename>
            -aN|-a0,1,2|-Aall
Erase the drive's security configuration and securely erase data on a drive MegaCli -PDInstantSecureErase
            -PhysDrv[E0:S0,E1:S1,...] |
            [-Force] -aN|-a0,1,2|-aALL
Show the security key for secured physical drives MegaCli -GetKeyID [-PhysDrv[E0:S0]] -aN
Start, stop, and show the progress of a secure erase operation MegaCli -SecureErase Start[
            Simple|
            [Normal [ |ErasePattern
            ErasePatternA|ErasePattern
            ErasePatternA ErasePattern
            ErasePatternB]]|[Thorough [
            |ErasePattern
            ErasePatternA|ErasePattern
            ErasePatternA ErasePattern
            ErasePatternB]]]
            | Stop| ShowProg| ProgDsply
            [-PhysDrv [E0:S0,E1:S1,...] |
            -Lx|-L0,1,2|-LALL]
            -aN|-a0,1,2|-aALL
Enable/disable the direct physical drive mapping mode. Show the current state of the direct physical drive mapping. MegaCLI DirectPdMapping -Enbl|-Dsbl|-Dsply -aN|-a0,1,2|-Aall
Enclosure Commands
Show enclosure information  MegaCli –EncInfo -aN|-a0,1,2|-aALL
Show enclosure status MegaCli –EncStatus -aN|-a0,1,2|-aALL
PHY Commands
Show PHY information MegaCli –PHYInfo -phyM -aN|-a0,1,2|-aALL
Set PHY link speed MegaCLI PhySetLinkSpeed -phyM -speed
            -aN|-a0,1,2|-aALL
Show the PHY error counters. Megacli PhyErrorCounters -An
Alarm Commands
Show alarm properties MegaCli -AdpGetProp AlarmDsply
            -aN|-a0,1,2|-aALL
Set alarm properties MegaCli -AdpSetProp
            AlarmEnbl|AlarmDsbl|AlarmSilence
            -aN|-a0,1,2|-aALL
Event Log Properties Commands
Show event logs. MegaCli -AdpEventLog -GetEventLogInfo
            -aN|-a0,1,2|-aALL
Show the specified type of event logs. MegaCli -AdpEventLog -GetEvents
            {-info -warning -critical -fatal} {-f <fileName>}
            -aN|-a0,1,2|-aALL
Show the specified event logs MegaCli -AdpEventLog -GetSinceShutdown
            {-info -warning -critical -fatal}
            {-f <fileName>} -aN|-a0,1,2|-aALL
Delete the event logs. MegaCli -AdpEventLog -Clear -aN|-a0,1,2|-aALL
Premium Feature Key Commands
Show the Safe ID of the controller MegaCli -ELF -GetSafeId -a0
Show the Advanced Software Options that are enabled on thecontroller, including the ones in trial mode. MegaCli -ELF –ControllerFeatures -a0
Apply the Activation Key in preview mode. MegaCli -ELF -Applykey key –val -preview -a0
Apply the Activation Key MegaCli -ELF -Applykey key –val -a0
Deactivate the trial key MegaCli -ELF –DeactivateTrialKey -a0
Show the re-host information and, if re-hosting is necessary, show the controller and key vault serial numbers. MegaCli -ELF -ReHostInfo -a0
Indicate to the controller that the re-host is complete MegaCli -ELF -ReHostComplete -a0

Friday, December 6, 2013

openssl

SSL Certificates HOWTO http://www.tldp.org/HOWTO/SSL-Certificates-HOWTO/index.html
http://www.freebsdmadeeasy.com/tutorials/freebsd/create-a-ca-with-openssl.php
http://wiki.samat.org/CheatSheet/OpenSSL
http://pages.cs.wisc.edu/~zmiller/ca-howto/

Files:
  • Certificate Signing Request (.csr)
  • Base64-encoded X.509 Certificate (.cer or .crt)
  • DER-encoded binary X.509 Certificate (.cer, .der or .crt)
  • Cryptographic Message Syntax Standard (PKCS#7) Certificate (.p7b, .p7r or .spc)
  • Personal Information Exchange Format (PKCS#12 Certificate (.pfx or .p12)
    PKCS#12 is the only format what can be used to export a certificate and its private key
  • Certificate Revocation List (.crl)
  • Microsoft serialized certificate store (.sst)
  • Certificate Trust List (.stl)
  • Privacy-enhanced Electronic Mail (.pem)
    a refinement of base64 encoding
  • Private Key (.key)

Generating Client/Server certificates with a local CA
*make sure openssl points to the correct instillation (%which openssl).  Mine is aliased to /usr/local/openssl/bin/openssl
Generate a CA
1)    openssl req -out ca.pem -new -x509
        -generates CA file "ca.pem" and CA key "privkey.pem"
Generate server certificate/key pair
        - no password required.
2)    openssl genrsa -out server.key 1024
3)    openssl req -key server.key -new -out server.req
4)    openssl x509 -req -in server.req -CA CA.pem -CAkey privkey.pem -CAserial file.srl -out server.pem
        -contents of "file.srl" is a two digit number.  eg. "00"
Generate client certificate/key pair
5)    Either choose to encrypt the key(a) or not(b)
        a. Encrypt the client key with a passphrase
            openssl genrsa -des3 -out client.key 1024
        b. Don't encrypt the client key
            openssl genrsa -out client.key 1024
6)    openssl req -key client.key -new -out client.req
7)    openssl x509 -req -in client.req -CA CA.pem -CAkey privkey.pem -CAserial file.srl -out client.pem
        -contents of "file.srl" is a two digit number.  eg. "00"

Check certificate content:
# openssl x509 -text -in /var/lib/puppet/ssl/certs/puppet.pem
# openssl crl -text -in /var/lib/puppet/ssl/ca/ca_crl.pem
Simulate SSL connection:
# openssl s_client -host puppet -port 8140 -cert /path/to/ssl/certs/node.domain.com.pem -key /path/to/ssl/private_keys/node.domain.com.pem -CAfile /path/to/ssl/certs/ca.pem
-
# ssldump
-

General OpenSSL Commands


These commands allow you to generate CSRs, Certificates, Private Keys and do other miscellaneous tasks.

  • Generate a new private key and Certificate Signing Request
    openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout privateKey.key
  • Generate a self-signed certificate (see How to Create and Install an Apache Self Signed Certificate for more info)
    openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crt
  • Generate a certificate signing request (CSR) for an existing private key
    openssl req -out CSR.csr -key privateKey.key -new
  • Generate a certificate signing request based on an existing certificate
    openssl x509 -x509toreq -in certificate.crt -out CSR.csr -signkey privateKey.key
  • Remove a passphrase from a private key
    openssl rsa -in privateKey.pem -out newPrivateKey.pem

Checking Using OpenSSL


If you need to check the information within a Certificate, CSR or Private Key, use these commands. You can also check CSRs and check certificates using our online tools.

  • Check a Certificate Signing Request (CSR)
    openssl req -text -noout -verify -in CSR.csr
  • Check a private key
    openssl rsa -in privateKey.key -check
  • Check a certificate
    openssl x509 -in certificate.crt -text -noout
  • Check a PKCS#12 file (.pfx or .p12)
    openssl pkcs12 -info -in keyStore.p12

Debugging Using OpenSSL


If you are receiving an error that the private doesn't match the certificate or that a certificate that you installed to a site is not trusted, try one of these commands. If you are trying to verify that an SSL certificate is installed correctly, be sure to check out the SSL Checker.

  • Check an MD5 hash of the public key to ensure that it matches with what is in a CSR or private key
    openssl x509 -noout -modulus -in certificate.crt | openssl md5
    openssl rsa -noout -modulus -in privateKey.key | openssl md5
    openssl req -noout -modulus -in CSR.csr | openssl md5
  • Check an SSL connection. All the certificates (including Intermediates) should be displayed
    openssl s_client -connect www.paypal.com:443

Converting Using OpenSSL


These commands allow you to convert certificates and keys to different formats to make them compatible with specific types of servers or software. For example, you can convert a normal PEM file that would work with Apache to a PFX (PKCS#12) file and use it with Tomcat or IIS. Use our SSL Converter to convert certificates without messing with OpenSSL.

  • Convert a DER file (.crt .cer .der) to PEM
    openssl x509 -inform der -in certificate.cer -out certificate.pem
  • Convert a PEM file to DER
    openssl x509 -outform der -in certificate.pem -out certificate.der
  • Convert a PKCS#12 file (.pfx .p12) containing a private key and certificates to PEM
    openssl pkcs12 -in keyStore.pfx -out keyStore.pem -nodes
    You can add -nocerts to only output the private key or add -nokeys to only output the certificates.
  • Convert a PEM certificate file and a private key to PKCS#12 (.pfx .p12)
    openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt

puppet

http://puppetlabs.com/puppet/puppet-enterprise
Puppet SSL Explained http://www.masterzen.fr/2010/11/14/puppet-ssl-explained/
replace puppet ca cert http://blkperl.github.io/replace-puppet-ca.html

- clean certificate for client, regenerate cert
. on puppet master  # puppet cert --clean {node certname} 
. on client # rm -r etc/puppet/ssl; rm -r /var/lib/puppet/ssl
. regenerate on client by restart puppet on clean
. on master, check there is new cert wait to be signed:  # puppetca --list 
. on master, sign the requested cert:  # puppetca --sign <node-name> 
- Re-generate the puppet master’s certificate
. clean the old cert
  # puppetca --clean "$(puppet master --configprint certname)"
  or
  # find $(puppet master --configprint ssldir) -name "$(puppet master --configprint certname).pem" -delete
. Start a non-daemonized WEBrick puppet master instance, and wait for it to generate and sign a new certificate:
  # puppet master --no-daemonize --verbose
or  # puppet master --verbose --no-daemonize --cert_name "Puppet CA: `hostname -f`"
  stop the temporary puppet master with ctrl-C after see the “notice: Starting Puppet master version 2.6.9” message.
. restart puppet master
( simplest way is just remove /var/lib/puppet/ssl directory and restart puppetmaster )

- manually verifying the certificate with openssl
# openssl verify -CAfile /etc/puppet/ssl/certs/ca.pem /etc/puppet/ssl/certs/myhostname.domain.com.pem
- look at the certificate content
# openssl x509 -text -noout -in /var/lib/puppet/ssl/certs/puppet.pem
- to see the puppet master’s certified hostnames, ssldir
# puppet master --configprint certname
# puppet master --configprint ssldir
# puppet master --configprint manifest
# puppet master --configprint modulepath
- fingerprinting
. on the node
puppet agent --test --fingerprint
. on master
puppetca --list node.domain.com --fingerprint
-

Friday, November 1, 2013

Expand a Xen virtual disk using LVM

http://www.craigdunn.org/2010/06/howto-expand-a-xen-virtual-disk-using-lvm/

HOWTO: Expand a Xen virtual disk using LVM

So you have a Citrix Xen VM with a Linux filesystem partitioned using LVM and need to expand the size of the root partition? – This is a quick how to that is fairly well tested.
Firstly, I recommend that you backup your data!
In this example, we’ll be adding another 5G to a current 6G logical partition, giving us 11G in total. In this example, our set ups include an extra 2G logical partition so the disk size in total will be 13G.


1 ) Shut down the VM


2 ) Identify the VM and the disk VDI


xenhost# xe vm-disk-list vm="vmhost"
Disk 0 VBD:
uuid ( RO)             : 941baebf-ca8d-0626-f088-30d314433287
    vm-name-label ( RO): vmhost
       userdevice ( RW): 0
 
Disk 0 VDI:
uuid ( RO)             : 03218b6d-dbb1-4181-aa67-5273938af532
       name-label ( RW): 0
    sr-name-label ( RO): TEMPORARY
     virtual-size ( RO): 8589934592
Now resize the VDI from the Xen Center command line:
xenhost# xe vdi-resize uuid=03218b6d-dbb1-4181-aa67-5273938af532 disk-size=13GiB

3 ) Start the VM, login and become root


4 ) Run fdisk and re-create the partition


You will need to identify the root LVM partition in fdisk, remove it, and create it using the largest block size available.
In this example, our LVM partition is the second one (xvda2) – so we select d to delete, 2 to specify the partition, then n to create a new second partition using up to the last cylinder.
vmhost# fdisk /dev/xvda
 
The number of cylinders for this disk is set to 1697.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
 
Command (m for help): p
 
Disk /dev/xvda: 13.9 GB, 13958643712 bytes
255 heads, 63 sectors/track, 1697 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          13      104391   83  Linux
/dev/xvda2              14        1044     8281507+  8e  Linux LVM
 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-1697, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-1697, default 1697):
Using default value 1697
 
Command (m for help): wq
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
 
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
vmhost#
This WARNING error can safely be ignored.

5 ) Reboot the VM


6 ) Resize the LVM physical volume


You can use pvdisplay to see the current size of the volume:
vmhost# pvdisplay
  --- Physical volume ---
  PV Name               /dev/xvda2
  VG Name               VolGroup00
  PV Size               7.90 GB / not usable 23.41 MB
...snip...
Now run pvresize to grow the physical volume to cover the whole partition…
vmhost# pvresize /dev/xvda2
Now re-run pvdisplay and you should see a bigger volume
vmhost# pvdisplay
  --- Physical volume ---
  PV Name               /dev/xvda2
  VG Name               VolGroup00
  PV Size               12.90 GB / not usable 25.51 MB
...snip...

7 ) Resize the LVM logical volume


vmhost# lvresize /dev/VolGroup00/LogVol00 -L +5G
  Extending logical volume LogVol00 to 10.94 GB
  Logical volume LogVol00 successfully resized

8 ) Grow the file system


This example assumes you are running an ext3 filesystem, other filesystem types may vary – run resize2fs over the volume.
vmhost# resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 2867200 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 2867200 blocks long.

Tada!

And that’s it, you should now see an extra 5G available in your root partition
vmhost# df -h /
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       <strong>11G</strong>  3.8G  6.3G  38% /