Navrangpura, Ahmedabad, Gujarat
Follow us :

Elastic Block Store (EBS), a scalable block storage solution offered by AWS (Amazon Web Services), offers permanent storage for EC2 (Elastic Compute Cloud) instances. An EC2 instance can have an EBS volume attached to it as a virtual hard drive to store data.es:

The following are some significant traits and qualities of EBS volumes:

1. EBS volumes are made to last and offer long-term storage, therefore they are persistent. Even if the connected EC2 instance is stopped or terminated, the data on an EBS volume continues.

2. Elasticity: EBS volumes can be created in a variety of sizes, from 1 GB to 16 TB, and scaled up or down as necessary. This enables you to accommodate your applications’ fluctuating storage needs.

3. Performance: To accommodate a range of workloads, EBS volumes provide numerous performance options. Four different EBS volume kinds are available:

( 1 ) Suitable for a variety of tasks with balanced performance and cost is the general-purpose SSD (gp2/gp3).

( 2 ) SSDs with provisioned IOPS (io1/io2) are made for high-performance databases and applications that demand reliable and quick I/O.

( 3 ) Throughput Optimised HDD (st1): Designed for heavy streaming workloads with frequent access.

( 4 ) Old HDD (sc1): Designed for workloads that access cold data less frequently

4. Snapshots: EBS volumes support creating point-in-time snapshots, which are incremental backups of the volume’s data. Snapshots are stored in Amazon S3 and can be used to restore volumes or create new volumes.

5. Using the AWS Key Management Service (KMS), you can enable encryption at rest for your EBS volumes. This additional layer of protection further protects your data.

6. High Availability: To increase redundancy and availability, EBS volumes can be linked to an EC2 instance either inside the same availability zone (AZ) or across separate AZs.

7. Data management: As needed, EC2 instances can be quickly attached, detached, and reattached to EBS volumes. Additionally, you can copy volumes, take snapshots, and share snapshots among AWS accounts.

Databases, file systems, content repositories, and other sorts of applications frequently use EBS volumes to provide persistent storage on AWS. They provide versatility, toughness, and performance for data storage and access in the AWS cloud.

Following steps 

1. Open the AWS Management Console and log in.

2. Activate the EC2 service.

3. Create an ” EC2 ” instance

4. Connect to the instance ( puTTY )

5. Login to the root user
Command

[ec2-user@ip-172-31-2-182 ~]$ sudo -i

6.  Check for disk
Command

[root@ip-172-31-2-182 ~]# lsblk

By default disk 

Create Volume 

1. Click “Volumes” on the left navigation pane of the EC2 Dashboard.

2. Select “Create Volume” from the menu.

3. Enter the following information in the “Create Volume” dialogue box.

( 1 ) The preferred availability zone where you wish to establish the EBS volume should be chosen.

( 2 ) Volume Type: Based on your needs, select the appropriate volume type (e.g., magnetic, provisioned IOPS, or general-purpose SSD).

( 3 ) Size: Enter the volume’s size in gibibytes (GiB).

( 4 ) Snapshot: To construct a volume based on a snapshot, select it here if you have one. This step is not required.

( 5 ) Encryption: You can choose this option if you want to encrypt the volume. This step is not required.

You can add whatever tags you want for identification. This step is not required

Volume type

General Purpose SSD
General Purpose SSD (gp2 and gp3) volumes offer cost-effective storage that is ideal for a broad range of workloads.

Size (GiB)

10 (Gib)

Availability Zone
The Availability Zone in which to create the volume. After you create the volume, you can only attach it to instances that are in the same Availability Zone.

Note: Make sure that EBS and EC2 should be in the same availability zone.

ap-south-1b

And click Create volume

Successfully Create volume 

Attach volume 

4. The EBS volume can be created by selecting the “Create Volume” button.

You can attach a volume to an EC2 instance after it has been created by selecting it in the Volumes list and selecting “Actions” > “Attach Volume.” Name the device and specify the instance to which you want to attach the volume (for example, /dev/sdf).

Click Attach volume

Successfully attached volume  

Check for disk Connect to the instance ( puTTY )

[root@ip-172-31-2-182 ~]# lsblk

New disk attached  xvdf 10G

Create an LVM logical volume on a partition created on an EBS volume

Short description

1. You can allocate disc space as well as stripe, re-mirror, and resize logical volumes with LVM. You can assign a single EBS volume or a group of EBS volumes to one or more physical volumes using LVM.
Follow these procedures to extend the partitions and use LVM on your EBS volume:

2. To create a partition, use the fdisk command. Enter 8e00 as the variable’s Hex or GUID. The partition /dev/xvdf1 is created on /dev/xvdf in the example that follows.

[root@ip-172-31-2-182 ~]# fdisk /dev/xvdf
Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x5cd32037.

Command (m for help): n
Partition type

p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)

Select (default p): e
Partition number (1-4, default 1): ( Enter )
First sector (2048-20971519, default 2048): ( Enter )
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971519, default 20971519): ( Enter )

Created a new partition 1 of type 'Extended' and of size 10 GiB.

Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): 8e
Changed type of partition 'Extended' to 'Linux LVM'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@ip-172-31-2-182 ~]# yum install lvm2

To build a physical volume from the partition, use the pvcreate command. The example below generates a physical volume from the device /dev/xvdh1:

[root@ip-172-31-2-182 ~]# pvcreate /dev/xvdf1

Physical volume “/dev/xvdf1” successfully created.
Creating devices file /etc/lvm/devices/system.devices

Make volume groupings and include the actual volumes therein.

Create a volume group using the vgcreate command to merge the new physical volumes. One physical volume is used in the example below to build volume group datastore:

[root@ip-172-31-2-182 ~]# vgcreate datastore /dev/xvdf1

Volume group “datastore” successfully created

To construct logical volumes (partitions) from your volume group, use the lvcreate command. The example below builds a database with a 10GB logical volume from the datastore volume group:

[root@ip-172-31-2-182 ~]# lvcreate -n database -L 10G datastore

Created a logical volume named “database”

[root@ip-172-31-2-182 ~]# mkfs.ext3 /dev/datastore/database

mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 2621184 4k blocks and 655360 inodes
Filesystem UUID: 172211d1-022b-4d8f-85fa-8c44b223afb9
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

[root@ip-172-31-2-182 ~]# blkid /dev/datastore/database

/dev/xvdf1: UUID=”172211d1-022b-4d8f-85fa-8c44b223afb9″ SEC_TYPE=”ext2″ BLOCK_SIZE=”4096″ TYPE=”ext3″ PARTUUID=”5cd32037-01″

[root@ip-172-31-2-182 ~]# blkid /dev/xvdf1 >> /etc/fstab
[root@ip-172-31-2-182 ~]# vim /etc/fstab

/dev/xvdf1: UUID=”172211d1-022b-4d8f-85fa-8c44b223afb9″ SEC_TYPE=”ext2″ BLOCK_SIZE=”4096″ TYPE=”ext3″ PARTUUID=”5cd32037-01″

UUID=172211d1-022b-4d8f-85fa-8c44b223afb9 /mnt/data ext3 defaults  0  0

[root@ip-172-31-2-182 ~]# mkdir /mnt/data
[root@ip-172-31-2-182 ~]# mount -a
[root@ip-172-31-2-182 ~]# df -h

Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 475M 0 475M 0% /dev/shm
tmpfs 190M 2.8M 188M 2% /run
/dev/xvda1 8.0G 1.5G 6.5G 19% /
tmpfs 475M 0 475M 0% /tmp
tmpfs 95M 0 95M 0% /run/user/1000
/dev/xvda128 10M 1.3M 8.7M 13% /boot/efi
/dev/xvdf1 9.8G 92K 9.3G 1% /mnt/data

[root@ip-172-31-2-182 ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 0 8G 0 disk
├─xvda1 202:1 0 8G 0 part /
├─xvda127 259:0 0 1M 0 part
└─xvda128 259:1 0 10M 0 part /boot/efi
xvdf 202:80 0 10G 0 disk
└─xvdf1 202:81 0 10G 0 part /mnt/datab

Create Volume new small size volume

1. Click “Volumes” on the left navigation pane of the EC2 Dashboard.

2. Select “Create Volume” from the menu.

3. Enter the following information in the “Create Volume” dialogue box.

( 1 ) The preferred availability zone where you wish to establish the EBS volume should be chosen.

( 2 ) Volume Type: Based on your needs, select the appropriate volume type (e.g., magnetic, provisioned IOPS, or general-purpose SSD).

( 3 ) Size: Enter the volume’s size in gibibytes (GiB).

( 4 ) Snapshot: To construct a volume based on a snapshot, select it here if you have one. This step is not required.

( 5 ) Encryption: You can choose this option if you want to encrypt the volume. This step is not required.

You can add whatever tags you want for identification. This step is not required

Volume type

General Purpose SSD
General Purpose SSD (gp2 and gp3) volumes offer cost-effective storage that is ideal for a broad range of workloads.

Size (GiB)

5 (Gib)

Availability Zone
The Availability Zone in which to create the volume. After you create the volume, you can only attach it to instances that are in the same Availability Zone.

Note: Make sure that EBS and EC2 should be in the same availability zone.

ap-south-1b

And click Create volume

Successfully Create volume 

Attach volume 

6. The EBS volume can be created by selecting the “Create Volume” button.

You can attach a volume to an EC2 instance after it has been created by selecting it in the Volumes list and selecting “Actions” > “Attach Volume.” Name the device and specify the instance to which you want to attach the volume (for example, /dev/sdf).

Click Attach volume

Check for disk Connect to the instance ( puTTY )

[root@ip-172-31-2-182 ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 0 8G 0 disk
├─xvda1 202:1 0 8G 0 part /
├─xvda127 259:0 0 1M 0 part
└─xvda128 259:1 0 10M 0 part /boot/efi
xvdf 202:80 0 10G 0 disk
└─xvdf1 202:81 0 10G 0 part /mnt/database
xvdg 202:96 0 5G 0 disk

[root@ip-172-31-2-182 ~]# fdisk /dev/xvdg
Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x5955208c.

Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): e
Partition number (1-4, default 1): ( Enter )
First sector (2048-10485759, default 2048): ( Enter )
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10485759, default 10485759): ( Enter )

Created a new partition 1 of type 'Extended' and of size 5 GiB.

Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): 8e
Changed type of partition 'Extended' to 'Linux LVM'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

create an LVM logical volume on a partition created on an EBS volume

1. You can allocate disc space as well as stripe, re-mirror, and resize logical volumes with LVM. You can assign a single EBS volume or a group of EBS volumes to one or more physical volumes using LVM.
Follow these procedures to extend the partitions and use LVM on your EBS volume:

2. To create a partition, use the fdisk command. Enter 8e00 as the variable’s Hex or GUID. The partition /dev/xvdf1 is created on /dev/xvdf in the example that follows.

[root@ip-172-31-2-182 ~]# pvcreate /dev/xvdg1
[root@ip-172-31-2-182 ~]# vgcreate vgdatastore /dev/xvdg1
root@ip-172-31-2-182 ~]# lvcreate -n lvdatabase -L 5G vgdatastore
[root@ip-172-31-2-182 ~]# mkfs.ext3 /dev/lvdatastore/vgdatabase

mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 1310464 4k blocks and 327680 inodes
Filesystem UUID: 69463fb2-f6cd-48ba-a47b-62df5674daf0
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

[root@ip-172-31-2-182 ~]# blkid /dev/lvdatastore/vgdatabase

/dev/xvdg1: UUID=”69463fb2-f6cd-48ba-a47b-62df5674daf0″ SEC_TYPE=”ext2″ BLOCK_SIZE=”4096″ TYPE=”ext3″ PARTUUID=”5955208c-01″g1

[root@ip-172-31-2-182 ~]# blkid /dev/xvdg1 >> /etc/fstab
[root@ip-172-31-2-182 ~]# vim /etc/fstab

/dev/xvdg1: UUID=”69463fb2-f6cd-48ba-a47b-62df5674daf0″ SEC_TYPE=”ext2″ BLOCK_SIZE=”4096″ TYPE=”ext3″ PARTUUID=”5955208c-01″

UUID=69463fb2-f6cd-48ba-a47b-62df5674daf0 /mnt/database ext3 defaults 0 0

[root@ip-172-31-2-182 ~]# mkdir /mnt/databse
[root@ip-172-31-2-182 ~]# mount -a
[root@ip-172-31-2-182 ~]# df -h

Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 475M 0 475M 0% /dev/shm
tmpfs 190M 2.9M 188M 2% /run
/dev/xvda1 8.0G 1.5G 6.5G 19% /
tmpfs 475M 0 475M 0% /tmp
/dev/xvda128 10M 1.3M 8.7M 13% /boot/efi
/dev/xvdf1 9.8G 92K 9.3G 1% /mnt/data
tmpfs 95M 0 95M 0% /run/user/1000
/dev/xvdg1 4.9G 92K 4.6G 1% /mnt/database

[root@ip-172-31-2-182 ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 0 8G 0 disk
├─xvda1 202:1 0 8G 0 part /
├─xvda127 259:0 0 1M 0 part
└─xvda128 259:1 0 10M 0 part /boot/efi
xvdf 202:80 0 10G 0 disk
└─xvdf1 202:81 0 10G 0 part /mnt/data
xvdg 202:96 0 5G 0 disk
└─xvdg1 202:97 0 5G 0 part /mnt/database

copy data from old drive(data) to new drive(database)

[root@ip-172-31-2-182 data]# cp -avxH /mnt/data/* /mnt/database/

Please check all data copied from the old EBS drive to the new EBS drive

[root@ip-172-31-2-182 ~]# df -h

Change mount point from database to data

[root@ip-172-31-2-182 /]# vim /etc/fstab

Old FSTAB UUID entry.

UUID=eb777ba8-5231-49f6-bb99-13b67bc9b981 /mnt/data ext2 defaults 0 0
UUID=8206c47c-cdaa-4b48-80a5-035c80beb782 /mnt/database ext2 defaults 0 0

New FSTAB UUID entry.

#UUID=eb777ba8-5231-49f6-bb99-13b67bc9b981 /mnt/data ext2 defaults 0 0
UUID=8206c47c-cdaa-4b48-80a5-035c80beb782 /mnt/data ext2 defaults 0 0

[root@ip-172-31-2-253 /]# mount -a

And check the mount point 

[root@ip-172-31-2-253 /]# df -h

[root@ip-172-31-2-253 /]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 475M 0 475M 0% /dev/shm
tmpfs 190M 2.8M 188M 2% /run
/dev/xvda1 8.0G 1.5G 6.5G 19% /
tmpfs 475M 0 475M 0% /tmp
/dev/xvda128 10M 1.3M 8.7M 13% /boot/efi
tmpfs 95M 0 95M 0% /run/user/1000
/dev/xvdg1 5.0G 22M 4.7G 1% /mnt/data

Go to EC2 Dashboard and click “Volumes”

Click 10 (Gib)  EBS and Detach the Volume

EBS 10 (Gib) delete volume

[root@ip-172-31-2-253 /]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 0 8G 0 disk
├─xvda1 202:1 0 8G 0 part /
├─xvda127 259:0 0 1M 0 part
└─xvda128 259:1 0 10M 0 part /boot/efi
xvdg 202:96 0 5G 0 disk
└─xvdg1 202:97 0 5G 0 part /mnt/data

Successfully Detach and delete 

Author

by admin

bg

Subscribe to our Newslatter

Sign Up to Our Newsletter to Get Latest Updates & Services

mail box
logo-footer
HighSky IT Solutions Pvt. Ltd. is a leading IT training and certification programs in Red hat, RSCSA Cloud, Open-source, AWS, Devops and various domains.
Contact Info

2nd floor, Rohera Arcade, opp SOTC office, Near Navrangpura police station, Navrangpura, Ahmedabad -380009 Gujarat

Copyright ©2024 Design & Developed by HighSky IT