

# Configure SAP HANA Filesystems
<a name="configure-storage-for-sap-hana"></a>

## Overview
<a name="_overview"></a>

This guide explains how to configure Amazon EBS storage for SAP HANA on Amazon EC2. It covers volume identification, filesystem creation, and LVM configuration where required.

**Note**  
This guide uses NVMe device names (e.g., /dev/nvme1n1) which are standard on Nitro-based instances. On non-Nitro instances, devices will use different naming (e.g., /dev/sdb). Adjust commands according to your device names.

Before beginning configuration, verify that you have the following:
+ An EC2 instance with appropriate EBS volumes attached
+ Root or administrative access to the instance

## Identify Volumes
<a name="_identify_volumes"></a>

Identify block devices, their sizes, and associated volume IDs in order to assign them to the appropriate filesystems.

1.  **Run lsblk to view the associations** 

   As root, on the host, run the following:

   ```
   # lsblk -o NAME,SIZE,TYPE,FSTYPE,LABEL,PATH,SERIAL | sed 's/vol0/vol-0/g'
   ```

    *Example* 

   ```
   NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS FSTYPE LABEL PATH           SERIAL
   nvme1n1     259:0    0  2.2T  0 disk                          /dev/nvme1n1   vol-0abc123def456789a
   nvme0n1     259:1    0   50G  0 disk                          /dev/nvme0n1   vol-0xyz987uvw654321b
   ├─nvme0n1p1 259:5    0    2M  0 part                          /dev/nvme0n1p1
   ├─nvme0n1p2 259:6    0   20M  0 part /boot/efi   vfat   EFI   /dev/nvme0n1p2
   └─nvme0n1p3 259:7    0   50G  0 part /           xfs    ROOT  /dev/nvme0n1p3
   nvme4n1     259:2    0    1T  0 disk                          /dev/nvme4n1   vol-0pqr456mno789123c
   nvme2n1     259:3    0  2.2T  0 disk                          /dev/nvme2n1   vol-0jkl789ghi123456d
   nvme3n1     259:4    0  500G  0 disk                          /dev/nvme3n1   vol-0def456abc789123e
   ```

1.  **Record the Volume Associations** 

   Document the volume requirements and assignments in a structured format. This table will help ensure the correct commands for setting up the volumes.    
[\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/en_us/sap/latest/sap-hana/configure-storage-for-sap-hana.html)

1.  **Review or Assign Tags (optional)** 

   Tags help identify volumes in the Amazon console and API commands, particularly useful during maintenance, volume extensions, or backup/restore operations. Review existing, or add new tags using the following command or the Amazon Console.

    *Example* 

   ```
   $ aws ec2 create-tags --resources vol-0abc123def456789a --tags Key=Name,Value="PRD - Hana Data Volume 1 of 2"
   ```

   Repeat for all volumes.

## Create Filesystems
<a name="_create_filesystems"></a>

Create Filesystems according to whether or not striping has been identifed as a requirement

1.  **Configure Single Volumes** 

   When performance requirements can be met using a single volume (including capacity for growth), create XFS filesystems directly on the device.

    *Example* 

   ```
   # Create XFS filesystem with label for HANA Shared
   mkfs.xfs -f /dev/nvme4n1 -L HANA_SHARED
   
   # Create XFS filesystem with label for HANA Log
   mkfs.xfs -f /dev/nvme3n1 -L HANA_LOG
   ```
**Tip**  
Labels provide consistent device identification across instance restarts. You can add or change a label on an existing XFS filesystem using `xfs_admin -L LABEL_NAME /dev/device_name`. Always use labels in /etc/fstab by referencing `/dev/disk/by-label/LABEL_NAME`.

1.  **Configure Striped Volumes** 

   Logical Volume Management (LVM) manages storage in three layers: Physical Volumes (created with pvcreate) are the actual disks, Volume Groups (created with vgcreate) combine these disks into storage pools, and Logical Volumes (created with lvcreate) are virtual partitions that can span multiple disks for features like striping.

    *Example* 

   ```
   # Create physical volumes
   pvcreate /dev/nvme1n1 /dev/nvme2n1
   
   # Create volume group
   vgcreate vg_hana_data /dev/nvme1n1 /dev/nvme2n1
   
   # Create striped logical volume
   lvcreate -i 2 -I 256 -l 100%VG -n lv_hana_data vg_hana_data
   
   # Create XFS filesystem with label for HANA data
   mkfs.xfs -L HANA_DATA /dev/vg_hana_data/lv_hana_data
   ```
**Important**  
Use 256 KB stripe size (`-I 256`) for data volumes
Use 64 KB stripe size (`-I 64`) for log volumes
The `-i` parameter should match the number of physical volumes. In the example we have 2 volumes.

## Create Mount Points
<a name="_create_mount_points"></a>

1.  **Create filesystems and modify permissions** 

   ```
   # mkdir -p /hana/data /hana/log /hana/shared
   # chown <sid>adm:sapsys /hana/data /hana/log /hana/shared
   # chmod 750 /hana/data /hana/log /hana/shared
   ```

1.  **Configure fstab** 

   The fstab file controls how Linux filesystem partitions, remote filesystems, and block devices are mounted into the filesystem.

   Add the following entries to `/etc/fstab`:

    *Example* 

   ```
   # SAP HANA Storage Configuration
   /dev/disk/by-label/HANA_DATA       /hana/data       xfs    noatime,nodiratime,logbsize=256k       0  0
   /dev/disk/by-label/HANA_LOG        /hana/log        xfs    noatime,nodiratime,logbsize=256k       0  0
   /dev/disk/by-label/HANA_SHARED     /hana/shared     xfs    noatime,nodiratime,logbsize=256k       0  0
   ```

## Mount and Verify
<a name="_mount_and_verify"></a>

1.  **Mount all filesytems** 

   ```
   # mount -a
   ```

1.  **Verify your final configuration** 

   ```
   # lsblk -o NAME,SIZE,TYPE,FSTYPE,LABEL,PATH,SERIAL | sed 's/vol0/vol-0/g'
   ```

    *Example* 

   ```
   NAME                         SIZE TYPE FSTYPE      LABEL       PATH                                  SERIAL
   nvme0n1                       50G disk                         /dev/nvme0n1                          vol-0xyz987uvw654321b
   ├─nvme0n1p1                    2M part                         /dev/nvme0n1p1
   ├─nvme0n1p2                   20M part vfat        EFI         /dev/nvme0n1p2
   └─nvme0n1p3                   50G part xfs         ROOT        /dev/nvme0n1p3
   nvme1n1                      2.2T disk LVM2_member             /dev/nvme1n1                          vol-0abc123def456789a
   └─vg_hana_data-lv_hana_data  4.5T lvm  xfs         HANA_DATA   /dev/mapper/vg_hana_data-lv_hana_data
   nvme2n1                      2.2T disk LVM2_member             /dev/nvme2n1                          vol-0jkl789ghi123456d
   └─vg_hana_data-lv_hana_data  4.5T lvm  xfs         HANA_DATA   /dev/mapper/vg_hana_data-lv_hana_data
   nvme3n1                      500G disk xfs         HANA_LOG    /dev/nvme3n1                          vol-0def456abc789123e
   nvme4n1                        1T disk xfs         HANA_SHARED /dev/nvme4n1                          vol-0pqr456mno789123c
   ```

1.  **Restart System** 

   Verify all mount points are correct using `mount` and `df -h` before rebooting, as incorrect /etc/fstab entries can prevent successful system boot. Once confirmed, restart the operating system to ensure filesystem persistence before HANA installation.