Change location of Users and ProgramData folders to other drive
Sometime ago I decided to buy and install SSD drive in my PC. At that time I thought that 120 GB will be enough for me. Of course I was thinking about bigger drive but main purpose of this upgrade was to speed us OS and application start and run. All data and documents should be hold on other drives. That was a plan that worked for longer time.
But…. Last week new Visual Studio and new Windows 10 were presented. In that time on my SDD drive there was only 2 GB free space. I tried to clean a disk but without any success. But I managed to identify a problem – two folders: Users and ProgramData have about 22 GB. I discovered also that Chrome takes about 1,5 GB for cache and other data. I was really shocked because of this.
Of course I tried to remove some files from those folders but I didn’t manage to gain needed space. Because of that new idea came to my mind – move those folders to another drive. After few tries I can say that this operation is not so difficult but you need to remember about few things. But I will point those things later.
Let’s start from beginning. First of all you need to start command line from Windows installation CD. To do that you need to do following steps:
- Start Windows 10 installer from CD.
- Then select option Troubleshoot
- Later – Advanced options
- And finally Command Prompt
From this moment you should have access to local drives from command line. Next thing that you should do is trying to find disk with OS and target drive where you would like to move those files. When you will do that you can copy those folders by executing following commands:
robocopy "C:\Users" "D:\Users" /MIR /COPYALL /XJ robocopy "C:\ProgramData" "D:\ProgramData" /MIR /COPYALL /XJ
After doing that you can remove those folders from OS drive:
rmdir "C:\Users" /S /Q rmdir "C:\ProgramData" /S /Q
And finally you need to create links to new folders. You will do that by following commands:
mklink /J "C:\Users" "D:\Users" mklink /J "C:\ProgramData" "D:\ProgramData"
In theory everything should work great after those steps. But sometimes you can spot some problems.
First of all you should remember that link you have created is somehow like a shortcut. And sometimes disk in command line can have different letter than after starting OS. Because of this you should always create links that will point folder on drive letter that will be used in OS and not in command line.
Also additional problem can occur. It is also connected to drive letter change. In my case I wanted to have ProgramData folder on Z: drive. Unfortunate this drive was not available in command line. And during attempt of link creation I got error with information that such drive does not exist. Of course you can obey such situation – you need to create additional copy of folder to drive with letter that you can create link. Then you need to start Windows and delete link to this folder and create new one to target device. We should remember to do that action as soon as possible after Windows start. Only then we will be able to reduce potential differences between folders. And finally we can remove folder that will not be used in future.