Anapixital


Monday, August 01, 2011

Moving Users Folder from C:\ to D:\

Warning: Follow the steps below at your own risk. I will not be held responsible for any damages caused as a result of following them. If you do choose to go ahead, remember to back up your data before going through the instructions. With that out of the way, read on.

I just got myself a new machine. The first time in eons that I have done so. As with all machines that I have owned, the first order of business was to customize it to my very specific settings. Among them was to move the Users folder normally found on the root of the system drive to a different drive. Reason being, I want nothing but programs and system software on the system drive, and all user generated data on a different drive.

I had done this before way back, and so had forgotten how I had achieved that task. And so onto the net I went to refresh my memory. Since the computer I have is running Windows 7, there was bound to be differences between how I did it last time and how I would get it done now.

The few links that came up initially involved some Registry hacking, which I am okay with. On researching some more, I found this LifeHacker site that showed a way to achieve my task without any Registry hacking. The thing that worked for it was use of symbolic links. I decided to try it out.

The instructions as laid out on that site are very simple to follow. I went through them without any problems. However, when I tried logging into my system, I got an error stating, "User Profile Service service failed logon..." No matter what I did, I wasn't able to log in. The LifeHacker site has an addendum showing what to do in the event one ran into problems. I followed those steps to try and recover my setup to no avail. Eventually I had to restore my machine to factory settings so I could log in again. Fortunately for me I hadn't yet set up anything else on it, so this wasn't as painful as it could have been.

I googled the error I had come across to try and figure out how I could resolve it. Nothing I found was of any help. At some point I remembered a way to recover a corrupt profile on a machine from a fix I had needed to do a couple of months ago and figured I would try that out on this machine. I went through the steps of moving the User folder once more, and at the point where I ran into the error tried out the steps of recovering a corrupt folder.

In detail, that involved:

- Backing up the corrupted user's folder
- Setting up a new user with Admin rights.
- Logging into that account in Safe Mode.
- Going into Regedit navigating to HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/ProfileList
- Deleting the key entry of the corrupted user's key
- Adding the user again from Control Panel
- Restoring their data into their new user folder.

I tried going through these steps but failed at the second one. At this point I tried a number of different things, all very experimental, to see if I could fix the problem. I went into File Explorer in safe mode and tried accessing the User folder from the C:\ drive and found I couldn't open it. That got me thinking that probably the link making process was not working as it should, since I ought to have been able to access the contents of that folder on the D:\ drive. This led me to try the following:

- Rename the key S-1-5-**-****-****-****-1***.bak to S-1-5-**-****-****-****-1***
- Change the value of the ProfileImagePath variable of the user from C:\User\username to D:\User\username.

This fixed the problem, and I was able to log in to my account. I was tempted to leave it at this, but then the nagging thought that this was just a stop gap measure kept bothering me. I did a test to see if the solution would hold by creating a new user. That did not work, since the new user's ProfileImagePath variable was set under the C:\ drive.

I reset the changes I had made and tried a different approach. I thought that since the previous two steps seemed to have somewhat fixed the problem, combining them with the LifeHacker steps would probably give me the full solution. I combined my steps with those of LifeHacker to come up with the following set of steps that eventually solved my problem (started from the point where the robocopy command is invoked in the LifeHacker steps):

- robocopy /copyall /mir /xj C:\Users D:\Users
- rmdir /S /Q C:\Users
- reboot into Safe Mode and navigate to HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/ProfileList
- rename the key S-1-5-**-****-****-****-1***.bak to S-1-5-**-****-****-****-1***
- change the value of the ProfileImagePath variable of the user from C:\User\username to D:\User\username
- reboot into regular mode and log into username account
- delete C:\Users
- mklink /j C:\Users D:\Users
- reboot into Safe Mode and navigate to HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/ProfileList
- change the value of the ProfileImagePath variable of the user from D:\User\username to C:\User\username

I tested this by logging into my account in regular mode and it worked just fine. I also set up a new account successfully. The next test trying to access C:\User, which I was able to do. The final test was copying data onto D:\User\username and see if I could access it through C:\User\username. I also checked the disk space of both C:\ and D:\ after copying the data. D:\'s space reduced while C:\'s space stayed constant. Problem solved!

Read on...