Skip to main content

NVMe drives in H100 VMs

Mount an NVMe drive in Ubuntu (H100 VMs)

Step 1: Identify the NVMe Drive

Open a terminal and run:

sudo lsblk

Your NVMe drives will appear as /dev/nvme0n1

Step 2: Open fdisk to Partition the Drive

Use fdisk to partition the drive:

sudo fdisk /dev/nvme0n1

Note: Make sure to replace /dev/nvme0n1 with the correct drive if necessary.

Step 3: Partition the Drive with fdisk

Once inside fdisk, use these steps to create a new partition:

  1. Type n to create a new partition.
  2. Choose a partition number (usually 1 if it’s a new drive).
  3. Specify the first and last sector (you can press Enter to use the defaults, which will use the entire drive up to a max of 2T because it is using MBR. If you need more space, see below section Converting from MBR to GPT for instructions).
  4. Write the changes by typing w and pressing Enter. This process creates a single partition on the drive, which you’ll see as /dev/nvme0n1p1.

Step 4: Format the Partition

Format the new partition with a filesystem (ext4 in this case).

sudo mkfs.ext4 /dev/nvme0n1p1

Step 5: Create a Mount Point

Choose a directory where you’d like to mount the NVMe drive, or create one if it doesn’t exist. For example:

sudo mkdir /data

Step 6: Mount the Drive

Mount the partition (e.g., /dev/nvme0n1p1) to your chosen mount point:

sudo mount /dev/nvme0n1p1 /data

Step 7: Verify the Mount

You can verify that the drive is mounted by listing the contents of the mount point:

ls /data

Step 8: Automount on Boot

To mount the drive automatically on boot, edit the /etc/fstab file:

sudo nano /etc/fstab

Add a new line with the following format:

/dev/nvme0n1p1  /data  ext4  defaults  0  2

To test, unmount the drive:

sudo umount /data

Then remount all drives listed in /etc/fstab:

sudo mount -a

Step 9: Change Permissions

You can set read, write, and execute permissions on the mount point as needed. Here are some common examples:

  • Full access to everyone:
sudo chmod -R 777 /data
  • Full access to the owner, read access to others:
sudo chmod -R 755 /data
  • Full access only for the owner:
sudo chmod -R 700 /mnt/nvme

Converting from MBR to GPT

By default, fdisk uses the MBR (Master Boot Record) partition table, which has a 2TB size limit. To use the full capacity of a disk larger than 2TB, you need to use the GPT (GUID Partition Table) scheme instead.

Here’s how to set up a GPT partition table and create a new partition that spans the entire disk:

Step 1: Backup Any Important Data

If there’s any data on the drive, back it up before proceeding. Converting to GPT will delete existing partitions.

Step 2: Use gdisk to Create a GPT Partition Table

Run gdisk to modify the partition table:

sudo gdisk /dev/nvme0n1

Step 3: Convert to GPT and Create a New Partition

  1. Convert to GPT:
  • Type o and press Enter to create a new GPT partition table. (This will wipe existing partitions on the disk.)
  1. Create a New Partition:
  • Type n to create a new partition.
  • Choose the default partition number (usually 1).
  • Press Enter to accept the default first sector.
  • Press Enter to accept the default last sector, allowing the partition to use the entire available space.
  1. Write the Changes:
  • Type w to write the changes to the disk and confirm when prompted.

Step 4: Format the New Partition

Now format the newly created partition, adjusting the following command if needed for a different filesystem:

sudo mkfs.ext4 /dev/nvme0n1p1

Step 5: Verify the Partition Size

After formatting, check the partition size:

lsblk

You should now see the partition using the full 3.84TB.