= FlexClone :toc: :icons: :linkattrs: :imagesdir: ../resources/images == Summary This section will cover FlexClone features available with *Amazon FSx for NetApp ONTAP* file system. === FlexClone Overview FlexClone allows you to create a clone of your source volume and allows you to make changes independently to both volumes. Common use cases include development or test environments where you want to create a copy of your production volume and use it for testing. For example, you may want to take a clone of your database and test changes before applying them in production. With FlexClone, you do not need to copy the data to another volume. When you create a FlexClone, ONTAP creates a snapshot of the parent volume, and the FlexClone is created from this snapshot. Since snapshot creation is nearly instant the FlexClone is immediately available for use and consumes virtually no additional capcity. Once the FlexClone volume is created you can manage it as a separate volume. Any new data you write to the FlexClone volume is written to new blocks and will occupy space on disk. You can create multiple clones for the same parent volume. You can split the parent volume and FlexClone volume into two physically separate volumes. When split, any shared data blocks will be split into two separate copies. == Duration NOTE: It will take approximately 05 minutes to complete this section. == Diagram You will be using resources deployed in *Primary VPC* for this section of the workshop. image::primary-architecture.png[align="center"] == Step-by-step Guide (FlexClone) === FlexClone steps . *_Return_* to the Session Manager connection of your *FSx for ONTAP Workshop Linux Instance* and *_run_* the below script to generate data (10 x 128 MB files) on your source volume. + TIP: If the Session Manager window has timed out, e.g. the session is unresponsive, close the session window and create a new one. Return to the link:https://console.aws.amazon.com/ec2/[Amazon EC2] console. *_Click_* the radio button next to the instance with the name *FSx for ONTAP Workshop Linux Instance*. *_Click_* the *Connect* button. Connect using AWS Systems Manager - *_Select_* *Session Manager* tab and *_click_* the Connect button to open a session in your browser. Change the shell back to bash by typing the command ***bash*** and then return. + + [source,bash] ---- jobName=$(echo $(uuidgen) | grep -o ".\{6\}$") count=10 threads=36 blockSize=16M blockCount=8 mkdir ${MOUNTPOINT}/128MB seq 1 ${count} | parallel --will-cite -j ${threads} time dd if=/dev/random of=${MOUNTPOINT}/128MB/dd-${jobName}-{} bs=${blockSize} count=${blockCount} ---- + . *_Run_* the command below to SSH to the cluster management endpoint of your *Primary* FSx for ONTAP file system. + [source,bash] ---- ssh ${ADMINUSER}@${MGMTENDPOINT} ---- + . *_Run_* the command below to list current snapshots on your volume. + [source,bash] ---- vol snapshot show -volume vol1_primary ---- + . *_Run_* the command below to create a new FlexClone. + [source,bash] ---- volume clone create -vserver svm01-primary -flexclone vol1_primary_clone1 -parent-volume vol1_primary ---- + . *_Run_* the below command to list the FlexClone Volumes. + [source,bash] ---- volume clone show ---- + . *_Run_* the command below to list snapshots on your volume again. Do you see a new snapshot created by the FlexClone? + [source,bash] ---- vol snapshot show -volume vol1_primary ---- + . *_Run_* the below command to create a junction path for your clone volume. + [source,bash] ---- volume mount -vserver svm01-primary -volume vol1_primary_clone1 -junction-path /vol1_primary_clone1 ---- + . *_Run_* the below commands to check the space usage between the source and FlexClone volume. + [source,bash] ---- volume show -vserver svm01-primary -volume vol1_primary -fields size,used,available,percent-used,physical-used,physical-used-percent volume show -vserver svm01-primary -volume vol1_primary_clone1 -fields size,used,available,percent-used,physical-used,physical-used-percent ---- + TIP: Since both volumes share data blocks on creation of the FlexClone, you can see *physical-used* space is lower on the FlexClone volume. Any new data written to either the parent or the FlexClone volume is not shared between the volumes. New data that gets written to the FlexClone volume leads to an increase in the space used on your file system. . *_Run_* the command below to quit the ONTAP CLI session. + [source,bash] ---- quit ---- + . *_Run_* the below commands from the Session Manager connection of your *FSx for ONTAP Workshop Linux Instance*. + [source,bash] ---- sudo mkdir ${CLONEDIR} sudo mount -t nfs ${NFSENDPOINT}:/vol1_primary_clone1 ${CLONEDIR} mount | grep ${CLONEDIR} ---- + . *_Run_* the below command to set the *user:group* Unix permissions for the mount point. + [source,bash] ---- sudo chown ssm-user:ssm-user ${CLONEDIR} ---- + . *_Run_* the below commands to compare the contents and space used by the source and FlexClone volume. + [source,bash] ---- ls -lt ${MOUNTPOINT} ${CLONEDIR} df -h ${MOUNTPOINT} ${CLONEDIR} ---- + TIP: You should see nearly identical contents and space usage reported for both volumes. . *_Run_* the below command to create a new file on the FlexClone volume. + [source,bash] ---- echo "Amazon FSx for NetApp ONTAP workshop - New file on Cloned Volume" >> ${CLONEDIR}/clone.txt ---- + . *_Run_* the below command to create a new 128MB file on the FlexClone volume. + [source,bash] ---- jobName=$(echo $(uuidgen) | grep -o ".\{6\}$") count=1 threads=1 blockSize=16M blockCount=8 seq 1 ${count} | parallel --will-cite -j ${threads} time dd if=/dev/random of=${CLONEDIR}/128MB/dd-${jobName}-{} bs=${blockSize} count=${blockCount} ---- + . *_Run_* the below commands to compare the contents of of your source and FlexClone volume. + [source,bash] ---- ls -lt ${MOUNTPOINT} ${CLONEDIR} df -h ${MOUNTPOINT} ${CLONEDIR} ---- + . Are the contents still identical? TIP: You will see that the contents and capacity of the FlexClone directory have changed from the source as we've written data directly to the FlexClone volume. + . *_Run_* the command below to SSH to the cluster management endpoint of your *Primary* FSx for ONTAP file system. + [source,bash] ---- ssh ${ADMINUSER}@${MGMTENDPOINT} ---- + . *_Run_* below commands to check the space usage between the source and FlexClone volume. + [source,bash] ---- volume show -vserver svm01-primary -volume vol1_primary -fields size,used,available,percent-used,physical-used,physical-used-percent volume show -vserver svm01-primary -volume vol1_primary_clone1 -fields size,used,available,percent-used,physical-used,physical-used-percent ---- + . Did the physical-used space change on your FlexClone volume? + TIP: You should see the physical capacity of the FlexClone volume increase. This is because we've written data blocks to the FlexClone which aren't shared with the parent volume. . *_Run_* the command below to quit the ONTAP CLI session. + [source,bash] ---- quit ---- == Next section Click the button below to go to the next section. image::elastic-tiering.png[link=../06-tiering/, align="left",width=420]