Azure主机windows2008就地升级十步

Azure上云主机的windows2008系统需要进行就地升级。

按着微软的升级路径:win2008-->win2012-->win2016-->win2022

第一步 :创建快照备份,防止升级失败
第二步 :升级托管磁盘,在VM管理的地方将磁盘升级成托管磁盘,注意此过程是不可逆的。
第三步 :创建升级介质磁盘

打开Portal上的cloud shell,结果是一片黑屏,没有任何命令行显示,切换到浏览器无痕模式重新登录,OK.

按微软提供的命令行,修改$sku = "server2012Upgrade",拷贝粘贴到了cloud shell中执行。

Customer specific parameters

Resource group of the source VM

$resourceGroup = "WindowsServerUpgrades"

Location of the source VM

$location = "WestUS2"

Zone of the source VM, if any

$zone = ""

Disk name for the that will be created

$diskName = "WindowsServer2012UpgradeDisk"

Target version for the upgrade - must be either server2022Upgrade, server2019Upgrade, server2016Upgrade or server2012Upgrade

$sku = "server2012Upgrade"

Common parameters

$publisher = "MicrosoftWindowsServer"

$offer = "WindowsServerUpgrade"

$managedDiskSKU = "Standard_LRS"

Get the latest version of the special (hidden) VM Image from the Azure Marketplace

versions = Get-AzVMImage -PublisherName publisher -Location location -Offer offer -Skus sku \| sort-object -Descending {\[version\] _.Version }

latestString = versions0.Version

Get the special (hidden) VM Image from the Azure Marketplace by version - the image is used to create a disk to upgrade to the new version

image = Get-AzVMImage -Location location -PublisherName publisher -Offer offer -Skus sku -Version latestString

Create Resource Group if it doesn't exist

if (-not (Get-AzResourceGroup -Name $resourceGroup -ErrorAction SilentlyContinue)) {

New-AzResourceGroup -Name resourceGroup -Location location

}

Create Managed Disk from LUN 0

if ($zone){

diskConfig = New-AzDiskConfig -SkuName managedDiskSKU -CreateOption FromImage -Zone zone -Location location

} else {

diskConfig = New-AzDiskConfig -SkuName managedDiskSKU -CreateOption FromImage -Location $location

}

Set-AzDiskImageReference -Disk diskConfig -Id image.Id -Lun 0

New-AzDisk -ResourceGroupName resourceGroup -DiskName diskName -Disk $diskConfig

成功创建介质

Name : WindowsServer2012UpgradeDisk

附加升级安装介质到VM,结果发现找不到这个盘,仔细比对发现,原来里面还有一个地方要修改和VM实际环境一致,$location = "WestUS",在资源中删除刚才生成的安装介质,重新运行命令创建介质。

第五步 :升级windows2012

在VM中附加安装介质盘成功。

运行安装升级:

PS E:\Windows Server 2012> .\setup.exe

安装出现问题:

提示:

1.Active Directory on this domain controller does not contain Windows Server 2012 ADPREP /FORESTPREP updates

2.These devices might not work properly in Windows. We recommend updating the drivers for these devices before you continue.

System devices: Microsoft Hyper-V S3 Cap

在E:\Windows Server 2012\resource下面没有找到ADPREP,在E:\Windows Server 2012\support\adprep>adprep /forestprep中搜索找到

E:\Windows Server 2012\support\adprep>adprep /forestprep

执行结果:

Adprep failed to verify whether schema master has completed a replication cycle

after last reboot.

Status/Consequence

The schema is not upgraded.

User Action

Check the log file ADPrep.log in the C:\Windows\debug\adprep\logs\20241217071508 directory for possible cause of failure.

Adprep encountered an LDAP error.

Error code: 0xc. Server extended error code: 0x20ae, Server error message: 00002

0AE: SvcErr: DSID-032103B3, problem 5010 (UNAVAIL_EXTENSION), data 8610

User Action

Check the log file ADPrep.log in the C:\Windows\debug\adprep\logs\20241217071508 directory for possible cause of failure.

2024/12/17:07:15:47.833

Adprep encountered an LDAP error.

Error code: 0xc. Server extended error code: 0x20ae, Server error message: 000020AE: SvcErr: DSID-032103B3, problem 5010 (UNAVAIL_EXTENSION), data 8610

第六步 :清除域控DC的垃圾信息

最后发现adprep /forestprep失败的原因是此前有辅助域控离线后没有清理导致的。
ntdsutil:metadata cleanup删除了另外一台DC的残余信息

第七步 :安装更新windows 2012

adprep /forestprep执行成功

再次执行win2012安装,又出现错误提示需要执行:ADPREP /DOMAINPREP

执行后通过,提示新错误:Windows Setup cannot locate a valid hard drive to store temporary installation files. To install Windows, create more free space on the hard drive or add a new hard drive.

原因是C盘的磁盘空间不够导致。删除没有的文件腾出了空间,进入到了更新界面,collecting files,settings, and applications 等待很久,直到成功更新。

第八步 :制作windows2016安装盘,升级到windows2016

卸载windows2012的安装盘,执行第三步创建2016的安装介质,注意修改$sku = "server2016Upgrade"

VM中挂载的安装介质,执行更新:

PS G:\Windows Server 2016> .\setup.exe /auto upgrade /dynamicupdate disable /eula accept

发现磁盘空间不足,需要清理调windows.old

--安装磁盘清理工具

Import-Module ServerManager

Install-WindowsFeature Desktop-Experience

清理空间后再次执行安装更新。

第九步 :升级window2022

重复第八步的动作升级到2022

PS G:\Windows Server 2022> .\setup.exe /auto upgrade /dynamicupdate disable /eula accept

第十步 :转原来的Blob vhd磁盘到托管磁盘

原来主机挂载的数据盘是非托管的blob存储,现在主机转换成了托管磁盘后,原来的这些非托管磁盘无法挂载到主机了,托管的主机也不能回退到非托管主机,怎么办?

VM里面blob磁盘转托盘磁盘很简单,但是这些分离掉的blob存储盘转托管磁盘却找不到地方。

找了半天资料,最后终于找到了方案,那就是用blob的vhd创建一个托管磁盘:

所有服务--Disks--新建磁盘:资源组需要选和VM一致的,选择磁盘类型,源选择存储blob, OS选择windows,VM选择第一代,x64,创建成功。

在VM上附加磁盘就可以找到新创建的磁盘添加。

相关推荐
学Linux的语莫15 分钟前
python中类的常见写法
开发语言·python·状态模式
武子康27 分钟前
撤回发生在重建途中,旧索引还能切回来吗
人工智能·后端·agent
码事漫谈1 小时前
双十一,我为什么想买一台编码显示器
后端
垆边人似月.1 小时前
Python中如何使用get函数实现频次查询
服务器·前端·python
AI 编程助手GPT1 小时前
GPT 脚本别只发一个文件:用 uv 把依赖和锁一起交付
人工智能·python·gpt·uv·依赖管理
喵个咪1 小时前
GoWind Kanban 拆解:看板拖拽背后——LexoRank、乐观锁与尽力而为广播
后端·架构·go
喵个咪1 小时前
GoWind OA 拆解:用 3000 行 Go 写一个够用的审批工作流引擎
后端·架构·go
喵个咪2 小时前
GoWind Ledger 拆解:单式记账的余额一致性——confirm、补偿,以及没进事务的那些缝隙
后端·架构·go
Patrick在香港2 小时前
第 16,216 次连接之后,它不干了
python·网络编程·socket·tcp·连接池
喵个咪2 小时前
GoWind Shop 拆解:订单超时关单——一个事务里的四联动
后端·架构·go