Azure VHD utilities.
Перейти к файлу
microsoft-github-policy-service[bot] 7c30a3748a
Auto merge mandatory file pr
This pr is auto merged as it contains a mandatory file and is opened for more than 10 days.
2023-06-13 17:53:15 +00:00
.vscode using Mb for n/w throughput instead of MB 2016-11-25 17:12:53 -08:00
upload Setting MD5 hash as VHD properties on upload completion, If some blocks failed to upload let user know that they can resume upload process that uploads only missing blocks 2016-11-26 21:02:00 -08:00
vhdcore Modernizing Go Stack (#54) 2018-11-14 17:09:04 -08:00
.gitignore Modernizing Go Stack (#54) 2018-11-14 17:09:04 -08:00
.travis.yml Modernizing Go Stack (#54) 2018-11-14 17:09:04 -08:00
LICENSE This is the first commit of 'Azure VHD Utilities for Go'. The tool supports uploading Dynamic, Differencing and Fixed VHDs to Azure blob storage. Tool also supports inspecting various segements of VHD (header, footer, BAT, blocks, block-bitmap). 2016-03-03 19:13:23 -08:00
Makefile Modernizing Go Stack (#54) 2018-11-14 17:09:04 -08:00
README.md Modernizing Go Stack (#54) 2018-11-14 17:09:04 -08:00
SECURITY.md Microsoft mandatory file 2023-06-02 21:20:57 +00:00
go.mod Modernizing Go Stack (#54) 2018-11-14 17:09:04 -08:00
go.sum Modernizing Go Stack (#54) 2018-11-14 17:09:04 -08:00
vhd.go vendoring the dependencies 2016-11-25 18:06:06 -08:00
vhdInspectCmdHandler.go Modernizing Go Stack (#54) 2018-11-14 17:09:04 -08:00
vhdUploadCmdHandler.go Setting MD5 hash as VHD properties on upload completion, If some blocks failed to upload let user know that they can resume upload process that uploads only missing blocks 2016-11-26 21:02:00 -08:00

README.md

Azure VHD utilities.

This project provides a Go package to read Virtual Hard Disk (VHD) file, a CLI interface to upload local VHD to Azure storage and to inspect a local VHD.

An implementation of VHD VHD specification can be found in the vhdcore package.

Go Report Card

Installation

Note: You must have Go installed on your machine, at version 1.11 or greater. https://golang.org/dl/

go get github.com/Microsoft/azure-vhd-utils

Features

  1. Fast uploads - This tool offers faster uploads by using multiple routines and balancing the load across them.
  2. Efficient uploads - This tool will only upload used (non-zero) portions of the disk.
  3. Parallelism - This tool can upload segements of the VHD concurrently (user configurable).

Usage

Upload local VHD to Azure storage as page blob

USAGE:
   azure-vhd-utils upload [command options] [arguments...]

OPTIONS:
   --localvhdpath       Path to source VHD in the local machine.
   --stgaccountname     Azure storage account name.
   --stgaccountkey      Azure storage account key.
   --containername      Name of the container holding destination page blob. (Default: vhds)
   --blobname           Name of the destination page blob.
   --parallelism        Number of concurrent goroutines to be used for upload

The upload command uploads local VHD to Azure storage as page blob. Once uploaded, you can use Microsoft Azure portal to register an image based on this page blob and use it to create Azure Virtual Machines.

Note

When creating a VHD for Microsoft Azure, the size of the VHD must be a whole number in megabytes, otherwise you will see an error similar to the following when you attempt to create image from the uploaded VHD in Azure:

"The VHD http://.blob.core.windows.net/vhds/.vhd has an unsupported virtual size of bytes. The size must be a whole number (in MBs)."

You should ensure the VHD size is even MB before uploading

For virtual box:

VBoxManage modifyhd --resize <size in MB>

For Hyper V:

Resize-VHD -Path -SizeBytes

 http://azure.microsoft.com/blog/2014/05/22/running-freebsd-in-azure/
For Qemu:

qemu-img resize <path-to-raw-file> size

 http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-create-upload-vhd-generic/

How upload work

Azure requires VHD to be in Fixed Disk format. The command converts Dynamic and Differencing Disk to Fixed Disk during upload process, the conversion will not consume any additional space in local machine.

In case of Fixed Disk, the command detects blocks containing zeros and those will not be uploaded. In case of expandable disks (dynamic and differencing) only the blocks those are marked as non-empty in the Block Allocation Table (BAT) will be uploaded.

The blocks containing data will be uploaded as chunks of 2 MB pages. Consecutive blocks will be merged to create 2 MB pages if the block size of disk is less than 2 MB. If the block size is greater than 2 MB, tool will split them as 2 MB pages.

With page blob, we can upload multiple pages in parallel to decrease upload time. The command accepts the number of concurrent goroutines to use for upload through parallelism parameter. If the parallelism parameter is not proivded then it default to 8 * number_of_cpus.

Inspect local VHD

A subset of command are exposed under inspect command for inspecting various segments of VHD in the local machine.

USAGE:
   azure-vhd-utils inspect footer [command options] [arguments...]

OPTIONS:
   --path   Path to VHD.

Show VHD header of an expandable disk

USAGE:
   azure-vhd-utils inspect header [command options] [arguments...]

OPTIONS:
   --path   Path to VHD.

Only expandable disks (dynamic and differencing) VHDs has header.

Show Block Allocation Table (BAT) of an expandable disk

USAGE:
   azure-vhd-utils inspect bat [command options] [arguments...]

OPTIONS:
   --path           Path to VHD.
   --start-range    Start range.
   --end-range      End range.
   --skip-empty     Do not show BAT entries pointing to empty blocks.

Only expandable disks (dynamic and differencing) VHDs has BAT.

Show block general information

USAGE:
   azure-vhd-utils inspect block info [command options] [arguments...]

OPTIONS:
   --path   Path to VHD.

This command shows the total number blocks, block size and size of block sector

Show sector bitmap of an expandable disk's block

USAGE:
   azure-vhd-utils inspect block bitmap [command options] [arguments...]

OPTIONS:
   --path           Path to VHD.
   --block-index    Index of the block.
   

License

This project is published under MIT License.