Moving Users, Document and settings, or Home folder to another partition or disk

Blog
Linux
Windows

Introduction

System partition (Where operating system is installed) is usually target for viruses, bad sectors, out of disk space (Which is quite common in Windows Vista and the next versions due to the winsxs folder's uncontrolled size increase) specially in Windows. You may need to re-install or even format your entire system partition, in situations like this the main problem is how to backup your data if your haven't lost it already!! Although it's possible but it's not easy, Unlike Linux , Windows does not have any official live CD so you would have to use command line or connect your disk to another system and wait until it backups your data and then you can start re-installing Windows, it's a very time consuming process and not every one has multiply OSs or PCs.

Using a different disk for users' data can also improve performance in Multi Tasking. Also If you're a Linux user there is another advantage. Using another partition for users's data allows trying other distributions - which is quite common among Linux users - without having to be worried about data loss.

Linux

Not much to say about Linux in this article since it's part of the installation process. Yes it's as easy as that.

I strongly recommend you to do so, it allows extreme flexibility in Linux, you'll become able to try new Distributions quite easily without having to be worried about your personal files.

Windows

Currently this article is only tested under Windows 7, although it should also work well under previous versions of Windows i can't guarantee unless i actually test it.

Doing this correctly is a bit tricky, using a single wrong command might result in non Bootable OS or very strange errors , i had some difficulty doing it for the first time due to the not very well tested tutorials, but managed to fix my problem by reading and trying dozens of articles, guides, comments. To make it easier for the others i decided to write a practical article.

There are too many ways to achieve this, i start with best one and review the other technique at the end.

Requirements

  • At least two partitions , one for windows and another for moving users' folder to
  • Windows' installation disk (Alternatives are WINPE or Bart's PE)

Usage

Note : Sooner you apply this change easier it's.

Note : You can move Program Files , Programs Data and most of windows' folders to another partition using the same technique, however i haven't tried it.

Booting into the system using installation disk

Reboot your computer and insert Windows 7's installation disk.

Proceed to repair utilities

Run Command Line tools

Moving the folders

Notice : Drive letters are usually incorrect when booting to the repair console, so you need to use mountvol to rearrange the drives before running the other commands otherwise the robocopy and mklink commands will not work properly. Usage :
First unmount the current incorrect drive (in this case C) :

mountvol C: /D
Figure out the correct volume that is to go to C: by issuing mountvol. Copy the volume name of the desired disk.
then unmount the desired C drive (lets say it is currently mounted at E)
mountvol E: /D
Then mount the correct volume to c:
mountvol c: \\?\Volume{GUID}\
Repeat for any other disks that need different letters

Step1 : Find the drive letter of Window partition and the one you want to move your files to. In this example the source is C:\Users and the target is D:\Users. If you're using windows xp , you can use Document and settings instead of Users.

robocopy C:\Users D:\Users /E /COPYALL /XJD /MIR /SEC

Depending on the programs you've installed you might face infinite loop issue. It's caused by a sub folder pointing to itself or one of its parent folders. For dealing with this issue you can append the following switch to the robocopy command mentioned before. You can also use it several times for other folders

/XD "C:\Users\All Users\Application Data"

Step2 : Now lets rename the old Users folder

move C:\Users C:\~Users

Step 3 : Link the old path to the new one on another partition

mklink /J "C:\users" "D:\users"

Changing registry to point to the new location

Editing registry links is important because some installers don’t respect the links and can sometimes turn out messy. You’ll also have problems creating the links because if you try delete C:\Users while windows thinks its the Users dir it doesn’t let you

Step1 : Inside command line window enter

regedit

Step 2 : Now you need to load your offline computer's registry hive. In the registry editor, Go to HKEY_LOCAL_MACHINE and the go to the File Menu and choose Load Hive. You will need to navigate to your Offline Windows installation's software hive file, usually located at the following path : C:\Windows\System32\config\SOFTWARE

It will ask a name for this key. I suggest something simple like SW. Once the hive is loaded, navigate to the sub-key of "SW" to the following location: Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit

Step 3 : locate HKEY_LOCAL_MACHINE\SW\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList and replace string %SystemDrive% and hard coded paths like ProfileList in value of all the keys with the path of the new drive. (If you haven't moved the files of all of them then replace %SystemDrive% only for the those that you moved to a new drive and leave the rest unchanged)

Step 4 :  When done, you may go back to the HKEY_LOCAL_MACHINE\SW section, choose the file menu, and choose Unload Hive. Confirm any prompts

Finishing the job

Restart the computer (Use the boot CD menu).

Make sure everything is ok

Remove ths old Users folder (DO NOT RUSH to remove the old folder, you can always remove it later)

rmdir "C:\~Users" /S /Q

Other techniques

If you prefer to try other options you might find the following descriptions useful.

Using Windows 7' built-in feature

In windows 7 you can move directories like documents, pictures , etc to another partition simply by right clicking -> properties -> location -> move

Disadvantages : You can move a very limited number of folders for each user this way and you'll have to do it manually for all users

Editing Windows' registry

Moving users' folder but only via registry, there are dozens of articles on the Internet describing this technique.

Disadvantages :

  • You'll have to do it again for every new user one by one!
  • You can move only a very limited number of folders
  • Important application related data will note move
  • Some applications have windows' folders path hard coded and modifying registry does not have any effect on this applications

Asking Windows to make new users on new location

Asking windows to create new users on new partition , then login with a new users and move other users.

Disadvantages :

  • This solution is known to cause some problems with windows update!!
  • And applying it to already existed users is a big tricky

One more option

Another technique is described in bent's blog, which is a good one.

Disadvantages : I think that it is really overkill!! besides i can't trust an script like this unless i  fully understand it and test it at least once which takes time. i don't want to end up with missing directories and unexpected errors after a while.

Different Utilities

Different articles authors used different tools, as long as i know there are two alternatives for robocopy in this case. There first one is Windows' xcopy command (Which didn't work for me!) and another but more powerful one that i didn't try is xxcopy

FAQ

Q: Windows creates another folder after boot which is only under its own control, and it's named users!!.?

A: The first reason is Windows Explorer displays the old folder as Users folder regardless of its real name (Probably because of the desktop.ini file inside the folder). To make sure that this is not the case, use command line to list the directories inside C:

Windows makes this folder simply because it can't access the new one due to permission issues! so if you see this folder it means that users folder permission needs to be fixed. If you're sure that the permissions are correct then do the following to get rid of it : boot with your rescue disk , rename it to something else, then rename your original users folder and reboot, that should fix it. DO NOT DELETE IT this time windows makes it again!,you can get rid of it after you successfully logged in with new location

Q: I messed up my system what should i do now?

A: If you made a backup or kept the original folder as i recommended, you can simply rename it back to it's original name and reboot your system.

Q: What about xcopy ?

A: Because of several issues with permissions and junction points i didn't have much luck with robocopy at first so decided to use xcopy which was also much easier to use, however robocoy provides much more option than xcopy so i gave another try and by using the right options i manged to to make it work.

Q: I ran the copy command but it's taking ages! what should i do?

A: Perhaps it's stuck in an infinite loop. The reason is some or several folders linking to themselves. You should be able see the same path repeating again and again in screen. If that's the case then write down the folder/file halt the command immediately by using Ctrl+C , remove the copied folder. exclude it and try again

Q: ok, i did whatever i could but it seems that Windows still can't access my folder, sometimes it logs me in as temporary user?!

A: Removing everyone from new Users folder and replacing it with authenticated users may fix it

Q: Why didn't you use Using Vol GUID which makes it work regardless of it's volume name

A: It decreases portability because if you change your harddisk or move to another system you'll have to recreate links.

Q: Is it possible to move program files and programs data folder using the same method ?

A: Yes, It's possible. However i don't recommend it, it's known to stop windows update from working properly. (By the way Users\All Users is linked to Programs Data)

Q: I think there is a Document and Settings folder on Windows 7 and Vista, shouldn't we move that as well ?

A: No you don't need to be worried about Document and settings because it points to Users for backward compatibility and since we linked c:\users to d:\users it will follow the link and point to d:\users instead

Final words

If you couldn't get it to work, don't hesitate to write a comment and describe your problem i'll help you if i can, there is also many useful resources at the end of this article which you can read for more information

Resources

Your rating: None Average: 1.9 (21 votes)

Comments

Justs's picture

This almost worked

This almost worked flawlessly. :)
I think I have tried every method possible over the past few days. This one seemed to be the cleanest and most thorough. I got nearly all the way through and hit a snag. I am currently wiping my entire machine and beginning again (formatting partitions, fresh Win7 install, etc.)

So before I go through this exercise again, I have a few questions:

    In Step 2: ...Once the hive is loaded, navigate to the sub-key of "SW" to the following location: Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit

    Then what? I navigated there and stared for a few moments, but what do I do next? There is no instruction, so I moved on to the next step.

    In Step 3: locate HKEY_LOCAL_MACHINE\SW\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList and change %SystemDrive% of the record with the path of the new drive

    There is no "SOFTWARE" under the SW tree. There is one directly above SW. There is however the rest of the tree. More like this: HKEY_LOCAL_MACHINE\SW\Microsoft\Windows NT\CurrentVersion\ProfileList I am guessing it was something that was not completed in the previous step?

    In FAQ:
    Q: Why didn't i use robocopy ?
    A: Unfortunately because of several issues with permissions and junction points i didn't have much luck with robocopy so decided to use xcopy which was also much easier to use

    But, unless I am missing something, we are using robocopy in this tutorial. What gives?

Thank you in advance for any assistance or recommendations. Great tutorial and format by the way. Most professional one that I found on the topic.

admin's picture

Ofcourse it doesn't exits,

Ofcourse it doesn't exits, because that key should have been created by your during Step 2 :

It will ask a name for this key. I suggest something simple like SW. Once the hive is loaded, navigate to the sub-key of "SW" to the following location: Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit

And regarding to your question about , i didn't mention that clearly so here is a more accurate version :

Step 3 : locate HKEY_LOCAL_MACHINE\SW\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList and replace string %SystemDrive% in value of all the keys with the path of the new drive

Which means that it's not referring to any specific key. If you see %SystemDrive% on value of any keys on this path you should replace it with the new path. that's it

Also thanks for robocopy point, i updated the FAQ

Espen's picture

Very good guide, however i

5

Very good guide, however i have a few comments that might help someone:

  1. It might be that the drive letters are incorrect when booting to the repair console, you then need to use mountvol to rearrange the drives before running the other commands in this guide. (else the robocopy and mklink commands will not work properly)
    Tips for mountvol:
    first unmount the current (incorrect) C drive:
    mountvol C: /D
    figure out the correct volume that is to go to C: by issuing mountvol. Copy the volume name of the desired disk.
    then unmount the desired C drive (lets say it is currently mounted at E)
    mountvol E: /D
    then mount the correct volume to c:
    mountvol c: \\?\Volume{GUID}\

    Repeat for any other disks that need different letters

  2. I too was puzzled by step 2. I navigated to that key, however you do not state what to do at that key, then step 3 you procede to other keys.
  3. In step 3 you say to replace %SystemDrive% with the proper path, That is fine, but i am unsure if this should be done for the key for ProgramData, (since we haven't moved this folder)
  4. I also had to change a key under ProfileList in subkey S-1-5-21-, called ProfileImagePath this key was hardcoded to C:

Thanks again for a very good guide

admin's picture

Dear Espen thanks for your

Dear Espen thanks for your comment, i updated the guide to include your suggestions and i'm sure many will find those improvements useful :)