cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cloud List <cloud-l...@sg.or.id>
Subject Automatically initialize data-disk on Windows Server 2016 OS template
Date Mon, 14 Aug 2017 05:32:12 GMT
Dear all,

I am using CloudStack 4.8.1 and KVM hypervisor. When creating my Windows
Server 2016 OS template, I tried to automate the initialization and
formatting of the data-disk so that it will automatically be put online,
initialized with MBR partition, formatted and assigned the E: drive letter,
without the user having to manually initialize the disk using Computer
Management > Disk Management.

I tried to do so by preparing 2 scripts:

1. A PowerShell script to automatically initialize and format all disks
with RAW partition, which I am taking from here:

https://blogs.technet.microsoft.com/heyscriptingguy/2013/05/29/use-powershell-to-initialize-raw-disks-and-to-partition-and-format-volumes/

I saved it on C:\script\InitializePartitionFormatNewDisks.ps1.

2. A command script to automatically run the above PowerShell script when
the Administrator user logs in. I follow the instructions on below URL:

https://stackoverflow.com/questions/20575257/how-to-run-powershell-script-when-computer-starts

to create a command script to set PowerShell execution policy to
"unrestricted" and then run the script.

===
PowerShell -Command "Set-ExecutionPolicy Unrestricted" >>
"%TEMP%\StartupLog.txt" 2>&1 PowerShell
C:\script\InitializePartitionFormatNewDisks.ps1 >> "%TEMP%\StartupLog.txt"
2>&1
===

I saved the command script onto:
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start
Menu\Programs\Startup\startup.cmd

The issue I face is that the command script I put onto
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start
Menu\Programs\Startup\startup.cmd is deleted during the "sysprep" process,
as part of the Windows template creation on CloudStack as per:

http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/4.8/templates/_create_windows.html

Is there a way I can put the startup.cmd file somewhere else so that it
will not be deleted during the sysprep process but will still be executed
when the VM boots up or when the Administrator user logs in? Or is there
any better approach on how to automate the data-disk initialization?

Any advice is highly appreciated.

Looking forward to your reply, thank you.

Cheers.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message