{"id":2831,"date":"2022-03-21T08:25:13","date_gmt":"2022-03-21T15:25:13","guid":{"rendered":"https:\/\/www.cloudinsidr.com\/content\/?p=2831"},"modified":"2022-03-22T08:02:33","modified_gmt":"2022-03-22T15:02:33","slug":"how-to-attach-and-mount-an-nvme-ebs-volume-on-ec2","status":"publish","type":"post","link":"https:\/\/www.cloudinsidr.com\/content\/how-to-attach-and-mount-an-nvme-ebs-volume-on-ec2\/","title":{"rendered":"How to attach and mount an NVMe EBS volume on EC2"},"content":{"rendered":"<p>The versatile advantages of NVMe are becoming increasingly apparent in modern storage systems. You can take advantage of them in the cloud.<\/p>\n<p><!--more--><\/p>\n<p>Connect to your EC2 instance using an ssh\u00a0client such as\u00a0<a href=\"https:\/\/cloudinsidr.com\/content\/tip-of-the-day-how-to-transfer-putty-settings-to-another-computer\/\">PuTTY<\/a>, then sudo su.<\/p>\n<h2>Install drivers and tools<\/h2>\n<p>Make sure your system is up to date and knows how to handle NVMe. On Fedora\/RHEL:<\/p>\n<pre># sudo dnf update -y\r\n# dnf install nvme*\r\n# dnf install nvme-cli nvmetcli\r\n# sudo dnf install xfsprogs<\/pre>\n<p>Show information about the kernel module nvme:<\/p>\n<pre># modinfo nvme<\/pre>\n<h2>View block devices<\/h2>\n<p>View block devices using:<\/p>\n<pre># lsblk<\/pre>\n<p>You may see something like this:<\/p>\n<pre># lsblk<\/pre>\n<pre style=\"padding-left: 40px;\">NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS\r\nzram0 252:0 0 1.9G 0 disk [SWAP]\r\nnvme0n1 259:0 0 30G 0 disk\r\n\u251c\u2500nvme0n1p1 259:1 0 1M 0 part\r\n\u251c\u2500nvme0n1p2 259:2 0 500M 0 part \/boot\r\n\u251c\u2500nvme0n1p3 259:3 0 100M 0 part \/boot\/efi\r\n\u251c\u2500nvme0n1p4 259:4 0 4M 0 part\r\n\u2514\u2500nvme0n1p5 259:5 0 29.4G 0 part \/home\r\n\/\r\nnvme1n1 259:6 0 40G 0 disk<\/pre>\n<p>nvme1n1 is your new unformatted, unpartitiond vanilla NVMe drive,<\/p>\n<p>You can list all NVMe devices using:<\/p>\n<pre># nvme list<\/pre>\n<p>and identify the NVMe Controller responsible for an individual partition (e.g. \/dev\/nvme1n1):<\/p>\n<pre># sudo nvme id-ctrl -v \/dev\/nvme1n1<\/pre>\n<h2>Create a new partition<\/h2>\n<p>Create a new partition using fdisk:<\/p>\n<pre># fdisk \/dev\/nvme1n1<\/pre>\n<pre>Welcome to fdisk (util-linux 2.37.4).\r\nChanges will remain in memory only, until you decide to write them.\r\nBe careful before using the write command.\r\n\r\nDevice does not contain a recognized partition table.<\/pre>\n<p>Follow the on-screen instructions. Use n to create a new partition and w to write it to disk. (For more on how to handle fdisk, see &#8220;<a href=\"https:\/\/www.cloudinsidr.com\/content\/how-to-expand-an-xfs-ebs-volume-on-aws-ec2\/\">How to expand an (xfs) EBS volume on AWS EC2<\/a>&#8220;.)<\/p>\n<h2>Format the new partition and mount it<\/h2>\n<p>You may need to create a new file system on the newly created partition:<\/p>\n<pre># mkfs.xfs \/dev\/nvme1n1p1<\/pre>\n<p>Mount it one-time:<\/p>\n<pre># mount \/dev\/nvme1n1p1 \/var\/www\/html\/<\/pre>\n<p>If you would like the volume to mount automatically after each reboot, you need to configure \/etc\/fstab accordingly. First, make a backup of the original version of the file:<\/p>\n<pre># sudo cp \/etc\/fstab \/etc\/fstab.orig<\/pre>\n<p>Now you need to figure out the UUID of the new partition to properly reference it:<\/p>\n<pre># blkid\r\n(...)\r\n\/dev\/nvme1n1p1: UUID=\"146de8f2-2f9d-4d3c-9e25-174585ca7fd4\" BLOCK_SIZE=\"512\" TYPE=\"xfs\" PARTUUID=\"ce613f49-01\"<\/pre>\n<p>Edit \/etc\/fstab using a text editor of your choice:<\/p>\n<pre># nano \/etc\/fstab<\/pre>\n<p>Enter this line at the end of \/etc\/fstab (add spaces as you see fit):<\/p>\n<pre>UUID=146ce7f2-2f9e-4d2c-9e15-174585ca7fd4 \/var\/www\/html xfs defaults,nofail 0 2<\/pre>\n<p>The nofail flag ensures that the system will boot without errors when the volume fails. The first digit represents the file system dump (the system utility dump for backups of an ext2\/3\/4 fs; xfsdump for xfs), the second is the fsck flag (file system check) for the partition. It determins the order of the file system check at boot time (the root should have 1, the rest should have 2 unless deactivated with 0).<\/p>\n<p>Now you should be able to unmount it:<\/p>\n<pre># sudo umount \/var\/www\/html\/<\/pre>\n<p>and mount it again based on the \/etc\/fstab file:<\/p>\n<pre># sudo mount -a<\/pre>\n<p>You are done.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The versatile advantages of NVMe are becoming increasingly apparent in modern storage systems. You can take advantage of them in the cloud.<\/p>\n","protected":false},"author":1,"featured_media":2839,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[143,213],"tags":[202,78,63,280],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to attach and mount an NVMe EBS volume on EC2 - CloudInsidr<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cloudinsidr.com\/content\/how-to-attach-and-mount-an-nvme-ebs-volume-on-ec2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to attach and mount an NVMe EBS volume on EC2 - CloudInsidr\" \/>\n<meta property=\"og:description\" content=\"The versatile advantages of NVMe are becoming increasingly apparent in modern storage systems. You can take advantage of them in the cloud.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cloudinsidr.com\/content\/how-to-attach-and-mount-an-nvme-ebs-volume-on-ec2\/\" \/>\n<meta property=\"og:site_name\" content=\"CloudInsidr\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-21T15:25:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-22T15:02:33+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2022\/03\/optane-ssd-905p-right-angle-16x9.png.rendition.intel_.web_.480.270.webp\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#website\",\"url\":\"https:\/\/www.cloudinsidr.com\/content\/\",\"name\":\"CloudInsidr\",\"description\":\"Cyber security, infotech\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.cloudinsidr.com\/content\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/how-to-attach-and-mount-an-nvme-ebs-volume-on-ec2\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2022\/03\/optane-ssd-905p-right-angle-16x9.png.rendition.intel_.web_.480.270.webp\",\"width\":480,\"height\":270,\"caption\":\"Intel Optane SSD 905P\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/how-to-attach-and-mount-an-nvme-ebs-volume-on-ec2\/#webpage\",\"url\":\"https:\/\/www.cloudinsidr.com\/content\/how-to-attach-and-mount-an-nvme-ebs-volume-on-ec2\/\",\"name\":\"How to attach and mount an NVMe EBS volume on EC2 - CloudInsidr\",\"isPartOf\":{\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/how-to-attach-and-mount-an-nvme-ebs-volume-on-ec2\/#primaryimage\"},\"datePublished\":\"2022-03-21T15:25:13+00:00\",\"dateModified\":\"2022-03-22T15:02:33+00:00\",\"author\":{\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#\/schema\/person\/dd6ee9cb21cf05763fd7cff3d6f11b2b\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.cloudinsidr.com\/content\/how-to-attach-and-mount-an-nvme-ebs-volume-on-ec2\/\"]}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#\/schema\/person\/dd6ee9cb21cf05763fd7cff3d6f11b2b\",\"name\":\"Cloud Insidr\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8b2fa1415b3d573b97d818b8f8f83b7c?s=96&d=mm&r=g\",\"caption\":\"Cloud Insidr\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts\/2831"}],"collection":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/comments?post=2831"}],"version-history":[{"count":7,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts\/2831\/revisions"}],"predecessor-version":[{"id":2843,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts\/2831\/revisions\/2843"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/media\/2839"}],"wp:attachment":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/media?parent=2831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/categories?post=2831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/tags?post=2831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}