Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mounting a NVME disk on AWS EC2

So I created i3.large with NVME disk on each nodes, here was my process :

  1. lsblk -> nvme0n1 (check if nvme isn't yet mounted)
  2. sudo mkfs.ext4 -E nodiscard /dev/nvme0n1
  3. sudo mount -o discard /dev/nvme0n1 /mnt/my-data
  4. /dev/nvme0n1 /mnt/my-data ext4 defaults,nofail,discard 0 2
  5. sudo mount -a (check if everything is OK)
  6. sudo reboot

So all of this works, I can connect back to the instance. I have 500 Go on my new partition.

But after I stop and restart the EC2 machines, some of them randomly became inaccessible (AWS warning only 1/2 test status checked)

When I watch the logs of why it is inaccessible it tells me, it's about the nvme partition (but I did sudo mount -a to check if this was ok, so I don't understand)

I don't have the AWS logs exactly, but I got some lines of it :

Bad magic number in super-block while trying to open

then the superblock is corrupt, and you might try running e2fsck with an alternate superblock:

/dev/fd/9: line 2: plymouth: command not found

like image 406
tricky Avatar asked Jul 18 '17 13:07

tricky


People also ask

What is NVMe in AWS?

AWS is adding a new kind of virtual machine to its growing list of EC2 options. These new machines feature local NVMe storage, which offers significantly faster throughput than standard SSDs. These new so-called C5d instances join the existing lineup of compute-optimized C5 instances the service already offered.

How do you mount attached EBS volume to EC2?

To attach an EBS volume to an instance using the consoleOpen the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . In the navigation pane, choose Elastic Block Store, Volumes. Select an available volume and choose Actions, Attach Volume. For Instance, start typing the name or ID of the instance.


1 Answers

I have been using "c5" type instances since almost a month, mostly "c5d.4xlarge" with nvme drives. So, here's what has worked for me on Ubuntu instances:

first get the location nvme drive is located at:

lsblk 

mine was always mounted at nvme1n1. Then check if it is an empty volume and doens't has any file system, (it mostly doesn't, unless you are remounting). the output should be /dev/nvme1n1: data for empty drives:

sudo file -s /dev/nvme1n1 

Then do this to format(if from last step you learned that your drive had file system and isn't an empty drive. skip this and go to next step):

sudo mkfs -t xfs /dev/nvme1n1 

Then create a folder in current directory and mount the nvme drive:

sudo mkdir /data sudo mount /dev/nvme1n1 /data 

you can now even check it's existence by running:

df -h 
like image 75
Naveen Reddy Marthala Avatar answered Sep 22 '22 06:09

Naveen Reddy Marthala