

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 參考：Amazon EC2 啟動範本範例
<a name="launch-template-examples"></a>

以下是範例 MIME 分段檔案，您可以用來建立自己的範本。

**Topics**
+ [範例：掛載現有的 Amazon EFS 檔案系統](#example-mount-an-existing-amazon-efs-file-system)
+ [範例：覆寫預設 Amazon ECS 容器代理程式組態](#example-override-default-amazon-ecs-container-agent-configuration)
+ [範例：掛載現有的 Amazon FSx for Lustre 檔案系統](#example-mount-an-existing-amazon-fsx-for-lustre-file-system)

## 範例：掛載現有的 Amazon EFS 檔案系統
<a name="example-mount-an-existing-amazon-efs-file-system"></a>

**Example**  
此範例 MIME 分段檔案會設定運算資源來安裝`amazon-efs-utils`套件，並在 掛載現有的 Amazon EFS 檔案系統`/mnt/efs`。  

```
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/cloud-config; charset="us-ascii"

packages:
- amazon-efs-utils

runcmd:
- file_system_id_01=fs-abcdef123
- efs_directory=/mnt/efs

- mkdir -p ${efs_directory}
- echo "${file_system_id_01}:/ ${efs_directory} efs tls,_netdev" >> /etc/fstab
- mount -a -t efs defaults

--==MYBOUNDARY==--
```

## 範例：覆寫預設 Amazon ECS 容器代理程式組態
<a name="example-override-default-amazon-ecs-container-agent-configuration"></a>

**Example**  
此範例 MIME 多段檔案會覆寫運算資源預設的 Docker 影像清除設定。  

```
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
echo ECS_IMAGE_CLEANUP_INTERVAL=60m >> /etc/ecs/ecs.config
echo ECS_IMAGE_MINIMUM_CLEANUP_AGE=60m >> /etc/ecs/ecs.config

--==MYBOUNDARY==--
```

## 範例：掛載現有的 Amazon FSx for Lustre 檔案系統
<a name="example-mount-an-existing-amazon-fsx-for-lustre-file-system"></a>

**Example**  
此範例 MIME 分段檔案會設定運算資源，以從 Extras Library 安裝`lustre2.10`套件，並將現有的 FSx for Lustre 檔案系統掛載至 `/scratch`，並掛載名稱為 `fsx`。此範例適用於 Amazon Linux 2。如需其他 Linux 發行版本的安裝說明，請參閱《*Amazon FSx for* [Lustre 使用者指南》中的安裝 Lustre 用戶端](https://docs.aws.amazon.com/fsx/latest/LustreGuide/install-lustre-client.html)。如需詳細資訊，請參閱[《Amazon FSx for Lustre 使用者指南》中的自動掛載 Amazon FSx 檔案系統](https://docs.aws.amazon.com/fsx/latest/LustreGuide/mount-fs-auto-mount-onreboot.html)。 * FSx *  

```
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/cloud-config; charset="us-ascii"

runcmd:
- file_system_id_01=fs-0abcdef1234567890
- region=us-east-2
- fsx_directory=/scratch
- amazon-linux-extras install -y lustre2.10
- mkdir -p ${fsx_directory}
- mount -t lustre ${file_system_id_01}.fsx.${region}.amazonaws.com@tcp:fsx ${fsx_directory}

--==MYBOUNDARY==--
```
在容器內容的[磁碟區](https://docs.aws.amazon.com/batch/latest/APIReference/API_ContainerProperties.html#Batch-Type-ContainerProperties-volumes)和 [mountPoints](https://docs.aws.amazon.com/batch/latest/APIReference/API_ContainerProperties.html#Batch-Type-ContainerProperties-mountPoints) 成員中，掛載點必須對應到容器中。  

```
{
    "volumes": [
        {
            "host": {
                "sourcePath": "/scratch"
            },
            "name": "Scratch"
        }
    ],
    "mountPoints": [
        {
            "containerPath": "/scratch",
            "sourceVolume": "Scratch"
        }
    ],
}
```