Attaching new volume:
Go to Volumes > Click on create Volume
Here on Volume Type select which type of volume we want.It can be General Purpose SSD,Provisioned IOPS SSD, Cold HDD,Throughput Optimized HDD or Mangnetic.Here we will go with General purpose SSD.
Then give the size of disk we want.we will go with 12 GB.
Select Availability zone.Check Availability zone where our ec2 instance is located.Here we will go with us-west-2b.
Note:The new volume should be in the same availability zone where the ec2 instance is running to which we want to attach.
If we want to create volume with new snapshot.select snapshot id. If we want to encrypt it tick encrypt this volume.Then click create volume.
After creating volume select the volume, From Actions > Attach volume.
From here select our ec2 instance id and click ok.
Now login to our linux vm and confirm that new volume is attached by using lsblk command
To delete externly attached hard disk we want to unmount it first
#umount /dev/xvdf1
Now from aws dashboard you can detach and delete volume.
Extending Root Volume:
To extend a volume disk in aws.
From Aws dashboard click on volume we want to extend.From Actions > Modify
Give volume Type and New Ssize and click Modify.
Now login to linux vm and assign file system to extended volume space.
#fdisk /dev/xvda
#mkfs -t ext4 /dev/xvda2
#mkdir /diskextend
#mount /dev/xvda2 /diskextend
(Note: To permanently add volume we want to edit /etc/fstab file)
Go to Volumes > Click on create Volume
Here on Volume Type select which type of volume we want.It can be General Purpose SSD,Provisioned IOPS SSD, Cold HDD,Throughput Optimized HDD or Mangnetic.Here we will go with General purpose SSD.
Then give the size of disk we want.we will go with 12 GB.
Select Availability zone.Check Availability zone where our ec2 instance is located.Here we will go with us-west-2b.
Note:The new volume should be in the same availability zone where the ec2 instance is running to which we want to attach.
If we want to create volume with new snapshot.select snapshot id. If we want to encrypt it tick encrypt this volume.Then click create volume.
After creating volume select the volume, From Actions > Attach volume.
From here select our ec2 instance id and click ok.
Now login to our linux vm and confirm that new volume is attached by using lsblk command
To mount the attached disk
#fdisk /dev/xvdf
After that run partprobe to reload partition table.
Now assign ext4 file system
#mkfs -t ext4 /dev/xvdf1
Create a folder where we we want to mount that,.
#mkdir /disk1
#mount /dev/xvdf1 /disk1
To delete externly attached hard disk we want to unmount it first
#umount /dev/xvdf1
Now from aws dashboard you can detach and delete volume.
Extending Root Volume:
To extend a volume disk in aws.
From Aws dashboard click on volume we want to extend.From Actions > Modify
Give volume Type and New Ssize and click Modify.
Now login to linux vm and assign file system to extended volume space.
#fdisk /dev/xvda
#mkfs -t ext4 /dev/xvda2
#mkdir /diskextend
#mount /dev/xvda2 /diskextend
(Note: To permanently add volume we want to edit /etc/fstab file)