A server stack is the collection of software that forms the operational infrastructure on a given machine. In a computing context, a stack is an ordered pile. A server stack is one type of solution stack — an ordered selection of software that makes it possible to complete a particular task. Like in this post about Windows EBS Volume from snapshot at instance launch is OFFLINE was one problem in server stack that need for a solution. Below are some tips in manage your windows server when you find problem about windows, amazon-ec2, amazon-web-services, amazon-ebs, .
Using Powershell launching a Server 2012 R2 machine.
I can launch an instance from the stock Server 2012R2 AMI with a defined new EBS volume for d: drive, and upon boot, is online, and works fine.
If I take the same code and just add creation of the volume from snapshot, it boots, the volume is there, but it is shown OFFLINE. Once in disk manager, mark it online and all is again well and I have a D: drive.
I tried several different ways to create the snapshot (running, offline, detached, instance stopped). Nothing seems to make a difference.
EDIT: Also tried launching instance without volume, provisioning volume, and attaching it to instance. Same results
Code I’m using:
#configure D: drive $Volume2 = New-Object Amazon.EC2.Model.EbsBlockDevice $Volume2.DeleteOnTermination = $True $Volume2.VolumeSize = 10 $Volume2.VolumeType = "gp2" $Volume2.SnapshotId = "snap-xxxxxx" #and map it $Mapping2 = New-Object Amazon.EC2.Model.BlockDeviceMapping $Mapping2.DeviceName = 'xvdf' $Mapping2.Ebs = $Volume2 #create the instance $NewInstance = New-EC2Instance -ImageId $ImageId -MinCount 1 -MaxCount 1 -InstanceType "t2.medium" -SecurityGroupIds xxxx -SubnetId xxxxx -UserData $UserdataBase64Encoded -KeyName XXX -AvailabilityZone us-east-1c -BlockDeviceMapping $Mapping2
Stock servers for Windows Server 2012 have a default policy of OFF-LINE for new storage it finds to mount. You can change that policy, but that wouldn’t be “stock” anymore. A “stock Server” has no D: drive, so you’re going to have to do something.
At some point, you’ll have to execute code from inside your “stock Server”+D:drive.
This example takes a disk that is offline and makes it online.
- Windows PowerShell PS C:> Set-Disk -Number 5 -IsOffline $False
The question becomes, how do you execute this code from a “stock Server”? Amazon Windows AMI “stock Servers” contain an additional service installed by Amazon Web Services, the EC2Config service. EC2Config’s “User data” enables you to inject scripts into the instance metadata during the first launch. By default, all Amazon AMIs have user data execution enabled for the initial boot.
For details, see Configuring a Windows Instance Using the EC2Config Service
Using Packer to make AMIs, I had the same problem – when I launched an AMI made by Packer, any drives added were offline.
I fixed it by adding to an existing PowerShell script provider in Packer the following line:
Set-StorageSetting -NewDiskPolicy OnlineAll
As this is a security sensitive environment, it’s possible that a security scan will find that and flag it as a STIG violation or something like that, but it does solve the problem.