Batch creation of Linux VMS with OS disk larger than 30G on Azure

Source: Internet
Author: User

The size of the OS disk for VMS on Azure is fixed at the time of creation. Windows is 127g,linux is 30G. If you need to bulk-create VMS, the OS disk has greater capacity. Consider the following method to implement.

1 Create a Data-disk CentOS VM, client, install the software, mount the disk

2 expanding the capacity of the OS disk

3 Resize OS disk capacity within the VM

4 Capture This VM as an image of azure

5 Create VMs in batches from this image. The OS disk capacity for creating VMS is the capacity just tuned

This article will implement these operations with Azure CLI 2.0:

Create a VM

1 Creating Resource Group

AZ Group Create--name hwmd--location Chinanorth

2 Creating VMS

AZ vm create-g hwmd-n hwmd01--image CentOS--authentication-type password--admin-username hengwei--admin-password xxx X--size standard_d1--storage-sku Standard_lrs

3 Mounting Data-disk

 - 1

4 SSH to this VM for customized work

Iptables-Fyuminstall -/dev//dev//etc/sysconfig/  0 Mount /dev/sdc1/var/www/html/DF -/var/www/htmlecho"  HelloWorld " >/etc/fstabMount -A

Two expansion of OS disk capacity

1 VM Downtime

AZ vm deallocate-g hwmd-n hwmd01

2 Expanding the size of the OS disk

View disk status;

AZ Disk List--o table

Enlarge the size of disk:

60

Three resize OS disk capacity in the VM

1 start VM

AZ vm start-g hwmd-n hwmd01

2 ssh to VM to delete partition, recreate partition (data is not lost)

fdisk/dev/Sdacommand (M forHelp ): uchanging display/entry units to cylinders (deprecated!). Command (M forHelp ): Pdisk/DEV/SDA:64.4GB,64424509440bytes125829120sectorsdevice Boot Start End Blocks Id System/DEV/SDA1 *1           -      512000    theLinux/dev/sda2 -        3917    30944256    theLinuxcommand (M forHelp ): dpartition number (1,2, default2):2Partition2Is Deletedcommand (M forHelp ): Npartition Type:p Primary (1Primary0Extended3  Free) e extendedselect (default p): Ppartition number (2-4, default2): First Cylinder ( --7832, default -): Using default Value -Last cylinder,+cylinders or +size{k,m,g} ( --7832, default7832): Using default Value7832Partition2of type Linux and of size59.5GiB is SetCommand (M forHelp ): Pdisk/DEV/SDA:64.4GB,64424509440bytes125829120sectors Device Boot Start End Blocks Id System/DEV/SDA1 *1           -      512000    theLinux/dev/sda2 -        7832    62397516    theLinux

At this point all the capacity is full. Restart after saving

3 Resize OS Disk

The commands for CentOS7 above machines are:

Xfs_growfs-d/dev/sda2

The CentOS6 machine commands are:

Resize2fs/dev/sda

You can see that the OS disk is already 60G in capacity.

DF -hfilesystem Size used Availuse% mountedon13/

Four capture image

1 in-VM generalization

Waagent-deprovision

2 The Azure platform to generalize VMS

AZ vm deallocate-g hwmd-g hwmd-n hwmd01

3 Capturing image

AZ image create-g hwmd--name hwmdimage--source hwmd01

Five create a VM from this image

1 Creating VMS

AZ vm create-g hwmd-n hwmd03--authentication-type password--admin-user hengwei--admin-password xxxx--image hwmdimage

2 ssh-to-VM view disk and Access scenarios

DF -hfilesystem Size used Availuse% mountedon131/var/www/ Html

You can see that the OS disk is already 60G, and the 30G disk that is mounted in the image.

Since the azure CLI automatically loads the NSG to the VM's NIC, and the Linux NSG only allows access to 22 ports, open 80 ports, or delete the NSG, to access the contents of the httpd.

You can see that the previously loaded content is also running in the new machine.

Vi. Summary

By capturing the customized VM as an image, you can easily replicate it. The customized content includes not only the installation software and user data, but also the added data disk and the expanded OS disk, which can be denied.

Batch creation of Linux VMS with OS disk larger than 30G on Azure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.