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

Disk (MSFT_Disk): Opens Format Window #171

Open
paraknell opened this issue Sep 14, 2018 · 5 comments
Open

Disk (MSFT_Disk): Opens Format Window #171

paraknell opened this issue Sep 14, 2018 · 5 comments
Labels
bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community.

Comments

@paraknell
Copy link

Disk (MSFT_Disk): Opens Format Window - and not in the CLI

Details

When Running the above script the verbose output returns no error messages and finishes cleanly however the "Formatting Disk (E:)" window is opened upon "completion" of the other operations. This forces you to still select formatting options through the GUI instead of remain on the CLI

If you run the below cmdlets it all runs within the CLI.

Get-Partition -DriveLetter 'C' | Resize-Partition -Size 32GB
New-Partition -DiskNumber 1 -UseMaximumSize -DriveLetter 'E'
Format-Volume -DriveLetter 'E' -FileSystem NTFS -NewFileSystemLabel 'Data' -Full -Force

Verbose Output

Clean output no errors.

VERBOSE: [WIN-768UBAPULEL]: LCM:  [ End    Set      ]  [[Disk]EVolume]  in 3.8290 seconds.
VERBOSE: [WIN-768UBAPULEL]: LCM:  [ End    Resource ]  [[Disk]EVolume]
VERBOSE: [WIN-768UBAPULEL]: LCM:  [ End    Set      ]
VERBOSE: [WIN-768UBAPULEL]: LCM:  [ End    Set      ]    in  3.9380 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 3.985 seconds

Suggested solution to the issue

Adding something like this to the "Default NTFS option"

$volParams = @{
            FileSystem = $FSFormat
            Confirm    = $false
            Force = $true
            Full = $true
}

or this...

if ($FSFull)
{
    # Set the File System label on the new volume
    $volParams["Full"] = $Full
} # if
if ($FSForce)
{
    # Set the File System label on the new volume
    $volParams["FSForce"] = $FSForce
} # if

The DSC configuration that is used to reproduce the issue (as detailed as possible)

configuration buildFileServer
{
    Import-DSCResource -ModuleName StorageDsc

    Node localhost
    {
        Disk EVolume
        {
             DiskId = 0
             DriveLetter = 'E'
             FSLabel = 'Data'
        }

    }
}
buildFileServer

Set-DSCLocalConfigurationManager -Path .\buildFileServer –Verbose
Start-DscConfiguration -Wait -Force -Path .\buildFileServer -Verbose

If I look at the source code it shows:

if ($volume.FileSystem -eq '')
    {
        # The volume is not formatted
        $volParams = @{
            FileSystem = $FSFormat
            Confirm    = $false
        }

        if ($FSLabel)
        {
            # Set the File System label on the new volume
            $volParams["NewFileSystemLabel"] = $FSLabel
        } # if

        if ($AllocationUnitSize)
        {
            # Set the Allocation Unit Size on the new volume
            $volParams["AllocationUnitSize"] = $AllocationUnitSize
        } # if

        Write-Verbose -Message ( @(
                "$($MyInvocation.MyCommand): "
                $($localizedData.FormattingVolumeMessage -f $volParams.FileSystem)
            ) -join '' )

        # Format the volume
        $volume = $partition | Format-Volume @VolParams
}

So it should return soimething like this if we "break out" the params from @volparams
$volume = $partition | Format-Volume -NewFileSystemLabel 'Data' -FileSystem NTFS

But it does not have the -Force or -Full params, which I believe are the options that enforce the process to remain within the CLI

The operating system the target node is running

OsName : Microsoft Windows Server 2016 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
WindowsBuildLabEx : 14393.0.amd64fre.rs1_release.160715-1616
OsLanguage : en-US
OsMuiLanguages : {en-US}

Version and build of PowerShell the target node is running

PSVersion: 5.1.14393.0
PSEdition: Desktop
PSCompatibleVersions: {1.0, 2.0, 3.0, 4.0...}
BuildVersion: 10.0.14393.0
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1

Version of the DSC module that was used ('dev' if using current dev branch)

Master

@paraknell
Copy link
Author

paraknell commented Sep 14, 2018

Looks like this was a similar issue to: #148
And I also tested with:

Get-Partition -DriveLetter 'C' | Resize-Partition -Size 32GB
New-Partition -DiskNumber 1 -UseMaximumSize -DriveLetter 'E'
Format-Volume -DriveLetter 'E' -FileSystem NTFS -NewFileSystemLabel 'Data' -Full

This will still bring up a prompt but allow the actual progress to be "tracked" within the CLI

@PlagueHO PlagueHO added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. labels Sep 14, 2018
@PlagueHO
Copy link
Member

I have noticed this during integration tests and should be resolved if possible - although it doesn't seem to cause a failure. It should be easy enough to fix using your suggested code. I've got one PR going through at the moment so I'll include your code after that (unless you want to submit a PR?) .

@paraknell
Copy link
Author

paraknell commented Sep 16, 2018

(For the PR) - Whatever works easiest for you :)

I ran some other tests and noticed that if you set it with the -Force parameter:

Format-Volume -DriveLetter 'E' -FileSystem NTFS -NewFileSystemLabel 'Data' -Full -Force

it will still show you a pop up stating the disk needs to be formatted. I even got it to state there was an error trying to format the drive and I didn't have the privileges to run that command, even though you can see it still running in the background with the write-progress showing completed successfully and also running it under an Admin account so it shouldn't be throwing a permissions issue.

The drive seems fine afterwards as well. Not sure if its a format-volume quirk or something else. I can post more information on monday, if you need it.

@johlju
Copy link
Member

johlju commented Sep 17, 2018

Using Format-Volume with Full will actually write to every byte on the disk, and is not recommended when using thin provisioning. So using Full says that it should not use quick-format.

The GUI that pops up, isn't that just the GUI is to quick to find the disk will it still isn't reported as formatted? Isn't it a GUI "bug" and not a problem with running the cmdlets? 🤔

@paraknell
Copy link
Author

paraknell commented Sep 17, 2018

I am currently using "Thick" provisioning for my VM's so I think -Full is the better option in the long run, I could definitely be wrong though... :)

But I'm betting to help those who do not use "Thick" provisioning there should be the option to turn it "on/off"

Disk EVolume
{
     Full = $true
}

You can add in the -Confirm parameter and it should suppress the gui window when you set it to false -Confirm:$false. Still testing as it seems it may not work in conjunction with the -Force parameter. But I'll update on that once I get more information.

UPDATES:
If you run the cmdlets in quick succession the File I/O system doesn't have enough time to recognize the new partition has been created.

Get-Partition -DriveLetter 'C' | Resize-Partition -Size 32GB
New-Partition -DiskNumber 0 -UseMaximumSize -DriveLetter 'E'
Get-Partition -DriveLetter 'E' | Format-Volume -FileSystem NTFS -NewFileSystemLabel 'Data' -Force -Confirm:$false

If you add in a sleep 1 call then it will have enough time to run the New-Partition cmdlet successfully

Get-Partition -DriveLetter 'C' | Resize-Partition -Size 32GB
New-Partition -DiskNumber 0 -UseMaximumSize -DriveLetter 'E'
Sleep 1
Get-Partition -DriveLetter 'E' | Format-Volume -FileSystem NTFS -NewFileSystemLabel 'Data' -Force -Confirm:$false

This also seems to handle it correctly as well:

Get-Partition -DriveLetter 'C' | Resize-Partition -Size 32GB
New-Partition -DiskNumber 0 -UseMaximumSize -DriveLetter 'E'
$Edrive = Get-Partition -DriveLetter 'E'
Format-Volume -DriveLetter $Edrive.DriveLetter -FileSystem NTFS -NewFileSystemLabel 'Data' -Force -Confirm:$false

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

No branches or pull requests

3 participants