Storing and Accessing Data on EBS Volume: A Step-by-Step Guide ๐Ÿš€

Storing and Accessing Data on EBS Volume: A Step-by-Step Guide ๐Ÿš€

ยท

3 min read

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

  1. 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 the Ubuntu image and configure other settings like the subnet (AP South 1) and enable the required options.

  2. 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 ๐Ÿ—‚๏ธ

  1. 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
    
  2. Identify Volumes: Note the names of the volumes. The root volume might be xvda, and the additional volume could be xvdb.

Formatting and Mounting the EBS Volume ๐Ÿ› ๏ธ

  1. Format the Volume: Convert the new volume (xvdb) to ext4 format using the following command:

     sudo mkfs.ext4 /dev/xvdb
    
  2. Create a Mount Directory: Create a directory where you will mount the EBS volume:

     sudo mkdir /test
    
  3. 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 ๐Ÿ“‚

  1. Navigate to the Mount Directory: Go to the mount directory:

     cd /test
    

    Navigating to Mount Directory

  2. Create Files: Create some files to test data storage:

     sudo touch file1.txt file2.txt
    
  3. 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 ๐Ÿ”„

  1. Unmount the Volume: Before detaching, unmount the volume:

     sudo umount /test
    
  2. Detach the Volume: Go to the AWS console, select the volume, and detach it from the instance.

  3. 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! ๐ŸŒŸ

ย