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 = versions[0].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上附加磁盘就可以找到新创建的磁盘添加。

相关推荐
林夕11201 分钟前
颠覆认知的MySQL全解析:安装、连接到SQL三大核心语句全掌握
后端·mysql
QMT量化交易22 分钟前
如何解决PyQt从主窗口打开新窗口时出现闪退的问题
python·pyqt
databook31 分钟前
『Plotly实战指南』--样式定制高级篇
python·数据分析·数据可视化
Java中文社群1 小时前
最火向量数据库Milvus安装使用一条龙!
java·人工智能·后端
basketball6161 小时前
Python torchvision.transforms 下常用图像处理方法
开发语言·图像处理·python
JAVA百练成神1 小时前
深度理解spring——BeanFactory的实现
java·后端·spring
兔子蟹子2 小时前
Java集合框架解析
java·windows·python
宁酱醇2 小时前
各种各样的bug合集
开发语言·笔记·python·gitlab·bug
古时的风筝2 小时前
暴论:2025年,程序员必学技能就是MCP
前端·后端·mcp
古时的风筝2 小时前
这编程圈子变化太快了,谁能告诉我 MCP 是什么
前端·后端·mcp