How To Attach EBS Volume to EC2 Linux Instance In AWS

Let’s create Elastic Block Store (EBS) volume and attach it to Linux. An EC2 instance comes with a storage. But, this storage only persists with the instance. If you need to terminate the instance and start a new one, you will loose the data. If you keep the data in EBS, you can launch the new instance and simply attach the existing EBS to that instance.

This is an optional step in How To Create Your Personal Data Science Computing Environment In AWS.

As a prerequisite, you need to have a running EC2 instance. If you want to know how to launch an instance, check here (How To Launch an EC2 Instance From AMI in AWS).

This process is fun because you get to use a bit of Linux admin skills. OK, let’s begin.

Steps

(1) Create a new EBS volume

Go to EC2 dashboard and create a new volume. Choose the same availability zone as the EC2 instance. You can get up to 30 GB free EBC as part of 12-month free tier.

(2) Attach the volume to the EC2 instance

Under Actions, click attach volume and choose the right instance. Once the status turns green (in-use), it is ready to go. SSH to the instance and check to see if EBS is attached to the instance by lsblk command.

Note that the volume is not mounted to the file system. You can check it with df -h command.

(3) Create a file system with mkfs command

You need to create a file system with the mkfs command. EBS is not ready to use yet. By default, the command creates an ext2 filesystem. Although it is usable by Linux, journaling filesystem with ext4 is a better option.

sudo mkfs -t ext4 /dev/xvdf

(4) Create a mount point and mount the disk

Once the disk is ready for use, you can create a mount point and mount the disk.

cd /
sudo mkdir -p /mnt/data
sudo mount /dev/xvdf mnt/data

Here is the command for unmounting the disk in case you want to unmount it and attach to another instance.

sudo umount -d /dev/xvdf

(5) Check the disk

Now you can see the disk is mounted to the instance. Yay!

You can go back to How To Create Your Personal Data Science Computing Environment In AWS to complete the rest of the steps!

Git
How to specify which Node version to use in Github Actions

When you want to specify which Node version to use in your Github Actions, you can use actions/setup-node@v2. The alternative way is to use a node container. When you try to use a publicly available node container like runs-on: node:alpine-xx, the pipeline gets stuck in a queue. runs-on is not …

AWS
Using semantic-release with AWS CodePipeline and CodeBuild

Here is the usual pattern of getting the source from a git repository in AWS CodePipeline. In the pipeline, we use AWS CodeStart to connect to a repo and get the source. Then, we pass it to the other stages, like deploy or publish. For some unknown reasons, CodePipeline downloads …

DBA
mysqldump Error: Unknown table ‘COLUMN_STATISTICS’ in information_schema (1109)

mysqldump 8 enabled a new flag called columm-statistics by default. When you have MySQL client above 8 and try to run mysqldump on older MySQL versions, you will get the error below. mysqldump: Couldn’t execute ‘SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM ‘$”number-of-buckets-specified”‘) FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = ‘myschema’ AND TABLE_NAME = ‘craue_config_setting’;’: Unknown …