Posts tagged “Server 2012 R2

Powershell script to setup NFS share on Server 2012 R2

The following script sets up NFS share on Server 2012 R2:


# Script to setup NFS share on Server 2012 R2
# Sam Boutros – 7/7/2014
# References:,
$NFSFolder = “d:\shares\NFS1” # Tye in the path to the folder to be shared via NFS
$NFSShare = “nfs1” # Type in the share name you wish to use
# End Data entry section
Import-Module ServerManager
Add-WindowsFeature FS-NFS-Service
Import-Module NFS
if (!(Test-Path $NFSFolder)) {New-Item -ItemType directory -Path $NFSFolder}
New-NfsShare -name $NFSShare -Path $NFSFolder
$ShareName = $env:COMPUTERNAME + “:/” + $NFSShare
Write-Output “NFS share has been created: $ShareName”

You can see the new share in Server Manager under File and Storage Services:


The default NFS share properties are:



Under Share Permissions, I clicked Add, entered the IP address (or name) of the Linux host that needs to connect to this 2012 R2 NFS share, and selected the desired access (read/write):


No changes to NTFS permissions:


Finally, I enabled the following firewall rule to allow me to ping this server:NFS8

Next, I setup a Red Hat 6.5 VM to test with.  I picked v6.5 because

  1. It comes with the Hyper-V integration built in – no need for manual RTM installation,
  2. The Hyper-V integration server for 6.5 kernel allows for Host-based VSS backup – no need for guest agent inside the Linux machine. We get crash consistent backup (not application consistent backup), but that’s a big improvement from Hyper-V integration service for kernel version 6.4 and older,
  3. The Hyper-V integration service supports dynamic RAM. Again, with kernel versions 6.4 and older, we can only use static RAM with Linux guests

I downloaded the media ISO Boot and DVD files from Red Hat,

created VM with 2 DVDs so that I can mount both media during setup, followed the simple installation steps, rebooted

Next, I used the console (and later on Putty to SSH) to the new Red Hat machine, logged in as root,


I ran the following commands:

ifconfig -a => show interfaces
ifconfig eth0 netmask => to setup IP address and mask
ping => confirm connection to NFS server (enabled ping rule in Windows firewall)
mount -t ext4 => to show partitions formatted with ext4 file system
mkdir /pub => to create local mount point directory /pub
mount /pub (must have added permission on NFS share on Server 2012)
cd /pub => to change directory to /pub
ls => to see files on remote NFS share
echo hello >test1.txt => to test creating a text file named test1

You might want to edit /etc/fstab and modify the following line to match your configuration. For example: /pub nfs defaults 0 0

The files were visible also on the 2012 R2 server.


Setup-KCD.ps1 powershell script to setup Kerberos Constrained Delegation for Hyper-V

One of the really nice features of Hyper-V is the ability to live-migrate virtual machines from one physical Hyper-V host to another while the VM is running. VMWare calls this feature vMotion. VMware’s vMotion was a bit ahead of Microsoft’s live-Migration until the release of Server 2012 and now 2012 R2. In my opinion Live Migration leaves nothing to be desired and has exceeded many features in vMotion (compared to ESXi 5.5). The script can be downloaded from the Microsoft TechNet Gallery.


Live migration has few requirements including:

  1. Active Directory domain: all Hyper-V hosts must be in an AD domain (either same domain or domains with two-way trust relationships)
  2. Kerberos Constrained Delegation

See this Technet article for more details.

KDC can be setup manually in AD Administrative Center. In an environment with a large number of Hyper-V hosts this can get tedious. The following script automates the task of setting KDC between a group of HyperV Servers.

Confirm changes by looking up Host properties in AD Administrative Center:

KCD2Finally test live-migration: