Moving ‘inetpub’ to a non-system drive on a SharePoint WFE
May 11, 2011 Leave a comment
This post applies to Microsoft Windows Server 2008 R2 with Microsoft IIS 7.5 and Microsoft SharePoint Server 2010
It is recommended that ‘inetpub’ should not be tampered after SharePoint has been installed and configured. Changes to the ‘inetpub’ and the installation directory should be
planned before installing SharePoint. However, if SharePoint is already installed, and should the need arise to move the ‘inetpub’ directory to another drive from the default system drive, ensure a backup of the farm (databases and file system of each web front end server) before proceeding further.
To move the ‘inetpub’ directory from default system (C) drive to E drive follow the steps below.
Ensure a proper backup of the SharePoint farm completes before proceeding further.
Stop the SharePoint timer service
Create a batch file with the following code.
This batch file can be downloaded from http://blogs.iis.net/thomad/archive/2008/02/10/moving-the-iis7-inetpub-directory-to-a-different-drive.aspx Many thanks to Thomas Deml for publishing this.
Save the batch file as ‘moveInetpub.bat’.
Open a command prompt and drag and navigate to the path of the created batch file. Enter the batch file name followed by the drive letter to which the ‘inetpub’ directory is to be moved. Example C:\>moveInetpub.bat E
The batch file will execute and during execution will stop and start IIS. A new ‘inetpub’ directory will be created in E drive with contents copied from the original location and also the necessary registry changes will be made. However, the original ‘inetpub’ directory will not be deleted.
To test that the files are now being served from the new ‘inetpub’ directory, delete the original ‘inetpub’ directory in C drive. Also verify from the IIS management console (inetmgr) that the physical path of the websites is changed to the new path.
In IIS management console verify the paths for each website and ensure that they are pointing to the proper physical directory.
Note: If IIS components are added or removed in future using the Windows Server Manager console or from the command line appcmd, Windows will create a new ‘inetpub’ directory in the default system drive again, following which the batch file will have to be executed again.
The above batch file only changes the IIS settings, registry entries and the location of the ‘inetpub’ directory with respect to IIS. However, SharePoint has additional properties for each web application which point to the ‘inetpub’ physical directory. These properties can to be changed using SharePoint PowerShell commands easily.
#Create a web application object
$SPSite = new-objectMicrosoft.SharePoint.SPSite(“web application URL”)
$WebApp = $SPSite.WebApplication
#Change SPUrlZone if not in default zone
$IISSettings = $WebApp.IisSettings[[Microsoft.SharePoint.Administration.SPUrlZone]::Default]
#Point to your new directory
$IISSettings.Path = “E:\inetpub\wwwroot\wss\VirtualDirectories\<SiteID>”
#Update Web Application
Execute the above PowerShell commands for every web application and perform an IIS reset.
Start the SharePoint timer service which was stopped in the initial step.
There is a chance of encountering errors with the safe mode not being able to start.
“Safe mode did not start successfully. This page has encountered a critical error. Contact your system administrator if this problem persists.”
There are also chances that the SharePoint Central Administration Website might not work even after making changes to web application settings from PowerShell.
In such cases, we will have to unprovision the Central Administration site and reprovision it using the SharePoint configuration tool (psconfig.exe)
Use the following commands to unprovision and reprovision the central administration site.
psconfig.exe –cmd adminvs -unprovision
The above command will unprovision the central administration web site from the current frontend server.
psconfig.exe –cmd adminvs –provision –port <port no>
The above command will provision a central administration web site at the specified port number on the current web frontend server.
Ensure that the steps are performed on all web front end servers in the farm and all the file paths and contents of the ‘inetpub’ directories are in sync between the web front ends.
Having said and done all that it is also important to know as to why we need to take the pain of moving inetpub for SharePoint installations from C to E drive. A good reference article to start planning the file system and free space can be found here http://www.thesanitypoint.com/archive/2010/06/29/sharepoint-2010-and-the-c-drive.aspx