Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hidden sector detection for logical 4096 sector size #543

Conversation

PartialVolume
Copy link
Collaborator

This fixes an issue where nwipe detects a discrepancy between the number of sectors reported by hdparm and nwipe's own HPA/DCO functions that were reporting the same values, using number of sectors based on 512 byte sectors but disagreed with the number of sectors
generated from libata which was reporting the number of sectors based on 4096 byte sectors.

This has been fixed by always calculating the number of sectors returned by libata using 512 bytes per sector so a direct comparison can be made to data from hdparm & nwipe's HPA/DCO functions.

This fixes an issue where nwipe detects a discrepancy
between the number of sectors reported by hdparm and
nwipe's own HPA/DCO functions that were reporting the
same values, using number of sectors based on 512 byte
sectors but disagreed with the number of sectors
generated from libata which was reporting the number of
sectors based on 4096 byte sectors.

This has been fixed by always calculating the number
of sectors returned by libata using 512 bytes per sector
so a direct comparison can be made to data from hdparm
& nwipe's HPA/DCO functions.
@PartialVolume
Copy link
Collaborator Author

PartialVolume commented Feb 3, 2024

HELP NEEDED to test hidden sector detection on 4096/4096 sector drives @Firminator @ggruber @mdcato or anybody else that may have such a drive.

This patch needs testing on 4096 logical sector drives. All my drives are 512/512 or 512/4096 logical/physical so no good for this test. I've tried setting the sector size but none of my drives seem to support that feature of hdparm. The logical/physical sectors as reported by fdisk -l

Disk /dev/nvme0n1: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: WD Blue SN570 1TB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

To test:

Locate a disk that reports a logical sector size as 4096/4096, possibly enterprise ? Unfortunately my 12TB EXOS drives are 512/4096 so no good.

Create a hidden sector in the disk with hdparm, i.e

Example

# Determine sectors and whether there is already hidden sectors
hdparm -N /dev/sdc

# where xxxxxxxxxxx is the number of sectors reported above -1
hdparm -N xxxxxxxxxxxx /dev/sdc

# IMPORTANT, send system to sleep or power cycle drive

Confirm nwipe v0.35.6 reports a hidden sector and in the nwipe logs it's the expected size

Reset the HPA so there is no hidden sector

# xxxxxxxxxx is the original (real) number of sectors
hdparm -N xxxxxxxxxxxx /dev/sdc

# IMPORTANT, send system to sleep or power cycle drive

Check nwipe v0.35.6 reports no hidden sector

Thanks !

@PartialVolume PartialVolume merged commit 1610542 into martijnvanbrummelen:master Feb 3, 2024
2 checks passed
@PartialVolume PartialVolume deleted the Fix_incorrect_HS_status_for_4096_sectors_as_reported_by_libata branch February 3, 2024 22:43
@PartialVolume
Copy link
Collaborator Author

Also see #542 that describes the false positive on a 4096/4096 encrypted drive.

@PartialVolume PartialVolume changed the title Fix hidden sector detection for logical 4096 size Fix hidden sector detection for logical 4096 sector size Feb 3, 2024
@PartialVolume
Copy link
Collaborator Author

Once I get confirmation this patch #543 works correctly for detecting hidden sectors on 4096/4096 logical/physical disk drives I'll release nwipe v0.36

@ggruber
Copy link
Contributor

ggruber commented Feb 6, 2024

unfortunately I'm struggling with a new nwipe test box with 3,5" drive bays. Hope the get around this in the next two days. But afaik I have no 4kn drive on my shelfs, only 512n and 512e. Even a ST16000NM001G I've my hands on as borrowed offers 512e mode.

@PartialVolume
Copy link
Collaborator Author

@ggruber thanks for checking, 4096/4096 drives seem to be a very rare drive, I read somewhere that the PS3 drive was formatted this way. Unfortunately I don't have any of those either.

@ggruber
Copy link
Contributor

ggruber commented Feb 8, 2024

my 3,5" Testbox is running now, but no 4kn disk, sry

@PartialVolume
Copy link
Collaborator Author

No problem, these Western Digital Red Pro - 6TB 7200RPM 4Kn SATA III 6Gb/s 128MB Cache 3.5" NAS Network Hard Drive - WD6002FFWX are 4Kn, is that something you might come across?

@Firminator
Copy link
Contributor

Firminator commented Feb 10, 2024

Western Digital UltraStar has a bunch of 4Kn drives.

DC HC530 (14TB)
DC HC520 (12TB)
DC HC510 (10TB)
DC HC320 (8TB)
DC HC310 (4 and 6 TB)

Model number is important. Only the ones ending with 42XX (SAS) or N6XX (SATA) are 4Kn.
Example: HUH721212ALN600 (looks like a HGST model number in my mind, did WD buy Hitachi/HGST?)

source: research on a new power saving feature (PWDIS - Power Disable) that effectively prevents newer gen enterprise drives to not power when using different SAS or SATA power connectors than what came with the server. We came across this the other day trying to wipe a retired SAN. See https://documents.westerndigital.com/content/dam/doc-library/en_us/assets/public/western-digital/collateral/tech-brief/tech-brief-western-digital-power-disable-pin.pdf

Other vendors are aslo affected: https://global.icydock.com/product/faq/Power_Disable_Feature_25_35_SATA_SAS_HDD_SSD_list.pdf

Video Fix: https://invidious.fdn.fr/watch?v=fnISM_LMuss

@PartialVolume
Copy link
Collaborator Author

@Firminator So like this one

They are not cheap! I did think about buying one but that's too expensive for me for just a occasional test drive.

Thanks for the info re PWDIS, interesting.

@mdcato
Copy link

mdcato commented Feb 10, 2024 via email

@PartialVolume
Copy link
Collaborator Author

No problem, I'm sure somebody will turn up with one eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants