Finding hard drive information

dos2unix

Well-Known Member
Joined
May 3, 2019
Messages
3,237
Reaction score
2,989
Credits
28,493
I was a little surprised to find out that lspci will see my nvme hard drives, but it doesn't see my ssd hard drives.

Code:
root@absTower:~# lspci | grep -i ssd

Outputs this
Code:
01:00.0 Non-Volatile memory controller: Sandisk Corp WD Black SN850X NVMe SSD (rev 01)

However fdisk shows all my hard drives.

Code:
fdisk -l | grep Disk | grep -v mapp

Outputs this
Code:
Disk /dev/sda: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: SQF-SM4V2-256G-S
Disklabel type: gpt
Disk identifier: 34713260-E825-4896-A4D7-27A13153B7A4
Disk /dev/sdb: 489.05 GiB, 525112713216 bytes, 1025610768 sectors
Disk model: Crucial_CT525MX3
Disklabel type: gpt
Disk identifier: 214CD305-8D57-49C3-A244-B232E66D2141
Disk /dev/nvme0n1: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: WD_BLACK SN850X 2000GB                
Disklabel type: gpt
Disk identifier: 09A0425F-2853-45FA-AB17-9D096F9C58E1
Disk /dev/zram0: 8 GiB, 8589934592 bytes, 2097152 sectors

As mentioned in some other tutorials, you can use...

Code:
smartctl -a /dev/nvme0n1

To get info about nvme drives.
..and you can use...

Code:
smartctl -x /dev/sda

To get info about most hdd and ssd hard drives.

There is another command, we haven't talked much about. It's a more advanced command.
Most of my tutorials have been basic stuff. This command is a little more advanced.
If you have an ssd or hdd hard drive, you'll be happy to know this command works on those, but
not nvme type drives. I almost hate to mention it here, because if you don't know what you're doing
it can mess things up, but here we go.

Disclaimer: I'm not responsible for any commands you run.

This first command is pretty harmless, it just gives you some information.
Code:
sudo hdparm -I /dev/sdX

Just change the X to whatever your drive letter is.

This will tell you the current power mode of the drive.
Code:
sudo hdparm -C /dev/sdX

This will set the power mode level on your hard drive.
Code:
sudo hdparm -B 128 /dev/sdX

(1-127 allows spin-down, 128-254 prevents spin-down)

Enable or disable direct memory access. (Not all drives support this).
Code:
sudo hdparm -d1 /dev/sdX  # Enable DMA
sudo hdparm -d0 /dev/sdX  # Disable DMA

Set the acoustic manager level, lower values are quieter, higher values are faster)
Code:
sudo hdparm -M 128 /dev/sdX

Enable 32 bit I/O (This can increase performance on some drives)
Code:
sudo hdparm -c1 /dev/sdX

Set the read ahead sector count
Code:
sudo hdparm -a 256 /dev/sdX

Check the status of write caching.
Code:
sudo hdparm -W /dev/sdX

Enable write caching.
Code:
sudo hdparm -W1 /dev/sdX

Disable write caching.
Code:
sudo hdparm -W0 /dev/sdX

You can run the status command after you set this to see if it took effect.
Write caching can improve performance by writing to memory before writing to disk.
However, the downside is, if your computer gets unexpectedly shut down ( a power outage for example )
You will lose whatever data is in the memory cache.

I recommend writing down all your current/factory settings before changing anything.

Hopefully this will help someone.
 
Last edited:


I was a little surprised to find out that lspci will see my nvme hard drives, but it doesn't see my ssd hard drives.

Code:
root@absTower:~# lspci | grep -i ssd
It could be that it's an older ssd which is on the SATA bus rather than the PCIe bus which is where nvme ssd's usually live. If that's the case, it wouldn't be within the lspci purview to see it. The lsblk command should pick it up though.
 
I was a little surprised to find out that lspci will see my nvme hard drives, b
Now that surprises me, by now I would have thought you would have realised they are on usually on a different bus. Because of the faster transfer rates, NVMe are on the PCIE x4 and SSD's are on the SATA bus, that is why for basic drive info I use inxi -d
 
If you have an older drive, chances are you may have some bad sectors on it.
How can you find out?

Code:
sudo badblocks -v /dev/sdX

Note: this can take a very long time, depending on the size of your drive.

This checks the sectors on your hard drive at a physical level. Not at the file system level.
(that's a different command "fsck", maybe another article some day)

There are some flags to this command, if you just type "badblocks" without anything after it
it will show you some usage examples.

This does work on nvme type drives as well.
 
Another thing you can do with hdparm. A secure erase.

Before we run this command, we have to set a password. The password is temporary
and it only in effect for the period of time it takes to erase the hard drive. It can be pretty much
anything you want.

Code:
sudo hdparm --user-master u --security-set-pass password /dev/sdX

Once the password is set, now you can erase the hard drive.

Code:
sudo hdparm --user-master u --security-erase "password" /dev/sdX

This pretty much puts the drive back in factory/reset mode.
If you decide to use this command again, you'll have to create another password again.

This has saved some LUKS encrypted drives for me in the past.
But it doesn't work if it's the drive you are booted from. :)

Another way to erase your hard drive in a "somewhat" more secure way than a simple re-format.

Code:
sudo dd if=/dev/zero of=/dev/sdX bs=1M

This can take a while. Maybe order a pizza while you are waiting.
 
have you tried

sudo smartctl --attributes --log=selftest /dev/sda [replace sda with location of your drive]
 
Now that surprises me, by now I would have thought you would have realised they are on usually on a different bus. Because of the faster transfer rates, NVMe are on the PCIE x4 and SSD's are on the SATA bus,

I have some computer that have the 3.5 inch drives connected to the SATA bus via SATA cable and that is true for them.

But on this particular motherboard - https://www.msi.com/Motherboard/MEG-X570-UNIFY/Overview

The SSD's are in m.2 slots. You can put either NVME or SSD in these m.2 slots.

These SSD's look just like a NVME m.2 drive.


@Brickwizard
I have thought about replacing them with nvme drives, but I'm not rich like you and @osprey :)
Besides, they work good enough for what I'm doing.

My main driver (it's dual boot, and is currently in Windows )
But it's the same way - https://www.msi.com/Motherboard/X670E-GAMING-PLUS-WIFI/Overview

I do have both 3.5 inch SSDs and m.2 SSd's in that system. But my main OS drives are nvme.
 
Last edited:
The SSD's are in m.2 slots. You can put either NVME or SSD in these m.2 slots.
Be very careful when you make this statement, M2 slots come in 6 types the most common to take the 22x? SSD/NVMe card are

1] M2 B used for SATA and wireless cards [your media start probably has one with the WI FI card in
2] M2 M mainly used for NVME
3] M2 BM can be used for both above
4] M2 E specifically for WI-FI and other small card peripherals or adaptor cables

the other 2 types are the old standards, and not been used for quite a while.
 
Last edited:
I booted my other computer into Linux.

ray@LianLi:~$ lspci | grep -i ssd
06:00.0 Non-Volatile memory controller: Intel Corporation SSD 660P Series (rev 03)
17:00.0 Non-Volatile memory controller: Sandisk Corp WD Black SN850X NVMe SSD (rev 01)

ray@LianLi:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 223.6G 0 disk
├─sda1 8:1 0 200M 0 part
├─sda2 8:2 0 3G 0 part
├─sda3 8:3 0 40G 0 part
├─sda4 8:4 0 35G 0 part
├─sda5 8:5 0 30G 0 part
├─sda6 8:6 0 25G 0 part
├─sda7 8:7 0 9.5G 0 part
└─sda8 8:8 0 7.7G 0 part
sdb 8:16 0 238.5G 0 disk
├─sdb1 8:17 0 16M 0 part
└─sdb2 8:18 0 238.5G 0 part
sdc 8:32 0 953.9G 0 disk
├─sdc1 8:33 0 320M 0 part /boot/efi
├─sdc2 8:34 0 3G 0 part /boot
├─sdc3 8:35 0 500G 0 part /home
├─sdc4 8:36 0 45G 0 part /
├─sdc5 8:37 0 35G 0 part /var
├─sdc6 8:38 0 10G 0 part [SWAP]
└─sdc7 8:39 0 350G 0 part /space
zram0 252:0 0 8G 0 disk [SWAP]
nvme0n1 259:0 0 1.9T 0 disk
├─nvme0n1p1 259:1 0 16M 0 part
└─nvme0n1p2 259:2 0 1.9T 0 part
nvme1n1 259:3 0 1.8T 0 disk
├─nvme1n1p1 259:4 0 100M 0 part
├─nvme1n1p2 259:5 0 16M 0 part
├─nvme1n1p3 259:6 0 1.8T 0 part
└─nvme1n1p4 259:7 0 768M 0 part

This has 2 nvme drives and 3 ssd drives.
sdc is a 3.5 inch connected via SATA cable.

sda is an external drive connected via USB.

But both nvme drives and sdb are all in m.2 slots.

I am aware of the different m.2 slot types, all my drives work on both systems.
What's funny is only one of my nvme drives shows up in lspci, but also only 1 of my ssd drives.
(More investigation required)

However everything shows up in lsblk and fdisk.
 
for basic drive info I use inxi -d

This works pretty good also.

Code:
root@LianLi:~# inxi -d
Drives:
  Local Storage: total: 5.07 TiB used: 11.01 GiB (0.2%)
  ID-1: /dev/nvme0n1 vendor: Intel model: SSDPEKNW020T8 size: 1.86 TiB
  ID-2: /dev/nvme1n1 vendor: Western Digital model: WD BLACK SN850X 2000GB
    size: 1.82 TiB
  ID-3: /dev/sda vendor: Kingston model: SUV500240G size: 223.57 GiB
  ID-4: /dev/sdb model: 2.5 SATA SSD 3ME3 size: 238.47 GiB
  ID-5: /dev/sdc vendor: Realtek model: RTL9210B size: 953.87 GiB type: USB
  Message: No optical or floppy data found.

Code:
root@absTower:~# inxi -d
Drives:
  Local Storage: total: 2.53 TiB used: 98.69 GiB (3.8%)
  ID-1: /dev/nvme0n1 vendor: Western Digital model: WD BLACK SN850X 2000GB
    size: 1.82 TiB
  ID-2: /dev/sda vendor: Advantech model: SQF-SM4V2-256G-SBE
    size: 238.47 GiB
  ID-3: /dev/sdb vendor: Crucial model: CT525MX300SSD4 size: 489.05 GiB
  Message: No optical or floppy data found.
 
Last edited:
This is my ageing HP Prodesk SFF the 2 usb connections are pen-drive for my family photos and a 512gb SSD on a SATA to usb3 connector for backup
oh the NVME is on aPCe I3 adaptor card

brian@the-answer-42:~$ inxi -d
Drives:
Local Storage: total: 1.18 TiB used: 196.41 GiB (16.2%)
ID-1: /dev/nvme0n1 vendor: Netac model: NVMe SSD 256GB size: 238.47 GiB
ID-2: /dev/sda vendor: Seagate model: ST500DM002-1BD142 size: 465.76 GiB
ID-3: /dev/sdb type: USB vendor: A-Data model: USB Flash Drive
size: 29.02 GiB
ID-4: /dev/sdc type: USB model: Mass Storage Device size: 476.94 GiB
Optical-1: /dev/sr0 vendor: hp HLDS model: DVDRW GUD1N dev-links: cdrom
Features: speed: 24 multisession: yes audio: yes dvd: yes
rw: cd-r,cd-rw,dvd-r,dvd-ram
 
Be very careful when you make this statement, M2 slots come in 6 types the most common to take the 22x? SSD/NVMe card are

1] M2 B used for SATA and wireless cards [your media start probably has one with the WI FI card in
2] M2 M mainly used for NVME
3] M2 BM can be used for both above
4] M2 E specifically for WI-FI and other small card peripherals or adaptor cables

the other 2 types are the old standards, and not been used for quite a while.
How do you tell which of these types one has?
Is it possible with software or do you need to look into manuals?
Is it possible to distinguish by looking at slots physically?
 
How do you tell which of these types one has?

The only ways I know is by looking, or looking at your motherboard manual.


M.2 B Key: Has a notch on the right side.
M.2 M Key: Has a notch on the left side.
M.2 B+M Key: Has notches on both sides.
M.2 E Key: Typically used for Wi-Fi and Bluetooth cards, with a notch on the right side but in a different position compared to B Key.

I know this isn't a very good answer, but it's all I got right now.
You can google m.2 slot pictures, and you can see the differences.
 
I already know the difference, I have been stripping, repairing, upgrading mainly desktops but also laptops since the days of the IBM compatible which had no on board storage, programs were loaded from a 5-inch floppy which was then removed and work saved to a different 5-inch floppy [early 1980's
 
Is it possible to distinguish by looking at slots physically
its ok if you can look into them, [i posted pictures somewhere on this site before] but they are usually very difficult to see into

th-74746303.jpeg
 
as mentioned by dos2Linux, there is also M2 E socket used for network cards [I don't usually bother mentioning this one as most laptops already have a card fitted and most people do not Chang

EDIT TO CLARIFY, the pins on the cards below are what we are looking at, these are both adaptor cards
the black one id M2E to M2 M and the green one is NGFF to SD card [for use as additional storage, not a card reader]

M2 E
th-4236152007.jpeg


And a new one I have not seen [only in manuals] the M2 NGFF
th-3486021344.jpeg
 
Last edited:

Members online


Latest posts

Top