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

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


 

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

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

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

方法1、安装系统时移动this

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

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

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

请保证 0 Failed,若是不行,能够多试几回,仍是不行,请自行想办法,异曲同工(好比能够在在linux下移动)。htm

参数解释:blog

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

/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不区分大小写,路径中没有空白字符则不须要转义或加双引号。

三、删除系统盘原文件

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

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

全部步骤完成以后能够以下删除原文件夹,但如今先跳过。


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

参数解释:

/S: 除目录自己外,还将删除指定目录下的全部子目录和文件。用于删除目录树。

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

四、建立链接

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.) 

五、继续接下来的安装便可。

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

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

 

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

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

二、在没有发生故障的状况下,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