windows分离系统文件和用户数据

2013/12/17更新:使用了一段时间,开机时有时会出现一些错误,不过不影响正常使用,不能忍的是会经常更新,所以暂时不推荐使用。


为了方便地重装系统,同时保留用户数据,想到了分离windows系统文件和用户数据。经过各方搜索,终于成功,现总结如下。

主要把Users和ProgramData移出系统盘(Program Files和Program Files (x86)可根据个人需要选择是否移动),这里以从C:Users和C:ProgramData移动到D:Users和D:ProgramData,win8系统为例。

主要有两种途径,一是在安装系统将要创建用户的时候按Shift+F10进入命令提示符,二是在安装系统后进入修复模式,核心思想都是将Users和ProgramData移动到目标文件夹,在系统盘建立硬连接。

方法一、安装系统时移动

1、将要创建用户的时候按Shift+F10进入命令提示符;

2、复制Users、ProgramData 文件夹到你想使用的分区上

robocopy "C:Users" "D:Users" /E /COPYALL /XJ
robocopy "C:ProgramData" "D:ProgramData" /E /COPYALL /XJ

请保证 0 Failed,如果不行,可以多试几次,还是不行,请自行想办法,殊途同归(比如可以在在linux下移动)。

参数解释:

/E :: 复制子目录,包括空的子目录。

/COPY:复制标记:: 要复制的文件内容(默认为 /COPY:DAT)。

                        (复制标记: D=数据,A=属性,T=时间戳)。

                        (S=安全=NTFS ACL,O=所有者信息,U=审核信息) 。

/COPYALL :: 复制所有文件信息(等同于 /COPY:DATSOU)。

/XJ :: 排除接合点(默认情况下通常包括)。

也有这种用法:

robocopy /copyall /mir /xj C:Users D:Users
robocopy /copyall /mir /xj C:ProgramData D:ProgramData

参数解释:

/mir :: 镜像目录树(等同于 /E 加 /PURGE)。

/PURGE :: 删除源中不再存在的目标文件/目录。(加入D:Users原来有数据,使用/PURGE会被删除)。

说明:windows不区分大小写,路径中没有空白字符则不需要转义或加双引号。

3、删除系统盘原文件

这里采用将原文件夹重命名的方式,一来达到了删除的效果,二来备份了原文件夹,这样万一出现问题还可恢复,确保无误后再删除也不迟。

move "C:Users" "C:Users2"
move "C:ProgramData" "C:ProgramData2"

所有步骤完成之后可以如下删除原文件夹,但现在先跳过。


rmdir "C:Users2" /S /Q rmdir "C:ProgramData2" /S /Q

参数解释:

/S: 除目录本身外,还将删除指定目录下的所有子目录和文件。用于删除目录树。

/Q: 安静模式,带 /S 删除目录树时不要求确认。

4、创建连接

mklink /J "C:Users" "D:Users"
mklink /J "C:ProgramData" "D:ProgramData"

参数解释:

Use the /J switch to create a junction that's a hard symlink. (If you use the /D switch, you'll also have to edit the registry, cuz it won't be a hard link.) 

5、继续接下来的安装即可。

方法二、安装系统后移动(推荐)

进入修复模式,打开命令提示符,按方法一步骤2,3,4操作,重启电脑即可。

下面谈谈可能会遇到的几个问题。

1、不论用哪种方法,都要确认驱动器盘符,按照方法一多硬盘时更是如此,方法二也会有问题,有时候驱动器盘符不一定和自己期望的一致。

2、在没有发生故障的情况下,win8进入修复模式有两种方法:

In Windows 8 they dropped the use of the F8 key to access the boot menu.

Now to access such menu you can hold Shift before you press Restart (so already within Windows) and you'll be presented with it after the reboot. Another way is to press "Restart now" at the general PC settings:

Boot menu:

Boot menu

Troubleshoot

Troubleshoot menu

Advanced options

Advanced options menu

选择命令提示符即可。

关于分离系统文件和用户数据的弊端:

Using this setting to redirect folders to a drive other than the system volume blocks upgrades.Using ProfilesDirectory to point to a directory that is not the system volume will block SKU upgrades and upgrades to future versions of Windows. ... The servicing stack does not handle cross-volume transactions, and it blocks upgrades.

官方文档:http://technet.microsoft.com/en-us/library/cc722177(v=WS.10).aspx

个人建议:忽略之

cite:

http://acer.it168.com/thread-1205482-1-1.html

http://lifehacker.com/5467758/move-the-users-directory-in-windows-7

http://superuser.com/questions/496493/how-do-i-access-windows-8-recovery-partition-and-how-to-recover-it-to-factory-im

http://www.zdnet.com/dont-move-your-windows-user-profiles-folder-to-another-drive-7000022142/

http://technet.microsoft.com/en-us/library/cc722177(v=WS.10).aspx

原文地址:https://www.cnblogs.com/cloud2rain/p/3462369.html