Moving Inetput to different drive with Sharepoint websites

Published:
Are these one of the scenarios you faced in your environment?
You don't have space in default C drive and always wanted to move Inetpub to D drive.
By mistake someone configured few webservers on C drive and couple of them on D drive, in farm environment it caused issues while deploying the code base.
One of your environment is already configured in C drive long back and now you have a policy/scripts which will only work in D drive. You want to move to D drive and make this environment similar to your production/cob environment.

If you answered yes to any one of the above, then you are reading the right article. Lets follow the below steps to move Inetpub with sharepoint websites from C drive to D drive.

Step 1: Backup the current registry and Change all the registry settings as below.

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ContentIndex\Catalogs\Web]
                      "Location"="D:\\Inetpub"  
                      
                      [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\ContentIndex\Catalogs\Web]
                      "Location"="D:\\Inetpub"
                      
                      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ContentIndex\Catalogs\Web]
                      "Location"="D:\\Inetpub"
                      
                      [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp]
                      "PathWWWRoot"="D:\\Inetpub\\wwwroot"

Open in new window


Step 2: Goto C:\winnt\system32\Inetsrv. Make sure IIS is stopped. Take a backup of metabase.xml under Inetsrv.  Do find/replace from C:\Inetpub to D:\Inetpub for all references.

Now copy C:\inetpub directory to D drive and give the same permission for the directory similar to C:\inetpub.

Step 3: Login to Server which contains sharepoint databases. Run the below query against sharepoint configuration database. This will give all the webapplications which are created in C drive.

select * from objects where properties like '%C:\inetpub\wwwroot\wss\virtualdirectories\%'

Open in new window


Now we need to update all these references to D drive as we are moving from C drive.

Step 4: We need to run the below powershell script to update the configuration database.
#script start
                      [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
                      
                      $SPSite = new-object Microsoft.SharePoint.SPSite("http://mywebapp:24333")
                      $WebApp = $SPSite.WebApplication
                      #IIS zone under which webapplication is created.
                      $IISSettings = $WebApp.IisSettings[[Microsoft.SharePoint.Administration.SPUrlZone]::Default]
                      
                      #Change to new path
                      $IISSettings.Path = "D:\wss\VirtualDirectories\24333"
                      
                      #update and dispose
                      $WebApp.Update()
                      $SPSite.Dispose()
                      #End powershell script

Open in new window


Now the trick part is moving the websites created by extending to different zones and ssp.

So you need to change the IISettings i.e
$WebApp.IisSettings[[Microsoft.SharePoint.Administration.SPUrlZone]::Default]

Open in new window


For example if the website you have created is in internet/intranet it would be like this
$WebApp.IisSettings[[Microsoft.SharePoint.Administration.SPUrlZone]::[b]Internet[/b]]
                      $WebApp.IisSettings[[Microsoft.SharePoint.Administration.SPUrlZone]::[b]Intranet[/b]]
                      
                      For moving webapplication with Shared Service Provider(SSP) the zone will be default but the change will be in  SP site object. It should be like this...
                      
                      [code]$SPSite = new-object Microsoft.SharePoint.SPSite("http://mywebapp:24333/ssp/admin")

Open in new window


So run the powershell script by make all these appropriate changes to all the sites for sharepoint.

Step 5: Run the below query to check the configuration database is updated.
select * from objects where properties like '%d:\inetpub\wwwroot\wss\virtualdirectories\%'

Step 6: Start the IIS and remove/backup the C:\inetpub directory. Browse your sharepoint websites to make sure there is no issue.

This way it helps you to spend only 30 minutes to move from C drive to D drive rather than spending 1 or 2 days to completely remove all Sharepoint websites and reinstall them completely on the D drive. It saves more time and effort if you have lot of Sharepoint websites or sites with heavily customized features and code.
2
3,401 Views

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.