To retrieve the serial number of your SSD, HDD, or NVMe drive, you can use the smartctl command-line tool, which is part of the smartmontools package. Below are the steps for installation and usage on RHEL-based and Ubuntu-based systems.
Steps for RHEL-based Systems (e.g., AlmaLinux)
- Install the smartmontoolspackage by running the following command:yum install smartmontools
- Enable and start the smartdservice:systemctl enable smartdsystemctl start smartd
- Retrieve the serial number of your drive using the following command (replace /dev/nvme0n1with your actual device path):smartctl -i /dev/nvme0n1 | grep -i 'serial'
Steps for Ubuntu-based Systems (e.g., Ubuntu 22.04)
- Update your package list and install the smartmontoolspackage by running:sudo apt-get updatesudo apt-get install smartmontools
- Retrieve the serial number of your drive using the following command (replace /dev/nvme0n1with your actual device path):sudo smartctl -i /dev/nvme0n1 | grep -i 'serial'
Optional: Disabling smartd Service
If the smartctl tool is no longer needed, you can disable the smartd service to save system resources. For RHEL-based systems (e.g. AlmaLinux), use the following commands:
systemctl stop smartdsystemctl disable smartdAdditional Notes
- Ensure you have the correct permissions (e.g., root access) to install packages and execute the smartctlcommand.
- Replace /dev/nvme0n1with the appropriate device path for your drive. Common paths include/dev/sdaor/dev/nvme0n1.
- To display more Disk information use the command smartctl -a /dev/nvme0n1(replace /dev/nvme0n1 with your drive path).
- You can show a list of all hard drives by using the command lsblkorfdisk -l | grep -i 'disk'
Using these steps, you can easily retrieve the serial number of your storage drives on both RHEL-based and Ubuntu-based systems.
