惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 衡子

Ubuntu24.04更改SSH端口 记录安装过程 - 衡子 Azure CLI创建管理员用户 创建VMSS中的instance 创建不带公网IP的VM Azure LSv3系列VM 自动挂载NVMe本地磁盘 Azure AD访问Azure Storage Azure Linux VM使用Managed Identity获取Key-vault的Secret Azure AD SSO with Google Cloud Identity 通过API获取Azure KeyVault Securet Azure Front Door添加自定义域名 VM间网络PPS和带宽测试 Azure获取access token的方法 VM间记录时延 Windows Terminal的一些配置 安装hping Azure解除不再使用Directory的关联 使用VSCode Remote Containers功能实现开发环境统一 Azure AKS容器网络详解
通过VM SWAP OS DISK升级VM
衡子 · 2022-03-01 · via 博客园 - 衡子

Azure的VM提供交换OS Disk的方式,对VM进行升级、测试等。这里介绍如何通过Azure CLI实现此功能。

一 环境准备

1  创建两台VM

两台VM如下,分别安装Apache2和Nginx

VM01: Ubuntu21.01 + Apache2

VM02: Ubuntu21.01 + Nginx

2 获取VM的相关参数

获取VM Disk的名称:

vm01diskname=$( az vm list -g switchdisk --query "[?name=='vm01']" \
   | jq -r .[].storageProfile.osDisk.name)

vm02diskname=$( az vm list -g switchdisk --query "[?name=='vm02']" \
   | jq -r .[].storageProfile.osDisk.name)

3 创建VM02 Disk Snapshot 

通过下面的命令创建VM02 Disk的Snapshot:

az snapshot create -g switchdisk -n vm02-s2 --source $vm02diskname \
   --hyper-v-generation V2

4 通过Snapshot创建新的Disk

从snapshot创建disk:

az disk create -g switchdisk -n vm02disk04 --location westus2 --zone 1 \
   --source vm02-s2 --hyper-v-generation V2

获取diskid: 

diskid=$(az disk list --query "[?name=='vm02disk04']" | jq -r .[].id)

二 交换OS Disk 

通过下面的命令交换OS Disk:

az vm update -g switchdisk -n vm01 --os-disk $diskid

可以观察到,大约1分钟左右,VM的OS更换成新的disk:

 同样,在VM的console中可以看到VM重新启动,挂载新系统:

 

三 总结

通过更换VM OS Disk的方式,可以非常方便的升级VM的系统。