r/PowerShell • • 28d ago

Question PRoblems formatting SAS Drive on Win10x64

Context: SAS drive was given to me years ago but haven't gone to using it until now.

I'm trying to format a ST4000NM0023 on a Blueendless U35KS SAS/SATA Mobile Hard Disk Enclosure. I use a Dell G3 laptop to do all this.

Seagate tools are no help FYI. I don't want this drive go to waste!

I try to format with sg_format and this is what i get:

PS C:\windows>

>> sg_format --format --size=512 --fmtpinfo=0 --six -v pd2

Generic External 0157 peripheral_type: disk [0x0]

PROTECT=0

Unit serial number: 00000000000000000001

LU name: 570b3d5000000000

mode sense(6) cdb: [1a 00 01 00 fc 00]

mode sense(6):

Fixed format, current; Sense key: Vendor specific(9)

vendor specific ASC=80, ASCQ=92 (hex)

MODE SENSE (6) command: Some other sense error, try '-v' option for more information

4 Upvotes

22 comments sorted by

1

u/x86_64_ 28d ago

You have to do a low-level format of that drive first - it very likely came from an array and Windows can't make sense of the format.

Paste this whole thing into your search engine of choice, there's only a few steps to it but the format will take a few hours to complete.

2

u/Aggravating_Coast285 28d ago

Thanks. Danget. Now to find a system I know of that uses Linux.... :/

3

u/NorCalFrances 28d ago edited 28d ago

Boot to a thumb / flash drive w a live ISO.

But also, for windows try https://hddguru.com/software/HDD-LLF-Low-Level-Format-Tool/

1

u/Aggravating_Coast285 27d ago

Just tried, no dice. :/

1

u/NorCalFrances 27d ago

Which one?

2

u/Aggravating_Coast285 27d ago

Now using SystemRepair Linux. No dice for the HDD LLF tool.

1

u/NorCalFrances 27d ago

Linux to the rescue! I've used the LFF tool before, along with others over the years on SAS drives on Win Server. May I ask what went wrong? At the very least it should have been able to give you diagnostic info on the drive.

1

u/Aggravating_Coast285 27d ago

sg_format -v /dev/sg3

Generic External 0157 peripheral_type: disk [0x0]

PROTECT=0

Unit serial number: 00000000000000000001

LU name: 570b3d5000000000

mode sense(10) cdb: [5a 00 01 00 00 00 00 00 fc 00]

mode sense(10):

Fixed format, current; Sense key: Vendor specific(9)

vendor specific ASC=80, ASCQ=92 (hex)

MODE SENSE (10) command: Some other sense error, try '-v' option for more information

then I did a sg_inq

sg_inq /dev/sg3

standard INQUIRY: [PQ indicates LU temporarily unavailable]

PQual=1 PDT=0 RMB=1 LU_CONG=0 hot_pluggable=0 version=0x06 [SPC-4]

[AERC=0] [TrmTsk=0] NormACA=0 HiSUP=1 Resp_data_format=2

SCCS=0 ACC=0 TPGS=0 3PC=0 Protect=0 [BQue=0]

EncServ=0 MultiP=0 [MChngr=0] [ACKREQQ=0] Addr16=0

[RelAdr=0] WBus16=0 Sync=0 [Linked=0] [TranDis=0] CmdQue=0

[SPI: Clocking=0x0 QAS=0 IUS=0]

length=76 (0x4c) Peripheral device type: disk

Vendor identification: Generic

Product identification: External

Product revision level: 0157

1

u/Aggravating_Coast285 27d ago

i'm a bit stumped by now... am using an old HP laptop that doesn't even feature a M.2 slot. :)

Processor : AMD A10-8700P 1 physical processor; 4 cores; 4 threads

Memory : 7039MB (1760MB used)

Machine Type : Notebook

Operating System : SystemRescue 13.02 - Arch Linux

User Name : root (Unknown)

1

u/x86_64_ 28d ago

You can use a live ISO of your favorite distro, but like /u/NorCalFrances says there's apparently also a Windows tool

2

u/Aggravating_Coast285 27d ago

Apparently one of Seagate's tool is a live Linux distro. might give it a try later.

1

u/dodexahedron 25d ago edited 25d ago

LLF is almost certainly unnecessary.

Launch an admin terminal/powershell and you can almost definitely fix it with either of the following two procedures (powershell is simpler):

Get-Disk

#From the output of that, find the disk that is the one you're trying to use, and use its number for the next command. Take out the #, which I only put in there for safety in case you copy/paste this without following directions:

#$DiskNumber = [The number of the disk from above]

if(-not $DiskNumber) { throw "No disk number set." }
$Disk = Get-Disk $DiskNumber
if($Disk.OperationalStatus -ne Online) {
 $Disk | Set-Disk -IsOffline $false $Disk = $Disk | Get-Disk
}
$Disk = $Disk | Clear-Disk -RemoveOEM -RemoveData -Confirm -PassThru
$Disk = $Disk | Initialize-Disk -PartitionStyle GPT -Confirm -PassThru
$Disk | Update-Disk

After this, the disk should now be ready for creating partitions and formatting those partitions, which you can do in powershell, the disk management mmc, or whatever you like.

The other method for doing the above using diskpart is this:

run diskpart.

Then, in diskpart, run the following commands, substituting anything in suare brackets for the correct disk number:

rescan
list disk
select disk [disk number of the disk you are trying to use]

REM if that disk is marked offline, run the next command. If not, skip it.

online disk

REM for the next command, you can instead run "clean all" to zero the entire disk, but that will take forever and is usually unnecessary.
clean
convert gpt
rescan
list disk

REM just make sure the disk shows online and gpt

exit

If you want to use linux to clean it, it's pretty simple:

Find the disk with: lsblk -f

Then do this, if it is an SSD, on the block device for that disk, where X is the letter and NO NUMBER for the block device. Also note that THIS WILL DESTROY ALL DATA ON THE DISK YOU RUN IT ON, UNRECOVERABLY!
It is damn near instant, too:

blkdiscard /dev/sdX -v

Now the disk is completely clean and you can initialize it however you like, either in linux or in windows.

If it isn't an SSD, then use this instead:

dd if=/dev/zero of=/dev/sdX bs=131072 count=1024

Here's how to make a new GPT on the disk:

gdisk /dev/sdX
o
w

Then just boot into windows and you'll have an empty disk with a clean GPT and can make whatever partitions you want on it.

1

u/Aggravating_Coast285 22d ago

Disk 2 is the drive in question.

get-disk

Number Friendly Name Serial Number HealthStatus OperationalStatus Total Size Partition

Style

------ ------------- ------------- ------------ ----------------- ---------- ----------

1 HGST HTS541010B7E610 WX61EB746UNE Healthy Online 931.51 GB GPT

0 SK hynix SC311 SATA 512GB EJ77N429210307B5Q Healthy Online 476.94 GB GPT

2 Generic External 00000000000000000001 Healthy No Media 0 B RAW

PS C:\Windows\system32> if(-not 2) { throw "No disk number set." }

>> >> $Disk = Get-Disk 2

>> >> i

f($Disk.OperationalStatus -ne Online) {$Disk | Set-Disk -IsOffline $false $Disk = $Disk | Get-Disk}

>> >> $Disk = $Disk | Clear-Disk -RemoveOEM -RemoveData -Confirm -PassThru

>> >> $Disk = $Disk | Initialize-Disk -PartitionStyle GPT -Confirm -PassThru

>> >> $Disk | Update-Disk

At line:3 char:34

+ >> if($Disk.OperationalStatus -ne Online) {$Disk | Set-Disk -IsOfflin ...

+ ~

You must provide a value expression following the '-ne' operator.

At line:3 char:35

+ >> if($Disk.OperationalStatus -ne Online) {$Disk | Set-Disk -IsOfflin ...

+ ~~~~~~

Unexpected token 'Online' in expression or statement.

At line:3 char:34

+ >> if($Disk.OperationalStatus -ne Online) {$Disk | Set-Disk -IsOfflin ...

+ ~

Missing closing ')' in expression.

At line:3 char:41

+ >> if($Disk.OperationalStatus -ne Online) {$Disk | Set-Disk -IsOfflin ...

+ ~

Unexpected token ')' in expression or statement.

+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException

+ FullyQualifiedErrorId : ExpectedValueExpression

1

u/dodexahedron 21d ago

Something got lost in translation there.

That if statement getting split up broke everything that follows.

Before any of the if statements, assign $DiskNumber = 2

And then the rest of the script from there, without modification. No constants.

1

u/Creative-Type9411 27d ago

use diskpart first run clean

after you select disk do a detail disk to make sure you picked the right one then do the clean

1

u/Aggravating_Coast285 27d ago

Diskpart just says "No Media"

1

u/BlackV 27d ago

Do have to tell the caddy that's it's sas?

1

u/Aggravating_Coast285 27d ago

Nope, no such switch or setting, pretty much plug and play... or in this case, plug and pray. :/

1

u/turnAsh 27d ago

usb enclosures usually strip out or block low-level scsi commands like that, especially with a 6-byte mode sense. you can try dropping the --six flag to see if 10-byte commands pass through the bridge chip, otherwise it really needs a proper HBA card.

1

u/Aggravating_Coast285 27d ago

[]{$?=1} Wed Nov 04 19:10:24 >

sg_format --format --size=512 --fmtpinfo=0 -v /dev/sg2

Generic External

0157 peripheral_type: disk [0x0]

PROTECT=0

Unit serial number: 00000000000000000001

LU name: 570b3d5000000000

mode sense (10) cdb: [5a 00 01 00 00 00 00 00 fc 00]

mode sense (10):

Fixed format, current; Sense key: Vendor specific (9) vendor specific ASC-80, ASCQ=92 (hex)

MODE SENSE (10) command: Some other sense error, try '-v' option for more information

[]{$?=98} Wed Nov 04 19:10:40 >

1

u/Aggravating_Coast285 27d ago

A

[[$7=0] Wed Nov 04 22:00:42 sg_vpd -a -1 -v /dev/sg2

inquiry cdb: [12 01 00 00 fc 00]

[0x0] Supported VPD pages VPD page:

inquiry cdb: [12 01 00 00 fc 00]

[PQual=1 Peripheral device type: disk]

0x00 Supported VPD pages [sv]

0x80 Unit serial number [sn]

0x83 Device Device identification [di]

Oxbo Block limits (SBC) [bl]

Oxb1 Block device characteristics (SBC) [bdc]

inquiry cdb: [12 01 00 00 fc 00]

[0x80] Unit serial number VPD page:

inquiry cdb: [12 01 80 00 fc 00] [PQual=1 Peripheral device type: disk]

Unit serial number: 00000000000000000001

inquiry cdb: [12 01 00 00 fc 00]

[ 0x83] Device Identification VPD page: inquiry cab: [12 01 83 00 fc 00

[PQual=1 Peripheral device type: disk]

Addressed logical unit:

designator type: T10 vendor identification, code set: ASCII 00000000000000000001

vendor id: Generic

vendor specific: External

designator type: NAA, code set: Binary

NAA 5, IEEE Company_id: 0x70b3d5

Vendor Specific Identifier: 0x0

[0x570b3d5000000000]

inquiry cdb: [12 01 00 00 fc 00]

Inquiry cab: [12 01 b0 00 fc 00]

[0xb0] Block limits VPD page (SBC):

[PQual-1 Peripheral device type: disk]

Write same non-zero (WSNZ): 0

Maximum compare and write length: 0 blocks [Command not implemented]

Optimal transfer length granularity: 1 blocks

Maximum transfer length: 65535 blocks

Optimal transfer length: 65535 blocks

Maximum prefetch transfer length: 65535 blocks

Maximum unmap LBA count: 0 [Unmap command not implemented]

Maximum unmap block descriptor count: 0 [Unmap command not implemented]

Optimal unmap granularity: 0 blocks [not reported]

Unmap granularity alignment valid: false

Unmap granularity alignment: 0 [invalid]

Maximum write same length: 0 blocks [not reported]

Maximum atomic transfer length: 0 blocks [not reported]

Atomic alignment: 0 [unaligned atomic writes permitted]

Atomic transfer length granularity: 0 [no granularity requirement

Maximum atomic transfer length with atomic boundary: 0 blocks [not reported]

Maximum atomic boundary size: 0 blocks [can only write atomic 1 block]

inquiry cdb: [12 01 00 00 fc 00]

12 00 inquiry cdb: [12 01 b1 00 fc 00]

[0xb1] Block device characteristics VPD page (SBC):

[PQual=1 Peripheral device type: disk]

Medium rotation rate is not reported

Product type: Not specified

WABEREQ=0

WACEREQ=0

Nominal form factor not reported