You must be able to extract or "unzip" the downloaded package. If your operating system doesn't have the built-inunzipcommand, use an equivalent.
The AWS CLI usesglibc,groff, andless. These are included by default in most major distributions of Linux.
We support the AWS CLI on 64-bit versions of recent distributions of CentOS, Fedora, Ubuntu, Amazon Linux 1, Amazon Linux 2 and Linux ARM.
Because AWS doesn't maintain third-party repositories, we can’t guarantee that they contain the latest version of the AWS CLI.
Install or update the AWS CLI
sudo yum remove awscli
To update your current installation of AWS CLI, download a new installer each time you update to overwrite previous versions. Follow these steps from the command line to install the AWS CLI on Linux.
We provide the steps in one easy to copy and paste group based on whether you use 64-bit Linux or Linux ARM. See the descriptions of each line in the steps that follow.
Swap space in Linux can be used when a system requires more memory than it has been physically allocated. When swap space is enabled, Linux systems can swap infrequently used memory pages from physical memory to swap space (either a dedicated partition or a swap file in an existing file system) and free up that space for memory pages that require high-speed access.
Note Using swap space for memory paging is not as fast or efficient as using RAM. If your workload is regularly paging memory into swap space, you should consider migrating to a larger instance type with more RAM. For more information, seeChange the instance type.
Thec1.mediumandm1.smallinstance types have a limited amount of physical memory to work with, and they are given a 900 MiB swap volume at launch time to act as virtual memory for Linux AMIs. Although the Linux kernel sees this swap space as a partition on the root device, it is actually a separate instance store volume, regardless of your root device type.
Amazon Linux automatically enables and uses this swap space, but your AMI may require some additional steps to recognize and use this swap space. To see if your instance is using swap space, you can use theswapon -scommand.
[ec2-user ~]$ swapon -s
Filename Type Size Used Priority
/dev/xvda3 partition 917500 0 -1
The above instance has a 900 MiB swap volume attached and enabled. If you don't see a swap volume listed with this command, you may need to enable swap space for the device. Check your available disks using thelsblkcommand.
[ec2-user ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda1 202:1 0 8G 0 disk /
xvda3 202:3 0 896M 0 disk
Here, the swap volumexvda3is available to the instance, but it is not enabled (notice that theMOUNTPOINTfield is empty). You can enable the swap volume with theswaponcommand.
Note
You must prepend/dev/to the device name listed bylsblk. Your device may be named differently, such assda3,sde3, orxvde3. Use the device name for your system in the command below.
[ec2-user ~]$ sudo swapon /dev/xvda3
Now the swap space should show up inlsblkandswapon -soutput.
[ec2-user ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda1 202:1 0 8G 0 disk /
xvda3 202:3 0 896M 0 disk [SWAP]
[ec2-user ~]$ swapon -s
Filename Type Size Used Priority
/dev/xvda3 partition 917500 0 -1
You also need to edit your/etc/fstabfile so that this swap space is automatically enabled at every system boot.
[ec2-user ~]$ sudo vim /etc/fstab
Append the following line to your/etc/fstabfile (using the swap device name for your system):
/dev/xvda3 none swap sw 0 0
실제적으로 /etc/fstab 을 vi 로 조져보면 위에 있는 줄 말고 따른놈이 혼자 놀고 있는 것을 알 수 있다.
To use an instance store volume as swap space
Any instance store volume can be used as swap space. For example, them3.mediuminstance type includes a 4 GB SSD instance store volume that is appropriate for swap space. If your instance store volume is much larger (for example, 350 GB), you may consider partitioning the volume with a smaller swap partition of 4-8 GB and the rest for a data volume.
Note
This procedure applies only to instance types that support instance storage. For a list of supported instance types, seeInstance store volumes.
1. List the block devices attached to your instance to get the device name for your instance store volume.
[ec2-user ~]$ lsblk -p
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
/dev/xvdb 202:16 0 4G 0 disk /media/ephemeral0
/dev/xvda1 202:1 0 8G 0 disk /
In this example, the instance store volume is/dev/xdvb. Because this is an Amazon Linux instance, the instance store volume is formatted and mounted at/media/ephemeral0; not all Linux operating systems do this automatically.
2. (Optional) If your instance store volume is mounted (it lists aMOUNTPOINTin thelsblkcommand output), unmount it with the following command.
[ec2-user ~]$ sudo umount /dev/xvdb
EBS 가 mount 되어 있는 상태에서 시도해보려고 했는데 작동이 안되었던 부분이다. 이게 실제로 Optional 로 작용하는지는 모르겠는데, 일단 내 case 에서는 umount 를 해줘야 작동이 됬다.
3. Set up a Linux swap area on the device with themkswapcommand.
[ec2-user ~]$ sudo mkswap /dev/xvdb
mkswap: /dev/xvdb: warning: wiping old ext3 signature.
Setting up swapspace version 1, size = 4188668 KiB
no label, UUID=b4f63d28-67ed-46f0-b5e5-6928319e620b
4. Enable the new swap space.
[ec2-user ~]$ sudo swapon /dev/xvdb
5. Verify that the new swap space is being used.
[ec2-user ~]$ swapon -s
Filename Type Size Used Priority
/dev/xvdb partition 4188668 0 -1
6. Edit your/etc/fstabfile so that this swap space is automatically enabled at every system boot.
[ec2-user ~]$ sudo vim /etc/fstab
If your/etc/fstabfile has an entry for/dev/xvdb(or/dev/sdb) change it to match the line below; if it does not have an entry for this device, append the following line to your/etc/fstabfile (using the swap device name for your system):
/dev/xvdb none swap sw 0 0
Important
Instance store volume data is lost when an instance is stopped or hibernated; this includes the instance store swap space formatting created inStep 3. If you stop and restart an instance that has been configured to use instance store swap space, you must repeatStep 1throughStep 5on the new instance store volume.
The following topic walks you through the process of extendingXFSandExt4file systems for Linux. For information about other file systems, see their documentation for instructions.
After youincrease the size of an EBS volume, you must use file system–specific commands to extend the file system to the new, larger size. You can do this as soon as the volume enters theoptimizingstate.
To extend a file system on Linux, you need to:
Extend the partition, if your volume has one.
Extend the file system.
Before you begin
Create a snapshot of the volume, in case you need to roll back your changes. For more information, seeCreate Amazon EBS snapshots.
이 부분에 대해서 조금 더 설명하자면, Volume 에 대해서 modifications 를 거치는 경우에는 modification - optimizing - completed state 까지를 거치는데 이 부분에서 Cooldown period 가 적용되기 때문에 약 6시간에서 24시간을 거친 이후에야 volume 수정을 재시도를 할 수 있다.
추가적으로 Volume 사이즈는 늘리는 것은 가능해도, 줄이는 것은 안되니께 굉장히 유의해야한다.
Ensure that the volume is attached to the instance and that it is formatted and mounted. For more information, seeFormat and mount an attached volume.
If you are using logical volumes on the Amazon EBS volume, you must use Logical Volume Manager (LVM) to extend the logical volume. For instructions about how to do this, see theExtend the logical volumesection in theHow do I create an LVM logical volume on an entire EBS volume?AWS Knowledge Center article.
Extend the file system of EBS volumes
Use the following procedure to extend the file system for a resized volume.
Note that device and partition naming differs for Xen instances andNitro instances. To determine whether your instance is Xen-based or Nitro-based, use thedescribe-instance-typesAWS CLI command as follows:
AWS CLI 에서 반드시 이부분을 확인하고 넘어가야한다. 부가적으로 설명하자면 t2 ~ t3 급에서 m5 급이나 c5 급 등으로 올라오게 되면 변경점이 생기기 때문이다
Check whether the volume has a partition. Use thelsblkcommand.
Nitro Instance Example In the following example output, the root volume (nvme0n1) has two partitions (nvme0n1p1andnvme0n1p128), while the additional volume (nvme1n1) has no partitions.
[ec2-user ~]$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme1n1 259:0 0 30G 0 disk /data
nvme0n1 259:1 0 16G 0 disk
└─nvme0n1p1 259:2 0 8G 0 part /
└─nvme0n1p128 259:3 0 1M 0 part
Xen Instance Example
In the following example output, the root volume (xvda) has a partition (xvda1), while the additional volume (xvdf) has no partition.
[ec2-user ~]$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 16G 0 disk
└─xvda1 202:1 0 8G 0 part /
xvdf 202:80 0 24G 0 disk
If the volume has a partition, continue the procedure from the following step (2b). If the volume has no partitions, skip steps 2b, 2c, and 2d, and continue the procedure from step 3.
이러한 부분에서 swap disk 를 생성해주려고 하는 경우에는 Instance 변경에 따라 문제가 생길 수 있기 때문에 option 으로 nvme 를 가져가게 된다
Check whether the partition needs to be extended. In thelsblkcommand output from the previous step, compare the partition size and the volume size.
If the partition size is smaller than the volume size, continue to the next step. If the partition size is equal to the volume size, the partition can't be extended.
Extend the partition. Use thegrowpartcommand and specify the partition to extend.
Nitro Instance Example
For example, to extend a partition namednvme0n1p1, use the following command.
[ec2-user ~]$ sudo growpart /dev/nvme0n1 1
Xen Instance Example
For example, to extend a partition namedxvda1, use the following command.
Important
Note the space between the device name (xvda) and the partition number (1).
[ec2-user ~]$ sudo growpart /dev/xvda 1
Troubleshooting tips
mkdir: cannot create directory ‘/tmp/growpart.31171’: No space left on device FAILED: failed to make temp dir: Indicates that there is not enough free disk space on the volume for growpart to create the temporary directory it needs to perform the resize. Free up some disk space and then try again.
must supply partition-number: Indicates that you specified an incorrect partition. Use thelsblkcommand to confirm the partition name, and ensure that you enter a space between the device name and the partition number.
NOCHANGE: partition 1 is size 16773087. it cannot be grown: Indicates that the partition already extends the entire volume and can't be extended.Confirm that the volume modification succeeded.
Verify that the partition has been extended. Use thelsblkcommand. The partition size should now be equal to the volume size.
확장된 부분에 대한 확인사살을 하면 된다
Nitro 인스턴스의 경우에는 아래처럼 1부터 파티션 128까지 붙을 수 있다
[ec2-user ~]$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme1n1 259:0 0 30G 0 disk /data
nvme0n1 259:1 0 16G 0 disk
└─nvme0n1p1 259:2 0 16G 0 part /
└─nvme0n1p128 259:3 0 1M 0 part
아래의 경우는 Xen Instance 의 경우이다
[ec2-user ~]$ df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/xvda1 ext4 8.0G 1.9G 6.2G 24% /
/dev/xvdf1 xfs 24.0G 45M 8.0G 1% /data
...
The commands to extend the file system differ depending on the file system type. Choose the following correct command based on the file system type that you noted in the previous step.
[XFS file system]Use thexfs_growfscommand and specify the mount point of the file system that you noted in the previous step.
Nitro and Xen instance Example
[ec2-user ~]$ sudo xfs_growfs -d /
Troubleshooting tips
xfs_growfs: /data is not a mounted XFS filesystem: Indicates that you specified the incorrect mount point, or the file system is not XFS. To verify the mount point and file system type, use thedf -hTcommand.
data size unchanged, skipping: Indicates that the file system already extends the entire volume. If the volume has no partitions,confirm that the volume modification succeeded. If the volume has partitions, ensure that the partition was extended as described in step 2.
[Ext4 file system]Use theresize2fscommand and specify the name of the file system that you noted in the previous step.
Nitro instance example
For example, to extend a file system mounted named/dev/nvme0n1p1, use the following command.
[ec2-user ~]$ sudo resize2fs /dev/nvme0n1p1
Xen instance example
For example, to extend a file system mounted named/dev/xvda1, use the following command.
[ec2-user ~]$ sudo resize2fs /dev/xvda1
Troubleshooting tips
resize2fs: Bad magic number in super-block while trying to open /dev/xvda1: Indicates that the file system is not Ext4. To verify file the system type, use thedf -hTcommand.
open: No such file or directory while opening /dev/xvdb1: Indicates that you specified an incorrect partition. To verify the partition, use thedf -hTcommand.
The filesystem is already 3932160 blocks long. Nothing to do!: Indicates that the file system already extends the entire volume. If the volume has no partitions,confirm that the volume modification succeeded. If the volume has partitions, ensure that the partition was extended, as described in step 2.
[Other file system]See the documentation for your file system for instructions.
Verify that the file system has been extended. Use thedf -hTcommand and confirm that the file system size is equal to the volume size.
You can share your AMIs with other AWS accounts. To allow all AWS accounts to use an AMI to launch instances, make the AMI public. To allow only specific accounts to use the AMI to launch instances, seeShare an AMI with specific AWS accounts.
Consider the following before making an AMI public.
Ownership– To make an AMI public, your AWS account must own the AMI.
Some AMIs can't be made public– If your AMI includes one of the following components, you can't make it public (but you canshare the AMI with specific AWS accounts):
Encrypted volumes
Snapshots of encrypted volumes
Product codes
Avoid exposing sensitive data– To avoid exposing sensitive data when you share an AMI, read the security considerations inGuidelines for shared Linux AMIsand follow the recommended actions.
Region– AMIs are a Regional resource. When you share an AMI, it is available only in the Region from which you shared it. To make an AMI available in a different Region, copy the AMI to the Region and then share it. For more information, seeCopy an AMI.
Usage– When you share an AMI, users can only launch instances from the AMI. They can’t delete, share, or modify it. However, after they have launched an instance using your AMI, they can then create an AMI from the instance they launched.
Automatic deprecation– By default, the deprecation date of all public AMIs is set to two years from the AMI creation date. You can set the deprecation date to earlier than two years. To cancel the deprecation date, or to move the deprecation to a later date, you must make the AMI private by onlysharing it with specific AWS accounts.
Billing– You are not billed when your AMI is used by other AWS accounts to launch instances. The accounts that launch instances using the AMI are billed for the instances that they launch.
Share an AMI with all AWS accounts (console)
After you make an AMI public, it is available inCommunity AMIswhen you launch an instance in the same Region using the console. Note that it can take a short while for an AMI to appear inCommunity AMIsafter you make it public. It can also take a short while for an AMI to be removed fromCommunity AMIsafter you make it private.
Select your AMI from the list, and then choose Actions, Edit AMI permissions.
Choose Public, and then choose Save changes.
Share an AMI with all AWS accounts (AWS CLI)
Each AMI has alaunchPermissionproperty that controls which AWS accounts, besides the owner's, are allowed to use that AMI to launch instances. By modifying thelaunchPermissionproperty of an AMI, you can make the AMI public (which grants launch permissions to all AWS accounts), or share it with only the AWS accounts that you specify.
You can add or remove account IDs from the list of accounts that have launch permissions for an AMI. To make the AMI public, specify theallgroup. You can specify both public and explicit launch permissions.
To make an AMI public
Use themodify-image-attributecommand as follows to add theallgroup to thelaunchPermissionlist for the specified AMI.
3. (Optional) To make the AMI private again, remove theallgroup from its launch permissions. Note that the owner of the AMI always has launch permissions and is therefore unaffected by this command.