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

xDisk and xDiskAccessPath: Add -UseLargeFRS option for Format-Volume #122

Open
codykonior opened this issue Oct 18, 2017 · 8 comments
Open
Assignees
Labels
enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community.

Comments

@codykonior
Copy link

codykonior commented Oct 18, 2017

Details of the scenario you tried and the problem that is occurring:
When formatting drives (and mount points) for SQL Server a common best practice is to use a Format-Volume parameter -UseLargeFRS. Can this be added as an option on the resource?

The DSC configuration that is using the resource (as detailed as possible):
xDisk and xDiskAccessPath.

Version of the Operating System and PowerShell the DSC Target Node is running:
N/A

Version of the DSC module you're using, or 'dev' if you're using current dev branch:
N/A

Other
I'm not sure if this is important for you but this is only for NTFS formats on Windows Server 2012 and above. You can't check the current status of a disk over WMI/CIM but you can check it locally with fsutil.

    $fsutil = &fsutil fsinfo ntfsinfo $path
    $fsutil = $($fsutil -join ",$([Environment]::NewLine)" -replace '(.*?)\s*:\s*([^,]*)(,*)', '"$1" : "$2"$3')
    $fsutil = ConvertFrom-Json "{ $fsutil }"
    if ($fsutil.'Bytes Per FileRecord Segment' -eq 4096) {
        # Was formatted with -UseLargeFRS
    }
@PlagueHO PlagueHO self-assigned this Oct 20, 2017
@PlagueHO PlagueHO added enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community. labels Oct 20, 2017
@PlagueHO
Copy link
Member

Hi @codykonior - this sounds like a pretty great feature and shouldn't be too difficult to add.

The biggest risk with using FSUtil to pull the "Bytes Per FileRecord Segment" label is localized.

@johlju - I don't suppose you have a Swedish version of Windows Server 2012 R2 running that you can execute this command on to see if the labels are localized?

I'm also not sure if this would work on Nano Server, so I'll need to check on this.

If all the above are fine then this should be able to implemented pretty easily.

Thank you for providing the great info BTW!

@johlju
Copy link
Member

johlju commented Oct 20, 2017

I think I have one in my lab at home - I will check when I get home.

@johlju
Copy link
Member

johlju commented Oct 20, 2017

Windows Server 2012 R2 Swedish:

PS C:\Windows\system32> fsutil fsinfo ntfsinfo c:\
NTFS Volume Serial Number :        0xdcaebe5daebe2fbe
NTFS Version   :                   3.1
LFS Version    :                   2.0
Number Sectors :                   0x00000000077fefff
Total Clusters :                   0x0000000000effdff
Free Clusters  :                   0x0000000000b314de
Total Reserved :                   0x0000000000000c88
Bytes Per Sector  :                512
Bytes Per Physical Sector :        512
Bytes Per Cluster :                4096
Bytes Per FileRecord Segment    :  1024
Clusters Per FileRecord Segment :  0
Mft Valid Data Length :            0x000000000b980000
Mft Start Lcn  :                   0x00000000000c0000
Mft2 Start Lcn :                   0x0000000000000002
Mft Zone Start :                   0x00000000000cb980
Mft Zone End   :                   0x00000000000cc820
Max Device Trim Extent Count :     0
Max Device Trim Byte Count :       0x0
Max Volume Trim Extent Count :     62
Max Volume Trim Byte Count :       0x40000000
Resource Manager Identifier :     BBFFCC12-6963-11E7-B4CF-8B22BFB60D18

@johlju
Copy link
Member

johlju commented Oct 20, 2017

I thought that Swedish is not a big language, and most Swedish companies run the English version except on some Citrix deployments where Swedish might be used.
But for other languages like Spanish, I thought it might be different. And yes it is.

Windows Server 2012 R2 Spanish:

PS C:\Windows\system32> fsutil fsinfo ntfsinfo c:
Número de serie de volumen NTFS:               0xccec6b4bec6b2f40
Versión de NTFS:                               3.1
Versión de LFS:                                2.0
Número de sectores:                            0x000000000fcf77ff
Total de clústeres:                            0x0000000001f9eeff
Clústeres disponibles:                         0x0000000001d2608b
Total de clústeres reservados:                 0x0000000000002d00
Bytes por sector:                              512
Bytes por sector físico:                       4096
Bytes por clúster:                             4096
Bytes por segmento de registro de archivo:     1024
Clústeres por segmento de registro de archivo: 0
Tamaño válido de datos MFT:                    0x0000000006cc0000
LCN de inicio de MFT:                          0x00000000000c0000
LCN de inicio de MFT2:                         0x0000000000000002
Inicio de zona MFT:                            0x00000000000c6c40
Fin de zona MFT:                               0x00000000000cc820
Id. de Administrador de recursos:     4930BE97-B5B0-11E7-ACFC-CD57F5A6C572
PS C:\Windows\system32>

So this might be the same for Chinese, Arabic, etc.

@PlagueHO
Copy link
Member

PlagueHO commented Nov 4, 2017

Awesome! Thanks @johlju for looking this up. This doesn't rule out using fsutil for this, but it does mean we couldn't use the name string. We could possibly use the position, but this is going to assume that the order of the returned lines stays the same - which is an awfully risky assumption.

Are we sure none of this information is surfaced anywhere else? CIM, registry, through .NET Framework calls?

@johlju
Copy link
Member

johlju commented Nov 4, 2017

The order of these could potentially work for languages that reads from left to right. But languages that read from right to left might show this differently. Not sure. As you says, it’s very risky. But maybe you could use the localization to find the correct string to read/search for.

I googled quickly while I was testing this but couldn’t find any other method. But that was a really fast search. I was surprised there is no other way to find this. Fsutil must find this somehow, but maybe it’s not information that’s found in .Net Framework.

@PlagueHO
Copy link
Member

PlagueHO commented Nov 4, 2017

Thanks for having a bit of a look around at this @johlju - I suspect that this could be something that is read straight out of the disk/volume information on the disk. So it might be possible to read the disk volume information and decode it - but this isn't something I'd want to do.

There is one other possible solution: do not evaluate this parameter in the Test-TargetResource - only use it when applying it in Set-TargetResource. I'm presuming that this is something you're most likely to want to set when first configuring a disk in a SQL Server machine. I know that this is a far from perfect solution but should it be considered?

@johlju
Copy link
Member

johlju commented Nov 5, 2017

@PlagueHO Yes, reasonably if Test-TargetResource does not find a partition then Set-TargetResource formats the partition using this parameter (if set). Reasonably the user does not the partition to be reformatted once data is on it. Although, there is the parameter ClearDisk that could suggest a user wanting to do this, and if we don't check for this in the Test-TargetResource then that won't work. But that could be explained in the documentation, due to the lack of means to test this property, it is not supported to reformat using this parameter as of yet.

Yet another option would be to use the above method to evaluate the property in Test-TargetResource, and change the documentation to say it is only supported in English OS. But if so, I would rather prefer using localization to be able to say the string to search for in fsutil output. A tleast until a better method of evaluating this exist.
Here is a blog post about the method in the issue description (nothing new though); Are your disks formatted with UseLargeFRS?.

Also, it should only check this for NTFS disks since ReFS does not have this property.

[PS] C:\Windows\system32>fsutil fsinfo refsinfo  f:
REFS Volume Serial Number :       0xbca85bc7a85b7f38
REFS Version   :                  3.1
Number Sectors :                  0x0000000004fa0000
Total Clusters :                  0x00000000009f4000
Free Clusters  :                  0x00000000009bae96
Total Reserved :                  0x0000000000018500
Bytes Per Sector  :               512
Bytes Per Physical Sector :       512
Bytes Per Cluster :               4096
Checksum Type:                    CHECKSUM_TYPE_NONE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
Development

No branches or pull requests

3 participants