简体   繁体   English

如何增加Azure VM的硬盘大小

[英]How to increase harddisk size of Azure VM

I am using Azure VM which is of type RHEL OS type. 我正在使用类型为RHEL OS类型的Azure VM。 Currently I am using Standard D3 v2 size VM. 当前,我正在使用标准D3 v2大小的VM。 I see only 32 hard disk storage available in VM. 我在VM中仅看到32个硬盘存储空间。 How do I increase the size of hard disk? 如何增加硬盘大小?

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        32G   32G  185M 100% /
devtmpfs        6.9G     0  6.9G   0% /dev
tmpfs           6.9G     0  6.9G   0% /dev/shm
tmpfs           6.9G  8.4M  6.9G   1% /run
tmpfs           6.9G     0  6.9G   0% /sys/fs/cgroup
/dev/sda1       497M  117M  381M  24% /boot
/dev/sdb1       197G  2.1G  185G   2% /mnt/resource
tmpfs           1.4G     0  1.4G   0% /run/user/1000

Note: I am using unmanaged disk. 注意:我正在使用非托管磁盘。

If your Virtual Machine was created using the Azure Resource Manager (ARM) you can resize the OS disk or the data disk within the new Azure Portal. 如果您的虚拟机是使用Azure资源管理器(ARM)创建的,则可以在新Azure门户中调整OS磁盘或数据磁盘的大小。

  1. Navigate to the Azure Resource Manager Virtual Machine that you want to resize the disk(s). 导航到要调整磁盘大小的Azure资源管理器虚拟机。
  2. Shutdown the Virtual Machine from the Azure portal. 从Azure门户关闭虚拟机。 Wait untill it's completely shutdown (de-allocated). 等到它完全关闭(取消分配)。
  3. Select 'Disks' in the Settings blade (As in the below image). 在“设置”边栏选项卡中选择“磁盘”(如下图所示)。

Disks settings blade 磁盘设置刀片

  1. Select the OS or Data disk that you would like to resize. 选择要调整大小的操作系统或数据磁盘。
  2. On the new blade, enter the new disk size (1023GB or 1TB max per disk) (As in the below image). 在新刀片上,输入新磁盘大小(每个磁盘1023GB或最大1TB)(如下图所示)。

Change disk size 更改磁盘大小

  1. Hit 'Save' on top. 点击顶部的“保存”。
  2. Start the Virtual Machine again. 再次启动虚拟机。

That's it! 而已! You can login to the VM and check that you have the new selected size for the disk(s). 您可以登录到VM,并检查磁盘是否具有新选择的大小。

So basically follow this article: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/expand-disks 因此,基本上请遵循以下文章: https : //docs.microsoft.com/zh-cn/azure/virtual-machines/linux/expand-disks

az vm deallocate --resource-group myResourceGroup --name myVM
az disk list \
    --resource-group myResourceGroup \
    --query '[*].{Name:name,Gb:diskSizeGb,Tier:accountType}' \
    --output table
az disk update \
    --resource-group myResourceGroup \
    --name myDataDisk \
    --size-gb 200
az vm start --resource-group myResourceGroup --name myVM

for unmanaged disks: 对于非托管磁盘:
https://blogs.msdn.microsoft.com/cloud_solution_architect/2016/05/24/step-by-step-how-to-resize-a-linux-vm-os-disk-in-azure-arm/ https://blogs.msdn.microsoft.com/cloud_solution_architect/2016/05/24/step-by-step-how-to-resize-a-linux-vm-os-disk-in-azure-arm/

According to your description, I test in my lab, I test on Red Hat Enterprise Linux Server release 7.3 (Maipo) . 根据您的描述,我在实验室中进行了测试,并且在Red Hat Enterprise Linux Server release 7.3 (Maipo)

Notes: When you don it, I strongly suggest you could backup your OS VHD. 注意:当您这样做时,强烈建议您可以备份OS VHD。 If you do fails, you could not start your VM. 如果失败,则无法启动VM。

1.Stop your VM on Azure Portal. 1.在Azure Portal上停止VM。

2.Increase OS disk with Azure CLI. 2.使用Azure CLI增加OS磁盘。

az vm update -g shui -n shui --set storageProfile.osDisk.diskSizeGB=100

3.Start your VM and ssh to your VM. 3.启动您的VM并SSH到您的VM。 You could check df -h and fdisk -l . 您可以检查df -hfdisk -l /dev/sda2 does not increase to 100GB. /dev/sda2不会增加到100GB。 You need do as the following commands. 您需要执行以下命令。

sudo -i

[root@shui ~]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001461e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        3917    30944256   83  Linux

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): p

Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001461e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2         1026048    62914559    30944256   83  Linux

Command (m for help): d
Partition number (1-4): 1

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-104857599, default 63): 64
Last sector, +sectors or +size{K,M,G} (64-1026047, default 1026047): 
Using default value 1026047

Command (m for help): p

Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001461e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              64     1026047      512992   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2         1026048    62914559    30944256   83  Linux

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@shui ~]# fdisk -l /dev/sda

Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001461e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          64      512992   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        3917    30944256   83  Linux

4.Reboot your VM 4,重启虚拟机

5.SSH to your VM and resize the filesystem. 5.SSH到您的VM并调整文件系统大小。

xfs_growfs -d /dev/sda2

Now, you could check your OS disk with df -h 现在,您可以使用df -h检查操作系统磁盘

[root@shui ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       100G  1.7G   98G   2% /

Use below link to resize the azure Ubuntu and RHEL servers OS disks. 使用下面的链接来调整Azure和Ubuntu RHEL服务器操作系统磁盘的大小。 9 Easy Steps To Increase Your Root Volume Of AZURE Instance 9个简单步骤来增加AZURE实例的根目录数量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM