บทนำ
User Profile Disks (UPD) เป็น Feature ใหม่ของ Remote Desktop Services ใน Windows Server 2012 UPD เป็น Alternative ของ Roaming Profiles และ Folder Redirection ใน RDS Scenarios จุดมุ่งหมายของ UPD คือ User และ Apps Data (User Profile) จัดเก็บเป็น VHDX Disk แยกต่างหากบน Network Shared Folder Dedicated Virtual Disk นี้จะ Mount เข้า User Session ทันทีที่ User Sign-in เข้า RDS Server และ Unmount เมื่อ Logout (การเปลี่ยนแปลงทั้งหมดของ User Profile จะบันทึกลง VHDX Disk)
บทความนี้อธิบายวิ้งตั้งค่าและใช้ User Profile Disks บน Server ที่มี Remote Desktop Services Role รัน Windows Server 2012 / 2012 R2 / 2016
การตั้งค่า User Profile Disks บน Windows Server RDS
สร้าง Shared Folder บน Corporate File Server ใดๆ เพื่อจัดเก็บ User Profiles เป็น VHDX Disk (หากต้องการ High Availability สำหรับ UPD Disks วาง UPD Files บน Clustered File Resource) ตัวอย่าง Path: \\rdvh1\DemoLabOficeApp เซิร์ฟเวอร์ที่เป็นส่วนของ RDS Collection ต้องได้รับ Full Access Permission เข้าถึง Shared Folder นี้
Tip: ใน Single RDS Collection มีเพียง 1 VHDX Profile File ต่อ 1 User หาก User เชื่อมต่อจาก 2 Collections ต่างกัน ควรสร้าง Profile Disk แยกสำหรับแต่ละ Collection
UPD Mode Enable และ Config ได้ใน Collection Settings ของ Remote Desktop Services สามารถ Enable ตอนสร้าง Collection ใหม่ หรือกลับมาตั้งค่าภายหลังได้
- ใน Server Manager Console เลือก Collection ที่มีอยู่ → มุมซ้ายบน Tasks → Edit Properties
- ใน Section User Profile Disks Check Enable user profile disks ระบุ Path ของ Shared Folder ที่สร้างไว้ (\\rdvh1\DemoLabOficeApps) และ Max Profile Disk Size (ตัวอย่าง 20 GB) → Save Changes
- หลัง Save ตรวจสอบ NTFS Permissions ของ Profile Disks Folder เปลี่ยนไปแล้ว ในตัวอย่าง Collection มี RDSH01 Server เดียว ได้ Full Control Permission
- Full Control Permission ถูก Grant ให้ RDSH01 Server บน Shared Folder Level
หมายเหตุ: เมื่อเพิ่ม RD Session Host Servers ใหม่เข้า RDS Collection Wizard จะเปลี่ยน Folder Permissions อัตโนมัติและให้ Access เซิร์ฟเวอร์ใหม่ สะดวกมาก เพราะไม่ต้องจำตั้งค่า Permissions สำหรับ Profile Folder ตอน Scale Terminal Farm
UPD: User Profile เป็น VHDX File
ไปที่ Network Shared Folder ที่เก็บ User Profiles จะมีไฟล์ UVHD-template.vhdx อยู่
ไฟล์นี้คือ User Profile Disk Template เมื่อ User Login เข้า RDS Server ครั้งแรก Template จะถูก Copy และ Rename เป็น VHDX File ที่มี User SID ในชื่อไฟล์
Tip: เพื่อ Match UPD File Name กับ User Name ต้องใช้ Script แยก เช่น ShowUPDFolderDetails.ps1 หรือ Convert SID เป็น Account Name ด้วย Get-ADUser Cmdlet: Get-ADUser -Identity S-1-5-21-32549751-3956249758-2943215497-23733695
ดูว่า User Profile Disk มีอะไรบ้าง: Right-click VHDX File → Mount UPD Disk ใช้ได้ใน Session เดียวบน RDS Host เดียว (Exclusive Access) ไม่สามารถ Mount UPD VHDX ได้หาก User กำลังใช้งานอยู่บน RDS Server
VHDX Disk มีชุด Folders และ Files ของ Standard User Profile ตอน Logon User ได้ Access ข้อมูลใน Profile อย่าง Transparent
ฝั่ง RD Session Host Server ไฟล์ .vhdx ของ User ถูก Mount ที่ C:\users\<username> และแสดงแบบนี้:
หมายเหตุ: UPD Drive ผูกกับ RDS Server Windows OS Version ไม่สามารถ Transfer (ใช้) UPD User Profile จาก RDS Server Version หนึ่งไปอีก Version ได้
Data เขียนลง VHDX File แบบ Real-time หมายความว่า Copy Data เข้า User Profile บน RDS Server ขนาด VHDX File บน Shared Storage จะเพิ่มขึ้นทันที
หาก User Profile Folder มีอยู่ในระบบแล้ว Folder เก่าจะ Rename เป็น <username>-BACKUP-<number>
VHDX Disk Mount ตอน User Session เริ่มบน VDI หรือ RDS Server รายการ Connected UPD Disks ดูได้ด้วย Utility mountvol
โดย Default UPD มี User Profile Contents ทั้งหมด แต่สามารถ Exclude โฟลเดอร์บางส่วนจาก Synchronized Directories ใน RDS Collection Settings หรือระบุว่าแค่โฟลเดอร์ไหนต้องบันทึกได้
การ Resize User Profile Disks ด้วย PowerShell
ขยาย Virtual VHDX Drive ที่มี User UPD Profile ด้วย PowerShell Cmdlet Resize-VirtualDisk จาก Hyper-V Module
Net use U: \\rdvh1\DemoLabOficeApps
Resize-VHD -Path u:\UVHD-<SID>.vhdx -SizeBytes 40GB
Net use U: /delete
หากรัน Resize-VHD Cmdlet จาก Windows 10 Desktop ต้อง Install Feature Hyper-V → Hyper-V Platform → Hyper-V Services
จากนั้น Extend Volume จาก GUI ของ Disk Management Console (Action → Attach VHD → Extend Volume)
หรือใช้ PowerShell Script ต่อไปนี้เพื่อ Extend VHDX File ไปที่ Max Available Size อัตโนมัติ:
<#
.Synopsis
This script extend size of VHDX file and resize the disk partition to Max
#>
Param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[alias("Path")]
[string]$vhdxFile,
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[alias("Size")]
[int64]$vhdxNewSize
)
begin{
try {
Mount-VHD -Path $vhdxFile -ErrorAction Stop
}
catch {
Write-Error "File $vhdxFile is busy"
Break
}
$vhdx = Get-VHD -Path $vhdxFile
if ($vhdx.Size -ge $vhdxNewSize){
Write-Warning "File $vhdxFile already have this size!"
$vhdx | Dismount-VHD
Break
}
}
process{
Dismount-VHD -Path $vhdxFile
Resize-VHD -Path $vhdxFile -SizeBytes $vhdxNewSize
$vhdxxpart = Mount-VHD -Path $vhdxFile -NoDriveLetter -Passthru | Get-Disk | Get-Partition
$partsize = $vhdxxpart | Get-PartitionSupportedSize
$vhdxxpart | Resize-Partition -Size $partsize.SizeMax
}
end{
Dismount-VHD -Path $vhdxFile
}
หมายเหตุ: ไม่สามารถ Extend User UPD Disk ได้หากมี Active RDS Session
ลดขนาด UPD File (สมมติ Delete User Data ภายใน VHDX และ File Size บน Disk น้อยกว่า Size ที่ Assign) ใช้คำสั่ง:
resize-VHD \\rdvh\DemoLabOficeApps\UVHD-<SID>.vhdx –ToMinimumSize
Optimize-vhd -path \\rdvh1\DemoLabOficeApps\UVHD-<SID>.vhdx -mode full
สรุปและข้อควรระวัง
เราได้อธิบายรายละเอียดหลักของ User Profile Disks ใน RDS/VDI Solutions บน Windows Server 2016 และ 2012 R2 UPD Configuration ง่ายกว่า Roaming Profiles หรือ Redirected Files มาก Disks เชื่อมต่อกับ RDS Collection ไม่เสียหายจากการใช้ Shared Profile โดยหลาย Servers (ต่างจาก Standard Profiles) User Profile Disks จัดเก็บได้ใน SMB Shares, CSV, SOFS, SAN หรือ Local Disks Microsoft ระบุว่า Speed ของการ Load User Desktop Environment ในกรณีใช้ UPD ลดลง
หากวางแผนจัดเก็บ UPD Profiles บน DFS Servers ต้องมี Windows Server 2012 R2 Installed รุ่นก่อนจะได้ Error:
Unable to enable user disks on rVHDShare. Could not create template VHD. Error Message: The network location "\\woshub.com\namespace\UserProfileDisk" is not available.
ควรใช้ SMB 3.02 บน File Server Side (Windows Server 2012 R2) หรือใหม่กว่า
โดยรวม เนื่องจาก UPD เป็นเทคโนโลยีที่ใหม่ค่อนข้าง แนะนำให้ Test การทำงานและปัญหาที่อาจเกิดขึ้นใน Test Environment ก่อน Production Implementation