Installing Windows 7 and Moving User Accounts to Another Drive

Installing Windows 7 and Moving User Accounts to Another Drive

By:  Steve Thompson; with credits to many others

OVERVIEW

Windows 7, by default, places user accounts on the system drive in the folder “C:\Users”.  This guide describes how to install Windows 7 and then move the entire “C:\Users” folder off the system drive and onto a second hard drive, almost a necessity if using an SSD.

This guide also assumes you want to dedicate the second drive exclusively to User accounts.  As such this procedure uses the “mountvol” command to direct Windows to mount the folder “C:\Users” to the second drive, in my case “E:”.  In doing this Windows will look for all content of the “C:\Users” folder on the “E:” drive.

It is also possible to use a directory junction and direct Windows to use a folder on a secondary drive in lieu of “C:\Users”.  If this is your preferred method refer to the relevant section at the end of this guide.

To a first order moving the Users accounts is a 3 step process.  First you need to document all of the system account settings, 2nd is moving all of the contents of “C:\Users” to the new drive, and 3rd is to recreate all of the system account settings.

To provide backward compatibility between Windows 7/Vista and Windows XP, Windows uses directory junctions to direct programs looking for folders/files with Windows XP names to correct Windows 7/Vista locations.  The System Administrator account contains 16 of these, each User account contains 16, likewise the “default” account from which each User account is built contains 16, the “Public” folders contain 3, and the User backbone another 8.

By following the installation instructions below you will need to manage the minimum 43
junctions.  If you have additional User accounts you will need to manage an additional 16 for each.  It is highly recommended you start with a clean install, and add your 2nd, 3rd, etc. later.  Personally, I like Justin Mitchell’s Windows 7 Installation guide and have copied much of it into this article.

In preparation I suggest:

1.    Be familiar with file and folder security settings, and attribute settings

2.    Take meticulous notes when directed to

3.    Backup your entire system, OS and all user data files

4.    Perform a clean install, or reinstall using Justin Mitchell’s guide

CLEAN WINDOWS 7 INSTALLATION

We begin with a clean install of Windows 7.  Unplug any network cables.  Insert the installation DVD and reboot.  Find the boot sequence and change it to boot from the CD/DVD ROM.  Simply follow the directions until you get to a menu that states upgrade or custom installation.  We always want to do a clean and full installation so please select custom installation.

Now we move on to the partitions.  Delete any and all partitions on all Disc drives and then select new and set the size of the partition you want windows 7 to be installed on.  You may notice that there is 100mb set aside on another partition. This is for a system restore, as
all the restore files will be stored there.  If for some reason your system reads 100mb and
not 100mb free, just delete the 100mb partition and then it should read the full 100mb as intended.  Now format all drives/partitions, select your boot drive and proceed with the installation.

What you have just done is ensured a 100% clean installation on your disc drive for the windows 7 operating system.  Ignore the prompt to enter your Product Key and uncheck the “activate automatically” box; we’ll get back to activation later.  Please follow any and all directions at this time and select your time zone, date, and any recommended
settings.  Type “Setup Account” when prompted for a User account name; we’ll use this dummy account for moving the User folder and do a final setup later.

Now, booted into Windows, let’s start the User folder migration.

DOCUMENT THE SYSTEM ACCOUNT SETTINGS

We first document all of the “permissions” and “attributes” detail for every directory junction in the “C:\Users” folder.  This is necessary because when we copy “C:\Users” to
the second drive we will tell the robocopy command to ignore (and not copy) the directory junctions.  And since we don’t copy the junctions, we will have to recreate them and then set their correct permissions, owners, and attributes.  We have to do it this way because some of the junctions point back to the folders that contain them; and these confuse the various copy commands which get stuck in an infinite loops and then terminate leaving you with a half cooked mess.

First let’s collect a list of all the directory junctions in “C:\Users”.  Open an administrator
command prompt window.  (Start button, type cmd in the search box, right click on the cmd.exe icon, click run as administrator)

At the command prompt move to the “C:\Users” folder.  (type C: then press enter, type cd \ then again press enter, and finally type cd \Users then press enter.)

At the C:\Users> prompt type:  dir /al /s > c:\junctions.txt

This creates a text file list of the 43 directory junctions.  Print the file.  The file will list 9 directories, each with 2 or more junctions.  Refer first to “Directory of C:\Users”.  Listed within are 2 junctions.  For each there is the date and time the junction was created, the type of junction (symlink or symbolic, and junction or hardlink), the name of the junction (the first being ‘All Users’) and then the in brackets the target of the junction (the first being ‘C:\ProgramData).  For us the relevant data is the directory, the type, the junction name, and the target.

Now collect and document the attributes for each of the 43 junctions.  In the administrator command prompt window use the “attrib” command.  Move to the “C:\Users” folder.

Type attrib /L “All Users” and press enter.  We use the /L switch to gather the attributes of the junction and not the target directory.   The prompt should return:

SH    I      C:\Users\All Users

In fact, all 43 of these junctions have the same attributes.  Write down the attributes “S” (for system), “H” (for hidden), and “I” (for ‘not content indexed’).

Next document the permissions and owners for each junction.  But first we need to be able to see them.  Open windows explorer.  In the upper left corner of this window press the “Organize” button, and select “Folder and search options”.  Select the “View” tab.  Click the button “Show hidden folders, files, and drives” and uncheck the box “Hide protected operating system files”.  Click “Yes” in the pop up window and then “OK” in the
folder options window.

Now double click the icon for your “C:” drive, and double click the folder icon for “C:\Users”.  You should see folder icons for your User account, for Public, for Default, and
also for “All Users” and for “Default User”.

To gather permissions for “All Users” right click on the icon, select “Properties”, and then the “Security” tab.  In this window you will see a list of “Group or user names” and a
list of “Permissions”.  Press the “Advanced” button, and then the “Change Permissions” button.  In this window you see a table.  Across the top are the headings:  “Type”, “Name”, “Permission”, “Inherited From”, and “Apply To”.  Write down the headings and the list of permissions.  Also write down if or not the “Include inheritable permissions…” and “Replace all child object permissions…” boxes are checked.

Now click on and highlight the first name in this list “SYSTEM” and then press the “Edit” button.  Write down every last detail in this window:  “Apply to: —-“, which boxes are checked and whether they are “Allow” or “Deny”, and finally whether the “Apply these permissions to objects and/or containers within this container only” box is checked.  Click “Cancel”.  Repeat this for every name in the list.

Now repeat for “Default User”, and then repeat for each of the remaining 41 junctions.

The owner for all junctions is “SYSTEM”.

Set all of this information aside.  We will need it later, after copying all of the contents of
“C:\Users” to the second hard drive.

MOVING C:\Users TO THE SECOND DRIVE

Open windows explorer, double click the icon for the “C:” drive, and right click on the icon for “C:\Users”.  From the menu select “Properties”, the “Security” tab, press the “Advanced” button, and then the “Change Permissions” button.  Open a second windows explorer.  Select the drive you plan to copy your User accounts to and right click its icon.  Select “Properties” from the menu and likewise select the “Security” tab, and press the “Advanced” and then the “Change Permissions” buttons.  Now change the permissions and owner for the target drive to match the permissions of the “C:\Users” folder.

The target drive is now ready for the user accounts.  We will move “C:\Users” and all its contents to the target drive in the repair console.

Boot to your installation disk.  Click the “OK” button on the intro screen, select “Repair Computer” (not install) on the second screen, and on the third screen select “Command
Prompt”.  You are now in the repair console.  Most likely you will see a prompt for the “X:” virtual drive.  Now locate the system drive.  (note:  it will not be “C” in the repair console).

If you have two hard drives in your system, generally “C” and “D” then in the repair console your system drive is most likely “E”.  On my system I have 4 hard drives “C”, “D”,
“E”, and “F”, so in the repair console my system drive is “G”.  Move to your system drive by typing the drive letter/colon G: and pressing enter.  Confirm this is the system drive by typing dir and then enter.  The system drive will return a list that includes “Program Files”, “Program Files (x86)”, “Users”, and “Windows”.

Rename the \Users folder.  Type ren Users Users_save and then press enter.  Type
dir and enter to again list the folders on your system drive and confirm the name change.

Now type mountvol and press enter.

The command will return the syntax for using the “mountvol” command, the list of switches and what they do, and then a list of all the drives on your computer.  These drives are listed by their or “VolumeName” (e.g. “\\?\Volume{fb705c09-2667-11df-8915-806e6f6e6963}\”) and below this the a drive letter (e.g. “D:\”).  Make note of the “VolumeName” for your target drive (it will have the same drive letter in the repair console as it does in windows).

Now we will assign your target drive to the “\Users” folders.  First make a new, empty “\Users” folder.  Type md \Users and press return.  Type dir and return.  Confirm the existence of the new “\Users” folder.  Now type mountvol \Users \\?\Volume{- – - your target drive’s volume name here – - -}.  With this command %SystemDrive%\Users is mounted to the target drive and to Windows and every software application you run they will appear one and the same.

Now we copy the User account files to the new \Users folder/drive.  For this we use the
“robocopy” command since “robocopy” will copy all of the folder and file security permission and attributes.

We will use the following “robocopy” switches:
·         “/XJ”       do not copy junctions
·         “/MIR”    mirror the directory tree
·         “/E”          copy all subdirectories, including empty ones
·         “/SL”        copy symbolic links versus the target (not sure if this is really needed)
·         “/COPYALL”      copy all file info (e.g. permissions, attributes, owner, etc.)

At the command prompt type robocopy \Users_save \Users /XJ /MIR /E /SL /COPYALL and press enter.

Check the report at the end.  If all has gone well there will be no failures.  Also note the
number of folders in “\Users_save” and the number of folders copied into “\Users”.  The missing folders are the junctions we told “robocopy” not to copy, the ones we earlier so meticulously documented.

Type exit and return, and then reboot into windows.  Open windows explorer and double
click the icon for your “C:” drive.  You will see two “\Users” folders (don’t be alarmed!).  One of them will have a normal folder icon, but the other will look like a shortcut arrow.  Double click this shortcut icon you will see the contents of the new \Users folder, double click on icon for your User account hard drive.  The contents should look exactly the
same.  If they do success!

Now let’s recreate the 43 junctions.

RECREATING DIRECTORY JUNCTIONS WITH THE “MKLINK” COMMAND

To create the directory (or folder) junctions we use the “mklink” command in an administrator command prompt window.  Use the “/D” switch to create a symbolic link (SYMLINKD) and the “/J” switch to make a hard link (JUNCTION).  Refer to your printed junctions.txt file and note there is only one symbolic link.  We’ll start with it.

Open an administrator command prompt window and move to “C:\Users”.  To create the “All Users” symbolic link type mklink /D “All Users” “C:\ProgramData” and then press enter.  The command will return symbolic link created for All Users
<<–>> C:\ProgramData
.  

Now type dir /al /s.  The command will return a record of 7 junctions, “All Users” the one symbolic junction you just created, and an additional 6 hard link junctions within it (listed under the “C:\Users\All Users” folder).  I don’t know why it does this.  While still in the “C:\Users” folder create the “Default User” junction by typing mklink /J “Default User” “C:\Users\Default”.  You now have the first 8 junctions on your list.  Before creating the remaining 35 let’s set the attributes, owners, and the security permissions for
these 8.

Still at the “C:\Users” prompt type attrib /L “All Users” enter and note the current
attributes.  This should return no attributes.  If it does make sure you have used the /L switch.  Type attrib /L “All Users” +S +H +I and press enter to set the correct attributes.  Confirm by typing attrib “All Users” and enter.  Repeat the process for “Default User”, and then moving to the “C:\Users\All Users” folder repeat the process for the next 6 junctions on the list.

Now move on to setting the owner and security permissions for the 8 junctions.  Open windows explorer and as before set the view options to show both hidden and protected system files.  Double click the icon for the “C:” drive and then the shortcut icon for “Users”.  Right click the icon for “All Users”, and select “Properties”, the “Security” tab, the “Advanced” button, and the “Change Permissions” button.  Set all the permissions per your earlier documentation.  Click “OK”.  You can also open a 2nd explorer window and migrate to the old \Users_save folders and use these junction permission settings for reference.

Select the “Owner” tab (if you clicked one to many “OKs” and completely closed out the advanced security window, right click—properties—advanced—owner tab will get you there).  Note the group or user listed as “Owner”.  It should say “SYSTEM”.  (you will need to change the owner to SYSTEM for all 43 junctions).  Press the “Edit” button and then the “Other users or groups” button.  In the large box type System and click okay.  Now “system” will show in the “Change owner to” box.  Click on “System” to highlight it and press the “OK” button.  You will be prompted a number of times, respond “OK” or
“YES” to each.

Repeat the above, setting the security permissions and “System” as the owner for the other 7 junctions.

The process is exactly the same for the remaining 35 junctions.  In the administrator command prompt window migrate to the correct directory, use the “mklink /J” command to create the desired junction, and in the same window clear, and then correctly set the
attributes.  And then in windows explorer set the permissions and owner.

When finished type dir /al /s > c:\junctions2.txt and print this file.  Compare to the
earlier file, double checking that all junctions were recreated, and that they have are in the correct directory, have the correct name, and point to the correct folder.

Now boot again to the repair console command prompt and move to your system drive.  Type dir and enter.  Now delete “\Users_save” by typing rmdir /s \Users_save and
pressing enter.  Type y and press enter when prompted.  Confirm by typing dir and pressing enter that “\Users_save” is in fact gone.

Exit the command window and reboot into windows.  Your user account files are now moved off your system drive and onto a second hard drive.

Let’s continue and complete our Windows 7 installation and setup.

THE REAL ADMINISTRATOR ACCOUNT

The dummy account we created during the windows 7 installation is a administrator account, however it does not have full access rights to the operating system. To achieve the full rights of the Windows 7 operating system please do the following.  In the Run
command type “control userpasswords2” and press enter.  You will now be looking at the User accounts.

Select the advanced tab and then click on advanced. You are now looking at the local users and groups menu.  Double click on users and you will see the administrator account, the guest account, and the account you created during the Windows 7 installation.  Right click
on the account you created during the installation and select “Account is disabled”.

Now we move onto the administrator account.  Right click on the administrator account and select properties.  Rename the account, note: you can not name the account the same as the account you created during the installation and deleted.  Put a check mark in the box that says “user cannot change password” and most of all remove the check mark in the box that says “Account is disabled “.  Now restart the computer by selecting it in the start menu.

Upon reboot open a command prompt and migrate to your system drive by typing cd \ and pressing enter.  Then migrate to the users directory by typing cd \Users and
pressing enter.  Type and enter dir to view the directory structure.  You should see folders for “Public”, your renamed “Administrator”, and “Setup Account”.  Let’s hide the “Setup Account” folder since we will not need it again.  Type attrib “Setup Account” +S +H +I and enter.  This sets the folder to be a hidden system folder; it will disappear from view unless you select to show these in your “Folder and search options” settings.

You now have 100% full administration right to the operating system.

PERFORMANCE & SECURITY TWEAKS

The first performance tweaks we will be doing are going to take place in the control panel of your Windows 7 operating system.  Go to you start menu and select Control Panel.  You may notice this control panel is a bit different from what you may be use to.  I recommend you play around and get familiar with it before moving on.  Once you’re done getting to know your new control panel we start by clicking on system and security.

In this window you a shield that says “allow remote access “ Click on this and please remove the check mark from the box that says “ allow remote assistance connections to this computer “ then click apply.  Remote access is a big security threat and unless needed should be disabled 100%.

Now in the same menu selection system and security click on power options and click the small arrow pointing down to achieve the high performance option then select it.  You’re done here so go back to the system and security menu in the control panel and select windows update.

To the left of this window you will see many options for the updates.  Click on change
settings and select “check for updates but let me choose when to install them” or you can do what I do and select, never check for updates and I manually install them myself.  This option is strictly preference.  This wraps up the tweaks for the control panel.  Let’s continue our system setup by optimizing the boot sequence.

In the search or run command please type “msconfig” then press enter.  Select the boot tab, then advanced options. Now that you are in the boot advanced options menu you need to put a check mark in the box that says “number of processors “then select the highest number of processors in the drop down menu below.  This is in regards to your (CPU processor).  If you have a dual core, you will see 1-2 processors.  If you have a quad core you will see 1-4.  By selecting the highest number, you are telling Windows 7 to boot using all processor cores and in turn will boot faster. Once this is done click apply and then okay to close.  Let’s optimize Windows 7 services.

In the start menu search box or in the run command box type services.msc and
press enter.  This opens a window listing all the windows services.  You should see a huge list of all the services that windows 7 is running every time windows starts.  About 90% of these processes are necessary for windows to function properly, however some are not.  We are going to disable 4 services that when running can present a system security risk.
Scroll down this menu and “stop” and set to “disable” these 4 services.

“Remote registry”, unless you elected to use the remote services, we don’t want anyone to have access to or registry, especially remote connection.  To stop and disable, double-click “Remote Registry”, press the “Stop” radio button, and then select “Disabled” on the drop down menu.  Click “OK” to save and close the properties window.

“Secondary logon”, this is in regards to the remote connection, other user, and hackers.  You only want one way to log in to your computer and that is by you.

Next is “Windows error reporting service”, every time that there is an error on your operating system, windows will report this to the company and then try to find ways to fix the problem for you.  This is great however every time they do this it puts your registry at risk from modification.  After a while your registry will be filled with stuff you do not need and harsh marks over any errors, just bypassing them and not getting rid of them.

“Parental controls”, unless this option suits you then get rid of it.  Now close this window.  You have now successfully completed a complete performance and security tweak on your Windows 7 operating system.

DRIVERS AND WINDOWS UPDATES

Please do not connect you LAN/Internet connection yet and install all the drivers that you can first.  Most of your drivers may have already been installed during the Windows 7 installation, however some may not have been and require a manual install, whether a CD/DVD or internet download.  To check the status of your system and drivers, go to your device manager and any line item that is opened up as a submenu needs a driver.  Once all the drivers have been installed refresh the screen, now all the submenus should be gone. If for whatever reason you need to go online to download drivers, do so now.

Shutdown your system and connect to your LAN/Internet connection and restart the system.  Once Windows has started, download and install any remaining drivers and then migrate to Windows Update in the Start Menu.  Scan the entire list, including any optional
updates, and right click/hide all updates pertaining to hardware drivers (motherboard, graphics cards, sound cards, printers, etc.) unless you are certain you want the provided drivers.  Click the “install” button.  You may need to restart a few times before you receive all the updates.  Once you have completed all of the available updates we move on to activation.

WINDOWS 7 ACTIVATION

Open a Control Panel window and select the system shield.  Locate and click the activate windows link.  This will open a new activation window.  Enter your product key into the frames provided and click activate.  If you installed from a new install DVD this should proceed without incident.  If you installed from an upgrade DVD this may return an error stating the product key is not valid.  In that case complete the following steps (source:  Paul Thurrott’s blog entry on doing a CleanInstall Windows 7 with Upgrade Media).

Open the run command, type regedit and press enter.  In the registry editor migrate to HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Setup/OOBE/

Next change value of the DWORD MediaBootInstall from “1″ to “0″. (Double-click it and then enter 0 in the dialog box that appears.)  Close regedit.

Now open a command prompt window.  Type SLMGR /rearm. Then ENTER and wait for the “Command completed successfully” dialog.  Reboot and then proceed to activate Windows 7.

FURTHER OPTIMIZATION, MAINTENANCE AND EVERYTHING ELSE

I recommend Koroush Ghazi’s Windows 7 Tweak Guides Tweaking Companion.  This
guide contains a comprehensive install, setup, optimization, OS and system tweaking, and maintenance overview along with recommendations for security software.

LET’S WRAP THINGS UP

You are almost finished with your fresh install.  Add any other accounts (mine is a family use computer so I add 3 additional user accounts), restore all of the backed up user files, and install your software and games.

Congratulations, you have successfully installed Windows 7 and moved your User accounts off your system drive!

ON USING JUNCTIONS INSTEAD OF MOUNTVOL

I have not tested this, but see no reason why it shouldn’t work as well as the above procedure.  Skip the step of mounting “C:\Users” to the second drive and go directly to the
robocopy step, but enter this command instead of the one above:  robocopy \Users_save E:\Users /XJ /MIR /E /SL /COPYALL.  Where I inserted the drive letter “E:” enter the correct drive letter for your system.  Now use mklink to create the directory junction:  mklink /J \Users E:\Users.  Set the correct attributes for this junction, same as the \Users_save folder, and upon reboot set the correct security permissions and owner for this new link.  After you confirm that all of the \Users folders and system files are where you want them reboot to the repair console and delete the “\Users_save” folder.  The remainder of the guide can be followed as written.

ACKNOWLEDGEMENTS

Let me credit the following people without whose work I wouldn’t have had a clue where to begin.

About these ads
This entry was posted in Uncategorized. Bookmark the permalink.

11 Responses to Installing Windows 7 and Moving User Accounts to Another Drive

  1. Nice post! I would add that robocopy \Users_save E:\Users /XJ /MIR /E /SL /COPYALL
    would exclude from your copy all simlinks or junction points (because of the /xj switch). I don’t know about mountvol.
    I found a tool to recreate them in case any older (xp) program needs them: http://sourceforge.net/projects/junctionbox/

    Thanks for the help!

  2. Steve T says:

    Indeed the symlinks and junctions are not copied. Many of these point back onto themselves and without the /xj switch one ends up in an endless do-loop; and this is the big challenge. Prior to doing the robocopy it is important to capture all of the symlinks and junctions AND their security setting. And after the robocopy, painstakingly recreating it all. But done correctly, it works.

  3. James says:

    I tried this but found my User folder in drive D has a shortcut which lends you to drive D so its going back to itself. My user data does not seem to be being stored in drive D either. I noticed my primary drive free space is going down after trying data to my desktop. Shouldn’t it go to my other drive rather than primary?

    • Steve T says:

      Hmmm. I’ve used this recipe several times with both Vista and Windows 7, without issue. Sounds like something went wrong for you during the robocopy as yes, the user data should have all been transferred to the other drive. Absent seeing your system myself I am not sure I can be of much help with the debugging. Do you have an image of your original install that you can restore to, and then try again?

  4. James says:

    My system is working fine, but it has moved many of the files ive noticed as some are as short cuts. But when I add new user accounts it simply goes to the C drive and not D. Also seems 1 of the user accounts did not get transferred for some strange reason. I take it the User folder in my D drive should not direct me to the D drive?

    • Steve T says:

      Sounds like something went wrong. If the system works, that is 1/2 the battle. Beware though…the real test will be when you go to install other software and if the software flags go to the right directories.

  5. James says:

    seems to of gone wrong in couple of places, data not being used from the D drive and there is the user dir being just a short cut to D drive. also i noticed my windows defrag tool says D:,D:\Users
    Only thing I can think of is try again but some of your tut doesn’t all make sense.

    PS can same be done to another files and directories? for example moving System32 to another drive i believe it should improve system performance, cos ofc its spedding the work load out more.

  6. Steve T says:

    Regarding the system32 directory I imagine it can be moved, but understanding all the bits that point to it and how to set those up would be the challenge. As I think about where your think might have gone wrong, I wonder if you inadvertently mounted your system drive and ended up doing the robocopy into a new directory on the same drive?

    • James says:

      It seems the mounting part only created a shortcut to D drive and this shor cut I’d in d drive. Everything still going to C drive everything still works as normal am going to try again although its not a fresh I installation. Yes I think it must of copied to the wrong location :( will try again

  7. krankyinkc says:

    I know this was written a long time ago now, but still very useful. Thank you!

    I have to say, however, with SSD drives more prevalent these days as a primary drive, Microsoft really needs to build this into some sort of supported utility or install option.

    • Steve T says:

      The process is arduous, but it works reliably. Microsoft has provided a means to move the data files to a different drive, but their method does not remap all of the embedded junctions and not all programs play nice.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s