Hello friends, my name is Bilal Khan. Today, I'm going to show you how to store data in an EBS volume and access it. Follow along as I take you through all the steps needed for this process. ๐ฆ๐
Here is the video explanation of it:
Setting Up the Instance and Volume
In my previous video, I explained how to attach an instance to a volume. If you missed it, check it out to get up to speed. Now, let's dive into inserting data into the EBS volume using some simple commands.
Launching an Instance
Create the Instance: If you haven't created an instance yet, go to the AWS console, click on "Launch Instance", and give it a name like
EBS-client
. Choose theUbuntu
image and configure other settings like the subnet (AP South 1
) and enable the required options.Configure Storage: During instance setup, add a new volume. For example, you can add a 6 GB General Purpose SSD. This will be your EBS volume.
Connecting to the Instance
Once your instance is running, click on Connect
it to access the terminal. This will open the SSH terminal in your browser.
Listing and Accessing EBS Volume ๐๏ธ
List EBS Volumes: Use the command
lsblk
to list all the block devices attached to your instance. This will show the root volume and the additional volume you added.lsblk
Identify Volumes: Note the names of the volumes. The root volume might be
xvda
, and the additional volume could bexvdb
.
Formatting and Mounting the EBS Volume ๐ ๏ธ
Format the Volume: Convert the new volume (
xvdb
) toext4
format using the following command:sudo mkfs.ext4 /dev/xvdb
Create a Mount Directory: Create a directory where you will mount the EBS volume:
sudo mkdir /test
Mount the Volume: Mount the volume to the directory you just created:
sudo mount /dev/xvdb /test
Verify the mount point to ensure it's mounted correctly:
mountpoint /test
Storing and Accessing Data ๐
Navigate to the Mount Directory: Go to the mount directory:
cd /test
Create Files: Create some files to test data storage:
sudo touch file1.txt file2.txt
Verify Files: List the files to ensure they have been created:
ls
Additional Operations
You can also perform other file operations within this directory, like copying, moving, or deleting files. These changes will be stored in the EBS volume.
Detaching and Reattaching the Volume ๐
Unmount the Volume: Before detaching, unmount the volume:
sudo umount /test
Detach the Volume: Go to the AWS console, select the volume, and detach it from the instance.
Reattach the Volume: To reattach, follow the same steps used initially to attach the volume to your instance.
Conclusion
By following these steps, you can efficiently store and access data in an EBS volume. Whether you're setting up a new volume or reattaching an existing one, these commands will help you manage your data seamlessly.
You can Buy Me a Coffee if you want to and don't forget to follow me on YouTube, Twitter, and LinkedIn.
Feel free to check out my previous videos for more detailed steps on creating instances and volumes. Happy learning! ๐