You are not logged in.

#1 2016-04-07 08:18:01

belette
Member
Registered: 2014-11-17
Posts: 121

NVMe disk and reading sector?

Hi,

I am trying to read sector with hdparm but it is like it is not supporting NVMe disk:

hdparm --read-sector 1330176 /dev/nvme0n1
reading sector 1330176: FAILED: Inappropriate ioctl for device

Do you know an alternative method to do it?
many thanks

Offline

#2 2016-04-07 13:19:06

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: NVMe disk and reading sector?

I'm not familiar with NVMe disks but it seems you are trying to tell hdparm to read from a partition, maybe what you want is to use /dev/nvme0.

If hdparm still refuses to work even with /dev/nvme0 then you could use dd.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#3 2016-04-07 15:07:53

belette
Member
Registered: 2014-11-17
Posts: 121

Re: NVMe disk and reading sector?

Thanks for your reply.
No, nvme0n1 is the disk and nvme0n1p1 or nvme0n1p2 are the partition.
I know the partition scheme is different on NVMe disk..

I haven't think about dd for reading partition sector, is there any special command for reading a specific sector(s)?
many thanks

Offline

#4 2016-04-07 15:52:15

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: NVMe disk and reading sector?

dd has 'skip' option. For example, I get the same sector from the following commands:

hdparm --read-sector 100000 /dev/sda
dd if=/dev/sda of=/tmp/out bs=512 skip=100000 count=1

(sda is SATA SSD)

But I wouldn't be too surprised if dd fails in a similar way.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#5 2016-04-07 20:58:13

belette
Member
Registered: 2014-11-17
Posts: 121

Re: NVMe disk and reading sector?

Thanks for your reply
And I guess you compare the result of hdparm to a hexdump /tmp/out ?
I have tried but I am unable to confirm what I am trying to do (confirming that fstrim is working)
Perhaps I got an issue regarding offset or byte sector in my calculation...

PS: dd is not failing on this case, only hdparm which is not recognising the NVMe disk name apparently )

Last edited by belette (2016-04-07 20:59:40)

Offline

#6 2016-04-07 21:28:22

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: NVMe disk and reading sector?

Yes, I compared hdparm output to hexdump of dd output, mostly to confirm value of skip.

My guess would be that the failure of hdparm goes deeper than failing to recognize the name:

# hdparm --read-sector 100 /dev/zero

/dev/zero:
 HDIO_GETGEO failed: Inappropriate ioctl for device
# hdparm --read-sector 100 /dev/md0

/dev/md0:
/dev/md0 is a RAID device: please specify an absolute LBA of a raw member device instead (raid1 only)
Aborting.
# hdparm --read-sector 100 /dev/vg0/test

/dev/vg0/test:
reading sector 100: FAILED: Inappropriate ioctl for device

(/dev/vg0/test is an LVM2 LV)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#7 2016-06-04 19:50:34

belette
Member
Registered: 2014-11-17
Posts: 121

Re: NVMe disk and reading sector?

coming back to this, I confirm that dd method is working.
What was make me think it was wrong (or that fstrim was not working) is that I forgot to drop caches after deleting the file (echo 1 > /proc/sys/vm/drop_caches)
many thanks!

Offline

#8 2016-06-23 13:14:58

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: NVMe disk and reading sector?

hdparm simply shouldn't be used on NVMe drives. It sends ATA commands* to the specified drive, while NVMe drives will not understand them since the interface has its own command set defined**.

* that are encapsulated in "ATA PASSTHROUGH" SCSI commands, to the SCSI-ATA Translation Layer provided libata in the kernel, which will decapsulate them and send the ATA commands to the drive
** You can use SCSI utilities (e.g. sg3_utils) on them though since the NVMe driver in the kernel has an SCSI-NVMe Translation Layer implemented

FWIW, you can pipe the output from dd to hexdump instead of using `of=` to a file:

dd if=/dev/sda skip=N count=M | hexdump

Last edited by tom.ty89 (2016-06-23 13:23:21)

Offline

Board footer

Powered by FluxBB