Change Disk Sector Size in NVMe Drives

To change the disk sector size of your NVMe drives, follow the below steps:

First, we need to check the NVMe drives locations, by running the below command:

lsscsi -gs

This will show you the NVMe drives locations on your server.

NVMe Drive Locations

Now note down the locations on your NotePad for the next steps.

Before proceeding, we need to check which sector size we do have in our NVMe disks. To check run the below command:

fdisk -l

Here, you can see our disk sector size for the first two drives is 4096 bytes. Which I want to change to 512 bytes.

Disk Sector Size

Here, I am going to resize the below NVMe disk sector.

/dev/nvme1n1
/dev/nvme2n1

So, we will do this one by one. Let’s format this /dev/nvme1n1 drive with 512 bytes. To do this run the below command:

nvme format /dev/nvme1n1 –block-size=512

Note: If you have 512 bytes disk sector size, and want to change to 4096 bytes, then simply modify the last value from 512 to 4096

This process will take a minimum of 10 seconds, and the disk sector size will be changed to 512 bytes.

Now run the same for the other disk. Here, we just changed the disk location.

nvme format /dev/nvme2n1 –block-size=512

Again this also will take a minimum of 10 seconds and the disk sector size will be updated. Now to verify if the disk sector size changed or not run the below command.

fdisk -l

This command will show you all the disk information attached on the server. Here, as you can see, both of our NVMe disk sector has been updated from 4096 bytes to 512 bytes.

Change Disk Sector in NVMe Drives

During the steps, if you found any command is missing on your system, you can search for the command on Google and download the package as per your operating system. The nvme-cli was missing on our server, so I used the below command to install that on our server.

You can install nvme-cli from your distribution package manager. For instance, on Fedora, CentOS, or similar:

sudo dnf install nvme-cli

On Debian, Mint, Elementary, and similar:

sudo apt install nvme-cli 

Warning:

1. This process will wipe out your drives, so take backup before if necessary.

2. I had software RAID1 setup on the 2×7 TB NVMe drives, but after this resizing process, the RAID also got wiped off. So, I had to do the RAID setup again.

Was this helpful?

2 / 0