Windows/Move Documents and Settings

From braindump
Jump to navigation Jump to search

Windows XP puts all of the user profile data into the %SystemDrive%\Documents and Settings. While this is ok with most settings where you only have 1 disk with one partition sometimes the space on the %SystemDrive% gets smaller and smaller and smaller and can affect system performance. In one particular case I had a much larger D: drive and I wanted to move all the users' data to it. This is how I went about the task.

Proof of concept - move one user

The first thing to do is to login as Administrator and pick a user that can be moved. For the sake of this example we use the fictious user jdoe.

  • Open the registry editor and navigate to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
  • Create a backup of the registry path mentioned above by navigating to the File menu and choose Export.
  • Look for the users jdoe by clicking on the folders starting with S-1-5-21-1111111111-222222222-333333333-1XXX. If the number after the last hyphen is 500 it is most likely the Administrator's account. Look for the value of the ProfileImagePath as it will contain the users' name at the very end.
  • Edit the value changing the %SystemDrive% variable to the desired drive letter in our case D:. For our sample user the path should then look something like this D:\Documents and Settings\jdoe.
  • Now create a folder called Documents and Settings under the D: drive.
  • Move the folder jdoe from %SystemDrive%\Documents and Settings to D:\Document and Settings
  • Log out of the Administrator account
  • Log into the account jdoe and check if everything is working as expected.

Move all users

After successfully having moved one users it is time to move the rest of the system.

  • Open the registry editor and navigate to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
  • Create a backup of the registry path mentioned above by navigating to the File menu and choose Export.
  • Change every users' ProfileImagePath changing the %SystemPath% to the new driver letter. Note: There is one excpetion user S-1-5-18 is off limits!
  • Reboot the host with a Linux rescue system disc such as SystemRescueCD
  • Create a directory called /mount and mount the Windows partitions
mkdir -p /mount/{c,d}
ntfs-3g /dev/sda1 /mount/c
ntfs-3g /dev/sda2 /mount/d 
  • Copy the date from /mount/c/Documents and Settings to /mount/d/Documents and Settings
rsync -av  "/mount/c/Documents and Settings" /mount/d/
  • To ensure it is working when logging back in we create and __ARCHIVE__ directory under /mount/c/Documents and Settings and move all the previously copied data into it.
cd "/mount/c/Documents and Settings"
mkdir __ARCHIVE__
mv * __ARCHIVE__
  • Reboot into Windows again testing if it worked.

Ensure new users will end up on the new drive

For new users to make sure they land on newly created drive we need to change on more Registry entry. For the sake of readability the command has been split onto several lines. Change the /d "" value to the path desired.

reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" 
  /v ProfilesDirectory 
  /t REG_EXPAND_SZ 
  /d "D:\Documents and Settings"

Rollback

To roll the above change back run the following commands:

set sysdrv=SystemDrive
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" 
  /v ProfilesDirectory 
  /t REG_EXPAND_SZ 
  /d "%%sysdrv%%\Documents and Settings"