= Access data from Linux and Windows clients
:toc:
:icons:
:linkattrs:
:imagesdir: ../resources/images


== Summary

This section will cover access to data on your *Amazon FSx for OpenZFS* volume from Linux and Windows instances using NFS protocol.


== Duration

NOTE: It will take approximately 10 minutes to complete this section.


== Step-by-step Guide (Mounting Volume on Linux Instance)

=== Connect to the Linux Instance

IMPORTANT: Read through all steps below before continuing.

. Open the link:https://console.aws.amazon.com/ec2/[Amazon EC2] console.
+
TIP: *_Context-click (right-click)_* the link above and open the link in a new tab or window to make it easy to navigate between this GitHub workshop and AWS console.
+
. Make sure you are in the same *AWS Region* as the workshop environment. If you need to change the *AWS Region* of the Amazon EC2 console, in the top right corner of the browser window *_click_* the region name next to *Support* and *_click_* the appropriate *AWS Region* from the drop-down menu.

. *_Click_* *Instances (running)*.

. *_Click_* the radio button next to the instance with the name *FSx for OpenZFS 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. (*recommended*)

* SSH using Terminal client - *_Select_* *SSH client* tab and *_Copy_* the Example SSH command shown and *_click_* Close.

** *_Open_* your terminal application and *_paste_* the SSH command in a terminal window.

** *_Follow_* the prompts to SSH into the instance.

=== Mount volume on Linux Instance

IMPORTANT: Read through all steps below before continuing.

. *_Run_* the following command to see if any NFS volumes have been mounted.
+
[source,bash]
----
mount | grep  nfs

----
+

. Do you see any NFS volumes have been mounted?

NOTE: No volumes should be mounted at this time.

. *_Run_* below command to create mount points for both the child volumes created by the workshop environment.
+
[source,bash]
----
sudo mkdir /fsxasync
sudo mkdir /fsxsync
----
+

. *_Return_* to the browser tab for your Amazon FSx for OpenZFS volume with name *async_vol* and *_Click_* *Attach* on the top right corner. On the *Attach file system* window, under *From Linux instances*, copy the *mount* command listed under *_Attach instruction - using the default DNS name_*

. *_Return_* to the SSH connection of the *FSx for OpenZFS Workshop Linux Instance*. *_Run_* mount command you copied in previous step. Replace the local_path with mount point */fsxasync* created earlier.
+
TIP: If the SSH connection has timed out, e.g. the session is unresponsive, close the SSH connection window and create a new one.
+
[source,bash]
----
sudo mount -t nfs -o nfsvers=4.1 <DNSNAME>:/fsx/async_vol/ local_path
----
+
[source,bash]
----
Example: sudo mount -t nfs -o nfsvers=4.1 fs-01234515abdcefgh.fsx.us-east-1.amazonaws.com:/fsx/async_vol/ /fsxasync
----
+
. *_Return_* to the browser tab for your Amazon FSx for OpenZFS volume with name *sync_vol* and *_Click_* *Attach* on the top right corner. On the *Attach file system* window, under *From Linux instances*, copy the *mount* command listed under *_Attach instruction - using the default DNS name_*

. *_Return_* to the SSH connection of the *FSx for OpenZFS Workshop Linux Instance*. *_Run_* mount command you copied in previous step. Replace the local_path with mount point */fsxsync* created earlier.
+
TIP: If the SSH connection has timed out, e.g. the session is unresponsive, close the SSH connection window and create a new one.
+
[source,bash]
----
sudo mount -t nfs -o nfsvers=4.1 <DNSNAME>:/fsx/sync_vol/ local_path
----
+
[source,bash]
----
Example: sudo mount -t nfs -o nfsvers=4.1 fs-01234515abdcefgh.fsx.us-east-1.amazonaws.com:/fsx/sync_vol/ /fsxsync
----
+
. *_Run_* below command to confirm your file system was successfully mounted.
+
[source,bash]
----
mount | grep -i nfs
----
+
. *_Run_* below command to set the *user:group* for the mount point. *_Copy_* the command with *ssm-user:ssm-user* if you are using a SSH session from *Session Manager*.  *_Copy_* the command with *ec2-user:ec2-user* if you are using a SSH session from your *Terminal*.
+
[source,bash]
----
sudo chown ssm-user:ssm-user /fsxasync /fsxsync

or 

sudo chown ec2-user:ec2-user /fsxasync /fsxsync

----
. *_Run_* below command to examine the size and available space for both volumes.
+
[source,bash]
----
df -h /fsxasync /fsxsync
----
+

. Why are the sizes different even thought both volumes have a quota of 1024 GiB?
+
TIP: The async_vol has a space reservation of 100 GiB which guarantees this space is always available for this volume. Due to this the sync_vol only sees the remaining capacity available on the file system.
+


== Step-by-step Guide (Mounting Volume on Windows Instance)

=== Connect to the Windows Instance

IMPORTANT: Read through all steps below before continuing.

//image::<connect-windows-instances>.gif[align="left", width=600]


. Go back to the Amazon EC2 console, *_Click_* *Instances (running)*

. *_Click_* the radio button next to the instance with the name *FSx for OpenZFS Workshop Windows Instance*.

. *_Copy_* the *Public DNS (IPv4)* name of the *FSx for OpenZFS Workshop Windows Instance*.

. Launch your remote desktop application and create a new connection.
* Windows Users - use the built-in *Remote Desktop Connection* application.
* Mac Users - use the link:https://apps.apple.com/us/app/microsoft-remote-desktop/id1295203466?mt=12/[Microsoft Remote Desktop] app available from the Mac App Store.

. Use the DNS name copied above as the host name of the new connection.

. Start a remote desktop session to the new connection. 

. Login using the *Administrator* user.

. To get the *Administrator* password, *_Select_* the radio button next to the instance with the name *FSx for OpenZFS Workshop Windows Instance* and *_Click_* *Connect*. *_Click_* on the *RDP client* tab and then *Click* on *Get password*. In the Get Windows password window, *_Click_* on *Browse* to browse the key pair associated with this instance, *_Select_* the key pair and *_Click_* *Open*. Next, *_Click_* *Decrypt Password* and *_Copy_* the Password. *_Paste_* the copied password in your remote desktop session window to complete the login process.

. *_Return_* to the browser tab for your Amazon FSx for OpenZFS volume with name *async_vol* and *_Click_* *Attach* on the top right corner. On the *Attach file system* window, *_Click_* on *From Windows instances*, copy the *mount* command listed under *_Attach instruction_*

. *_Return_* to the remote desktop session of the *FSx for OpenZFS Workshop Linux Instance*. *_Open_* a *command prompt* and paste the mount command you copied in previous step. 
+
NOTE: The NFS client has already been installed by the workshop environment.
+
[source,bash]
----
mount \\<DNSNAME>\fsx\async_vol\ Z:
----
+
[source,bash]
----
mount \\fs-01234515abdcefgh.fsx.us-east-1.amazonaws.com\fsx\async_vol\ Z:
----
+


== Next section

Click the link below to go to the next section.

image::data-protection.png[link=../04-data-protection/, align="left",width=420]




