Initializing a Windows Data Disk Using a Script
Scenarios
When a data disk is attached to an HECS, you must log in to the HECS and initialize the disk before you can use the disk.
The method of initializing data disks for an HECS is the same as that of initializing disks for an ECS. This section describes how to use scripts to initialize data disks for a Windows HECS. For more information, see Introduction to Data Disk Initialization Scenarios and Partition Styles.
This section uses Windows Server 2012 R2 Standard 64bit as an example to describe how to automatically initialize data disks attached to a Windows HECS.
The way to initialize a disk varies with the HECS OS. The operations described in this section are for reference only. For detailed operations and differences, see the product documentations of the HECS OSs.
When using a disk for the first time, if you have not initialized it, including creating partitions and file systems, the additional space added to this disk in an expansion later may not be normally used.
Prerequisites
- A data disk has been attached to the HECS and has not been initialized.
- You have logged in to the HECS.
Constraints
- This script uses the NTFS file system and MBR partition style by default.
- This script does not support the initialization of disks that form Windows logical volume groups.
- This script supports the initialization of up to 23 Windows data disks.
Manually Executing the Script to Initialize Windows Data Disks
- Log in to the HECS, download the script for automatically initializing disks, and save the script to C:\Windows\System32.
- Run Windows PowerShell as administrator.
- In the displayed dialog box, run the following command to set the script execution policy:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Force
- Run the following command in the dialog box to execute the initialization script:
C:\Windows\System32\WinVMDataDiskAutoInitialize.ps1
Information similar to the following is displayed.
Figure 1 Executing the automation script
If the command output shows that PowerShell cannot load the file, this is because the Windows system policy does not allow the PowerShell script downloaded from the network to be executed if the script is not signed.
To resolve this issue, run the set-ExecutionPolicy RemoteSigned command and restart PowerShell.
- (Optional) On the Disk Management page, view the initialization result. Figure 2 Disk Management
Configuring Automatic Initialization of Windows Data Disks
- On the HECS desktop, click Start and choose Server Manager.
The Server Manager page is displayed.
- In the navigation pane on the left, choose Tools > Task Scheduler, then right-click Task Scheduler Library and choose Create Task from the shortcut menu.
The Create Task page is displayed.
Figure 3 Tools
Figure 4 Task Scheduler
- On the displayed page, click the General tab, enter WinVMDataDiskInitialize in the Name text box, and click Change User or Group.
The Select User or Group page is displayed.
Figure 5 Create Task
- Click Advanced in the lower left corner of the page.
- Click Find Now on the right side of the page. In the search result list, select SYSTEM and click OK.
The Select User or Group page is displayed.
Figure 6 Selecting SYSTEM
- Click OK. Figure 7 Clicking OK
- Click the Triggers tab and click New in the lower left corner of the page.
- On the New Trigger page, choose At log on for Begin the task, retain the default settings for other parameters, and click OK. Figure 8 New Trigger
- Click the Actions tab and click New in the lower left corner of the page.
- On the New Action page, set the following parameters:
- Action: Select Start a program.
- Program/script: Select powershell.exe.
- Add arguments (optional): Enter -ExecutionPolicy Bypass C:\Windows\System32\WinVMDataDiskAutoInitialize.ps1.
Click OK.
Figure 9 New Action
- On the Create Task page, click OK.
After the configuration is complete, new EVS disks attached to this HECS will be automatically initialized when the HECS is logged in to again.
To enable automatic initialization of Windows data disks on multiple HECSs, configure automatic initialization on one HECS, create a private image for this HECS, and use the image to batch create HECSs.
Last Article: Expanding Disk Capacity
Next Article: Initializing a Linux Data Disk Using a Script
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.