This article will detail how to use the nvme-cli
tool to upgrade NVMe solid-state drive (SSD) firmware in a Linux environment. The tutorial covers preparation, key commands, and steps for checking and restarting after the upgrade, aiming to help users successfully complete the firmware upgrade.
Before starting the upgrade, ensure the following conditions are met:
1. Operating System: Linux OS
2. The nvme-cli
tool must be installed, with version v2.10 or above supporting firmware updates
Commands to install nvme-cli
on different Linux distributions:
Ubuntu/Debian:
sudo apt-get install nvme-cli
CentOS/RHEL:
sudo yum install nvme-cli
Fedora:
sudo dnf install nvme-cli
Arch Linux:
sudo pacman -S nvme-cli
If the current version of nvme-cli
does not support firmware updates, you can manually download the latest version:
1. Disk Connection and Recognition
First, ensure the NVMe device is correctly connected to the system and recognized with the following command:
nvme list
The output should list the connected NVMe devices, confirming the device name Node (e.g., /dev/nvme0n1
).
2. Upload Firmware File
Download and upload the firmware file to the Linux system. It is recommended to place it in the /root
directory for easy access.
1. Download Firmware
Use the nvme-cli
fw-download
command to download the firmware to the specified slot on the NVMe device. Replace
<device>
and <firmware file path>
with the actual path to the firmware file:
# nvme fw-download -f
nvme fw-download /dev/nvme0n1 -f /root/firmware.bin
2. Execute Upgrade Operation
Use the fw-commit
command to perform the firmware upgrade. Choose the activation method according to the environment:
# nvme fw-commit /dev/nvme0 -s -a 1
nvme fw-commit /dev/nvme0 -s 2 -a 3
This command writes the firmware to the specified slot and activates the update.
-A Explanation: The parameter specifies the firmware activation method. The options are as follows:
-a 1 Activate immediately (no reboot required). The firmware update will be applied and activated immediately without needing to reboot the device. This method is suitable for updates that need to take effect quickly.
-a 2 Manual reset required. The firmware update will take effect after a manual reset. This is suitable for scenarios where manual intervention is needed to ensure the update is successful.
-a 3 Activate after reboot. The firmware update will take effect after a device reboot. This method is typically used when a stable system reboot is required to ensure the update is applied successfully.
-S Explanation: The parameter specifies the firmware slot to be used. According to standard definitions, SSDs support up to 7 firmware slots, each with different purposes and permissions.
-s 1 Reserved for factory firmware, which is read-only and cannot be written to. It stores the firmware version pre-installed by the SSD manufacturer.
-s 2~3 These slots can be used to download new firmware versions. Typically, new firmware is downloaded to these slots during upgrades.
-s 4~7 Enterprise SSDs support up to 7 firmware slots, often used for storing and updating firmware, but specific usage may depend on the SSD manufacturer and product type.
3. Perform SSD Reset or Power Cycle Operation.
nvme reset /dev/nvme* (reset to make firmware effective; if -a 3 was used in step 2, reset is not needed)
*** Based on practical application tests, if the reset command does not make the firmware effective, you can perform a reboot to make the firmware effective in Linux OS.
1. Check Device Status
After the upgrade, use the nvme list
command to check the device status and ensure the firmware upgrade was successful.
2. View Firmware History
nvme fw-log /dev/nvme0n1
*** The fw-log
command can query firmware upgrade history (slot)
By following these steps, you can successfully use the nvme-cli
tool to upgrade the NVMe SSD firmware in a Linux environment. Before upgrading, be sure to back up important data and carefully check all parameters to ensure a smooth upgrade process.