Thursday 15 May 2008

Server Core - From Scratch to Hyper-V Production

It is quite an adventure to find the necessary information on the various commands needed to get a Server 2008 Core install up and running and subsequently live in production.

This list is by no means comprehensive, but the listed commands are the required ones to make things happen!

Assume the following:

  • Intel Xeon X3220 Quad Core Server
  • 8 GB of ECC RAM
  • 750GB Seagate RAID 1 array
  • Dual Gigabit NICs
  • DVDROM Optical
  • Server 2008 setup names the server: WIN-35CVS22
The above hardware configuration will be the basis for all of our commands.

Once the Server 2008 Core install has been completed one will be greeted with the Logon for admin. From there:


  1. Out of the box the Admin password is blank. Set a new password for the local admin account that meets password complexity requirements.
  2. Find the new server's name:
    1. hostname [Assume Enter after each line]
  3. Rename the server to our pending production name:
    1. netdom RenameComputer WIN-35CVS22 /NewName:TN-CoreVS01
    2. shutdown -r -t 05
  4. Configure our partitions:
    1. DiskPart
    2. Select Disk 0
    3. Create Par Primary Size=13312
    4. Sel Par 2 (assuming partition 1 is the system drive)
    5. format fs=ntfs label="SwapFile"
    6. assign letter=S
    7. Create Par Primary (no size specified as the balance will be taken)
    8. Sel Par 3
    9. format fs=ntfs label="VirtualMachines" Quick (No Quick means a long wait)
    10. assign letter=G
    11. list vol (should see optical, C:, S:, and G:)
    12. exit [Enter]
  5. Move the Swap File over to the S: partition:
    1. wmic computersystem where name="TN-CoreVS01" set AutomaticManagedPagefile=False
    2. wmic pagefileset where name=”S:\\pagefile.sys” set InitialSize=8192,MaximumSize=12288
      • If the pagefileset command gives you grief, reboot, then try the command again and it should work.
    3. shutdown -r -t 05
  6. Join the SBS domain and place the server in a custom OU:
    1. netdom Join TN-CoreVS01 /Domain:MySBSDomain.Local
      /OU:OU=SBSServers,OU=Computers,OU=MyBusiness,DC=Domain,DC=Local
      /UserD:MySBSAdmin
      /PasswordD:* (asterisk will prompt for the password)
      • If the command fails, check for typos.
    2. shutdown -r -t 05
    3. Post reboot login: MyDomainAdmin@MySBSDomain + password
  7. Create and share the base virtual machine folder:
    1. G:
    2. MkDir VMs (name whatever you like)
    3. net share VirtualMachines=G:\VMs /Grant:"MySBSDomain\Domain Admins",FULL /Remark:"My Virtual Machines"
    4. Net Share VirtualMachines (lists all settings relevant to the share)
  8. Install the Hyper-V role then update it:
    1. bcdedit /set hypervisorlaunchtype auto
    2. start /w OCSetup Microsoft-Hyper-V (Case Sensitive and a restart is required)
    3. On another system: Download the Hyper-V current release to a network share (assume M: via logon script)
    4. M: (location of the Hyper-V update bits)
    5. CD Microsoft\Hyper-V (relevant folder for you)
    6. Windows6.0-KB950050-x64-Hyper-V.msu (update will run and restart)
  9. Setup Windows Networking - Static IP and network DNS Server:
    1. On the domain DHCP server setup reservations for the planned IPs needed for the 2 NICs.
    2. ipconfig to get the currently assigned IP addresses in relationship to the NIC name.
    3. netsh interface ipv4 show interfaces (note Idx number)

    4. netsh interface ipv4 set address name="3" source=static address=192.168.37.250 mask=255.255.255.0 gateway=192.168.37.1
    5. netsh interface ipv4 add dnsserver name="3" address=192.168.37.2 index=1
      • For the following, hit the F3 key (DOSKey for those who remember), then the up arrow key to scroll through previously used commands to make things easier than retyping everything. Just change the relevant IP setting.
    6. netsh interface ipv4 set address name="7" source=static address=192.168.37.249 mask=255.255.255.0 gateway=192.168.37.1
    7. netsh interface ipv4 add dnsserver name="7" address=192.168.37.2 index=1 (please ignore wrapping)
    8. IPConfig /all to verify settings.
  10. Configure the Windows Firewall (MS KB947709) to allow RDP, folder sharing, and remote admin:
    1. netsh advfirewall firewall set rule name="Remote Administration (RPC-EPMAP)" new enable=yes profile=domain
    2. netsh advfirewall firewall set rule name="Remote Administration (NP-In)" new enable=yes profile=domain
    3. netsh advfirewall firewall set rule name="Remote Administration (RPC)" new enable=yes profile=domain
    4. netsh advfirewall firewall set rule name="remote desktop (tcp-in)" new enable=Yes profile=domain
      • This is the correct syntax for this one ... not the original in the post that came from the above KB article that has been struck out. Plus, a couple of extras were needed to make things complete.
      • NOTE: Check the current assigned profile and change the above profile setting as appropriate: netsh advfirewall show currentprofile
      • NetSH Reference Post.
  11. Enable remote firewall management:
    • Netsh advfirewall firewall set rule group=“Windows Firewall Remote Management” new enable=yes
  12. Enable Terminal Services Admin:
    1. cscript c:\Windows\System32\Scregedit.wsf /ar 0
    2. Test by mstsc /v:TS-CoreVS01 (from a remote workstation)
  13. Update the Server Core installation (previous blog post).
  14. If ISOs reside on a network share, configure the Hyper-V server to access the share via Constrained Delegation (previous blog post).

Now that we have a good grasp on what commands are required to complete a Hyper-V setup on Server Core, we can place all of the above commands into a series of batch files that can be ran at each step. Some quick modifications to tailor things such as names and not leaving our domain admin password in a plain text file would be a good thing.

Batching the above command sets would reduce the amount of time required to run post OS install setup steps significantly. It would also save us from having to retype that command or hitting the F3 key to bring it back to edit it yet again! ;)

With the Hyper-V Manager we are able to create, modify, update, and delete any virtual machines associated with any Hyper-V enabled Server 2008 instance on our domain. One can also use an MMC on Vista to connect to the Server Core machine and manage its settings to some degree.

The first task post Hyper-V Manager install on Vista SP1 is to change the default directories under Hyper-V Settings for the Virtual Hard Disks folder and Virtual Machines folder (configuration file folder) to:

  • Virtual Hard Disks: G:\VMs\Virtual Hard Disks
  • Virtual Machines: G:\VMs\Hyper-V
Once we are comfortable that the new machine will not need to be blown away for a fresh start, we need to activate it:


  1. start /w slmgr.vbs -ipk ABCDE-FGHIJ-KLMNO-PQRST-UVWXY
  2. start /w slmgr.vbs -ato
The new Microsoft Virtualization setup is quite slick, and, when Hyper-V is installed on Server Core it rocks!

UPDATE: Missed the Windows Networking setup step.
UPDATE 2008-09-01: Added the initial step to discover the host name, added the update Server Core step, and some minor tweaks to the commands. Updated the firewall rules to reflect the proper syntax.
UPDATE 2008-10-30: Added the Exit command for the DiskPart command set, and a link to our previous post on moving the swapfile in Server Core.
UPDATE 2009-02-20: Added the Constrained Delegation step as well as the opening up of the Windows Advanced Firewall to remote management step.

Philip Elder
MPECS Inc.
Microsoft Small Business Specialists

*All Mac on SBS posts are posted on our in-house iMac via the Safari Web browser.

8 comments:

Randy Fischer said...

I am working on a Hyper-V 2008 server install. Your comments here are a GREAT help. I am wondering about a couple things as I fumble through this.
1: How to decide how much disk space to alocate to Hyper-V Server 2008, I chose 75 gig for no apparent reason.
2: I have 16 gigs of ram, so am making the swap partition 25 gigs. Not sure the thought process I should have on this. Not sure of the whole Swapfile in a seperate partition concept. It seems like a good idea...

Philip Elder Cluster MVP said...

Fischnets,

We do 35GB for the OS.

With Hyper-V being the only role installed, and lots of RAM in the server then it is safe to say not too much in the way of Swap File action will be happening.

The Windows Performance Team Blog has a great discussion on the swap file and how to configure it.

Keeping the swap file in its own partition eliminates any performance degredation due to the file being fragmented over time.

Thanks for the comment!

Philip

Xavier said...

Have you ever managed to configure the Wake On Lan features of your Hyper-V server NICs ? We have a couple of Hyper-V servers hosting test machines and located remotely. These servers can remain unused for weeks so we would like to shut them down but be able to wake them up when needed. The server we use are Dell PowerEdge 610 with embedded Broadcom BCM5709 cards.

Philip Elder Cluster MVP said...

Xavier,

Install a Dell DRAC to remotely power cycle the servers.

Or, if the unit cannot take a DRAC, a PDU capable of plugging into the network that allows you to remotely power cycle the power socket to wake up the server. The BIOS setting for power events needs to be set to turn the server on.

Philip

Anonymous said...

Greetings,
I'm doing a few hyper-v boxes, and the guide is very helpful, however, one of the things missing (or something I didn't see, at any rate) was configuring ipv6. Thoughts?

~Nick

Unknown said...

Hi,

Thank you for this documentation! It helped me out plenty. I have a question: I can't seem to grant permission to a directory which I have created. It keeps coming back with "Net Share syntax command is."

net share example=s:\example /grant:"mydomain\domain admins", FULL

I'm running hyper-v server 2008 R2

is there something i'm missing?

thanks.
jimmy

Unknown said...

Great walkthrough! I'm having trouble with the swapfile, though. I seem to be running into the same problem you were having before you found the team blog you referenced. I'm able to set the autopagefile to True or False successfully, but even after rebooting, I'm getting a "No Instance(s) Available" message. I've paid VERY close attention to syntax, spaces, and have even attempted different sizes. Any thoughts or recommendations?

Thanks,
Ryan

Philip Elder Cluster MVP said...

Ryan,

In the pagefile post that is linked, dig down into the comments to Sander's command set. Note the "Create" step.

That will fix the problem. I need to update that post!

Philip