Digital Marketing

Attach extra EBS volume to your AWS EC2 instance

You create your new volume from the "Volumes" menu in your EC2 management console.

You attach your new volume to your ec2 instance by right clicking the new volume and choose attach.

From the "Attachment Information", you can see where it is being attached, such as "/dev/sdf".

Or you can then see your new volume inside your EC2 instance:

$ cat /proc/partitions 
major minor  #blocks  name

 202        1    8388608 xvda1
 202       80   20971520 xvdf

Use the lsblk command to view your available disk devices and their mount points (if applicable) to help you determine the correct device name to use.

$ lsblk

NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

nvme1n1       259:0    0  100G  0 disk 

nvme0n1       259:1    0    8G  0 disk 

├─nvme0n1p1   259:2    0    8G  0 part /

└─nvme0n1p128 259:3    0    1M  0 part 

$ sudo fdisk -l

Disk /dev/nvme1n1: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/nvme0n1: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt


#         Start          End    Size  Type            Name
 1         4096     16777182      8G  Linux filesyste Linux
128         2048         4095      1M  BIOS boot parti BIOS Boot Partition

Now format the new volume:

$ sudo mkfs -t xfs /dev/xvdf
If you get an error that mkfs.xfs is not found, use the following command to install the XFS tools and then repeat the previous command:

[ec2-user ~]$ sudo yum install xfsprogs

Then make a mount point:

$ sudo mkdir /mnt/data

mount the volume:

$ sudo mount /dev/xvdf /mnt/data/

Add it to /etc/fstab if you want it to automatically mount each time the EC2 instance starts.

Comments

Popular posts from this blog

MySQL Sandbox with the Sakila sample database