Wrong sector size in NVMe

5,118

If you go to Sabrent's download page for your SSD, you'll find a package named "SSC software" - that is a Sector Size Converter.

With it, you can switch the block size presented to the system by the SSD to either 512 or 4096 bytes, but the switching process will destroy all data currently stored on the SSD.

To view the system's current idea of the block size, run lsblk -t. For a true 512-byte storage device (as far as the kernel knows), you should see PHY-SEC, LOG-SEC and MIN-IO all at the value of 512.

For a 512e device, you'll see MIN-IO and PHY-SEC as 4096 and LOG-SEC at 512, indicating that the system knows the device will perform optimally if accessed in chunks of 4k bytes, even if it is currently emulating a classic 512-byte block size.

And for a true 4k device, all the three values should be at 4096.

Share:
5,118

Related videos on Youtube

David Lilue
Author by

David Lilue

Updated on September 18, 2022

Comments

  • David Lilue
    David Lilue almost 2 years

    I bought a new NVMe SSD (SB-ROCKET-256) and installed Arch using gdisk for partioning. In theory, this SSD doesn't support 512e and I think the physical size should be 4096, am I wrong? How do I set it right? The partition table is the following:

    $ parted --align optimal /dev/nvme0n1
    GNU Parted 3.2
    Using /dev/nvme0n1
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted) print                                                            
    Model: Unknown (unknown)
    Disk /dev/nvme0n1: 256GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    Disk Flags: 
    
    Number  Start   End     Size    File system     Name                   Flags
     1      1049kB  273MB   272MB   fat32           EFI System             boot, esp
     2      274MB   64.7GB  64.4GB  ext4            Linux x86-64 root (/)
     3      64.7GB  69.0GB  4295MB  linux-swap(v1)  Linux swap
     4      69.0GB  256GB   187GB   ext4            Linux /home
    

    smarctl output:

    smartctl 7.0 2018-12-30 r4883 [x86_64-linux-5.2.11-1-MANJARO] (local build)
    Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org
    
    === START OF INFORMATION SECTION ===
    Model Number:                       Sabrent
    Serial Number:                      296E0797013700062530
    Firmware Version:                   ECFM12.3
    PCI Vendor/Subsystem ID:            0x1987
    IEEE OUI Identifier:                0x6479a7
    Total NVM Capacity:                 256,060,514,304 [256 GB]
    Unallocated NVM Capacity:           0
    Controller ID:                      1
    Number of Namespaces:               1
    Namespace 1 Size/Capacity:          256,060,514,304 [256 GB]
    Namespace 1 Formatted LBA Size:     512
    Namespace 1 IEEE EUI-64:            6479a7 2223093330
    Local Time is:                      Sat Oct  5 14:51:26 2019 CEST
    

    From what I understand the sector size is set automatically and it should optimal. Is this optimal?

    • frostschutz
      frostschutz over 4 years
      sector size is correct (your ssd is set to pretend 512 byte sectors which is the backwards-compatible choice). +1 for making sure everything is MiB aligned anyway, otherwise don't worry about it
  • David Lilue
    David Lilue over 4 years
    In my case, PHY-SEC, LOG-SEC and MIN-IO were set to 512. The software worked. I lose all my data but not a big deal. I would like to know if there is an option in Linux for setting the SSD to 4k, it should be possible, right?
  • telcoM
    telcoM over 4 years
    Well, if the SSD now reports it's using a 4k block size, the kernel should be detecting that automatically. Use lsblk -t to check.
  • David Lilue
    David Lilue over 4 years
    It says 4096, but I needed Windows to use the SSC software. Is there another way to achieve the same result without Windows, why it needed to be set to 4k manually?
  • telcoM
    telcoM over 4 years
    You might install nvme-cli and use nvme format -b 4096... at your own risk. If your NVMe SSD happens to require some vendor-specific extra set-up commands when changing the block size, your SSD might not work at all after attempting to use nvme format for the block size change.