Skip to main content

EBS 볼륨 추가하기

The created EC2 instance has a root volume with enough storage capacity to support the operating system, as well as a few additional applications required for supporting the analyses. We will now need additional storage to accommodate the large datasets we are about to download (e.g. Raw reads, aligned sequences etc.). Hence we need to attach additional storage.

In this section we will:

a. Create an Elastic Block Store (EBS) volume.

b. Attach the new volume to an EC2 instance.

c. Format and mount the new volume.

    1. Format the new volume with a filesystem.

    2. Mount the volume and copy some data into it.

CREATE AN EBS VOLUME

  1. In the AWS Management Console search bar, type EC2 to navigate to the EC2 Service.

  2. On the Left Navigation Bar click on Volumes under Elastic Block Store

Screenshot 2023-09-27 at 10.19.25 AM.png

  1. Click on Create Volume (on the top right corner) to create a new volume

  2. In the Create Volume page fill out the required size of the volume in GB, e.g. 10 GB or more depending on the data set size.

NOTE: For the purposes of this lab 10 GB will suffice.
Important: Make sure the Availability Zone is the same as the EC2 instance you are going to attach the volume to.

Screenshot 2023-09-27 at 10.21.34 AM.png

Screenshot 2023-09-27 at 10.22.23 AM.png

  1. Click on Add Tag to uniquely tag the resource. Provide “Name” for the Key and “[your initials]-EBS” for the value.


    Screenshot 2023-09-27 at 10.23.27 AM.png

Attach an EBS Volume to a running Instance

  1. On the Left Navigation Bar click on Volumes under Elastic Block Store to view all the volumes. Select your newly created volume searching the list for the unique Name tag provided in the previous step.


    Screenshot 2023-09-27 at 10.24.55 AM.png

 

  1. Click on Actions and further click on Attach Volume

  2. In the Attach Volume dialog, click on the Instance field and select the EC2 instance by looking for the Instance ID or Name Tag in the list. Click Attach to attach the volume.

Screenshot 2023-09-27 at 10.25.54 AM.png

If attached successfully - In the list of displayed volumes you should see your new volume having a status (under the State Column) indicating In Use.

Screenshot 2023-09-27 at 10.26.22 AM.png

  1. On the left Navigation pane click EC2 Dashboard on the very top of the list of items.

  2. Select Instances (running) and then select your EC2 Instance from the list of instances to which you attached the Volume.

Screenshot 2023-09-27 at 10.27.08 AM.png

Important: Note down the specific device name for the next step of mounting the volume. The drive name may differ from what’s shown.

NOTE: Depending on the Linux version and the machine type, the device names may differ. The EC2 Console will generally show /dev/sdX, where X is a lower-case letter, but you may see /dev/xvdX or /dev/nvmeYn1. The following table may help with translating. Another way to help track is to pick different sizes for your EBS volumes (such as 151, 152, 153 GB for different volumes). | Device name (Console) | Alternate 1 | Alternate 2 | | — | — | — | | /dev/sda | /dev/xvda | /dev/nvme0n1 | | /dev/sdb | /dev/xvdb | /dev/nvme1n1 | | /dev/sdc | /dev/xvdc | /dev/nvme2n1 | | /dev/sdd | /dev/xvdd | /dev/nvme3n1 | | /dev/sde | /dev/xvde | /dev/nvme4n1 | | /dev/sdf | /dev/xvdf | /dev/nvme5n1 |

 

MOUNT THE VOLUME

  1. Log in to your EC2 Instance.

  2. List the available disks using the following command:

lsblk

The output will list the disks attached to your instance.

예시

Screenshot 2023-09-27 at 10.30.52 AM.png

NOTE: Depending on the Linux version and the machine type, the device names may differ. The EC2 Console will generally show /dev/sdX, where X is a lower-case letter, but you may see /dev/xvdX or /dev/nvmeYn1. The following table may help with translating. Another way to help track is to pick different sizes for your EBS volumes (such as 151, 152, 153 GB for different volumes).

Device name (Console) Alternate 1 Alternate 2
/dev/sda /dev/xvda /dev/nvme0n1
/dev/sdb /dev/xvdb /dev/nvme1n1
/dev/sdc /dev/xvdc /dev/nvme2n1
/dev/sdd /dev/xvdd /dev/nvme3n1
/dev/sde /dev/xvde /dev/nvme4n1
/dev/sdf /dev/xvdf /dev/nvme5n1
  1. Check for an unmounted filesystem of size 10GB.100GB. For example: “nvme1n1” as shown below:
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
nvme0n1     259:0    0  150G  0 disk
└─nvme0n1p1 259:1    0  150G  0 part /
nvme1n1     259:2    0   10G100G  0 disk
  1. Check if the volume has any data using the following command:
sudo file -s /dev/nvme1n1

Where “nvme1n1” is the device you noted from the previous section after attaching the device to the EC2 Instance.

If the above command output shows "/dev/nvme1n1: data", it means your volume is empty.

예시

Screenshot 2023-09-27 at 10.30.43 AM.png

 

  1. Format the volume to the ext4 filesystem using the following command.
sudo mkfs -t ext4 /dev/nvme1n1

NOTE: This file-system formatting step is only for a new device, DO NOT run this step while mounting an existing volume as it will wipe out all data on the device.

예시

Screenshot 2023-09-27 at 10.32.11 AM.png

  1. Create a directory of your choice to mount our new ext4 volume. Let’s use the name “volume1”.
sudo mkdir /mnt/volume1
  1. Mount the volume to “volume1” directory using the following command.
sudo mount /dev/nvme1n1 /mnt/volume1
  1. cd into the volume1 directory and check the disk space for confirming the volume mount.
cd /mnt/volume1
df -h .

The above command would show the free space in the volume1 directory.

  1. At this point, the drive is owned by root and not user. We will want to change ownership of the drive, so that you can change the contents of the drive (Add/remove files, etc).
sudo chown -R ubuntu /mnt/volume1

예시

Screenshot 2023-09-27 at 10.33.16 AM.png

Screenshot 2023-09-27 at 10.33.48 AM.png

  1. For your own information, it is possible to later remove this device. Practice unmounting, then remounting it. To unmount the volume, you have to use the following command. Make sure to be outside the directory to unmount the volume.
sudo umount /dev/nvme1n1

But we’ll need this device for later, so remember to re-mount it.

sudo mount /dev/nvme1n1 /mnt/volume1