August 25, 2011

PowerShell FlexVol Creation & LUN Clone

You're bored. You want to create something. You're creative.

See previous post about connecting to the controller.

Create the Volume:
New-NaVol -Name ma_test1 -Aggregate demo_aggr -Size 200G -SpaceReserve none -Controller $Filer -LanguageCode en_US

Create the LUN:
New-NaLun -Path /vol/ma_test1/na_test_lun1 -Size 100G -Controller $Filer -Unreserved
See previous post about the "$Filer" bit

Create a Snapshot:
New-NaSnapshot -TargetName -ma_test1 -Controller $Filer -SnapName snap_with_lun1

Great. So what?
You might want to clone the entire volume to a separate space because you want to do some work that might fill the volume up and you don't want to risk taking the LUN offline **

But you might just want to clone the LUN because you're just having a quick delve in to the snapshot to see some data or restore something you took a snapshot of at some previous time.

Clone the LUN:
New-NaLunClone -ClonePath /vol/ma_test1/ma_test_lun1_cl -ParentPath /vol/ma_test1/ma_test_lun1 -ParentSnapshot snap_with_lun1

** The point here is that you might be being careful about where you put data or the storage admin might not have given you the right to create a cloned volume. Perhaps the storage people want to keep you fairly cleanly inside your own box. A FlexClone creates a new volume whereas a LUN Clone creates a zero space clone inside the existing FlexVol.



August 20, 2011

Connect to your FAS / N-Series

Spin up your PowerShell. do the import-module DataONTAP and then do this:

$FilerName = "Name"
$narootpasswd = "p@ssword"
################################
$password = ConvertTo-SecureString "p@ssword" -AsPlainText -Force
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "root",$password
$Filer = Connect-NaController $FilerName -Credential $Cred

There are a bunch of ways but this is easiest for me.

Long term FlexClone

So you have your SQL database and you are keeping a few snapshots around, mirroring them to the DR site and vaulting them to another location for true backup protection.
Ah, but you want to take an SMSQL snapshot and then keep it around for a good while to do testing and/or development. Easy enough but what you need to consider is that you are going to lock a snapshot and it won't be able to be aged out of the production. Normally you'd have to call up the storage people and ask for the volume to be split. How's about you just do the job yourself and save everyone time. Obviously you need permissions on the controller (storage admin will provide easily enough and you need to be responsible for your own aggregate. Don't fill it up !!

Two PowerShell commandlets will FlexClone the snapshot so that you can start using it. Then, later, if you want to have that around on those disks for longer than your normal snapshot retention pattern you can execute the split. The FlexClone Split command is a background process so the LUN doesn't go offline ever, the underlying FlexVol just silently inflates on the aggregate.

New-NaVolClone -ParentVolume test1 -ParentSnapshot snapshot101 -CloneVolume testclone -Controller $Filer

Start-NaVolCloneSplit -name testclone -Controller $Filer