Prerequisites
Install an Ubuntu Linux operating
system to a virtual hard disk.
Ubuntu installation notes:
- The VHDX format is not supported in Azure, only fixed VHD. You can convert the disk to VHD format using Hyper-V Manager or the convert-vhd cmdlet.
- When installing the Linux system, it is recommended that you use standard partitions rather than LVM (often the default for many installations). This will avoid LVM name conflicts with cloned VMs, particularly if an OS disk ever needs to be attached to another VM for troubleshooting. LVM or RAID may be used on data disks if preferred.
- Do not configure a swap partition on the OS disk. The Linux agent can be configured to create a swap file on the temporary resource disk. More information about this can be found in the steps below.
- All of the VHDs must have sizes that are multiples of 1 MB.
STEPS:
1. In the center pane of Hyper-V Manager, select
the virtual machine.
2.
Click Connect to open the
window for the virtual machine.
3.
Replace the
current repositories in the image to use Ubuntu's Azure repos. The steps vary
slightly depending on the Ubuntu version.
Before
editing /etc/apt/sources.list, it is recommended to make a backup:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
#sudo sed -i
"s/[a-z][a-z].archive.ubuntu.com/azure.archive.ubuntu.com/g"
/etc/apt /sources.list
sudo apt-get update
4.
Update the operating system to the
latest kernel by running the following commands:
# sudo apt-get update
# sudo apt-get install linux-image-virtual
(recommended) sudo apt-get dist-upgrade
Once all the
above necessary packages were install, make sure to reboot your Linux box
# sudo reboot
5.
Modify the kernel boot line for Grub
to include additional kernel parameters for Azure. To do this open
"/etc/default/grub" in a text editor, find the variable called GRUB_CMDLINE_LINUX_DEFAULT
(or add it if needed) and edit it to include the following parameters:
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0,115200n8 earlyprintk=ttyS0,115200 rootdelay=300"
Save and close this
file, and then run 'sudo update-grub'. This will ensure all console messages
are sent to the first serial port, which can assist Azure technical support
with debugging issues.
#sudo update-grub
6. Ensure that the SSH server is
installed and configured to start at boot time. This is usually the default.
7. Install the Azure Linux Agent:
# sudo apt-get update
# sudo apt-get install walinuxagent
Note: Installing the walinuxagent package will remove the NetworkManager and NetworkManager-gnome
packages, if they are installed.
8. The Azure Linux Agent can
automatically configure swap space using the local resource disk that is
attached to the VM after provisioning on Azure. Note that the local resource
disk is a temporary-disk, and might be emptied when the VM is
deprovisioned.
After installing the Azure Linux Agent (see previous step),
modify the following parameters in /etc/waagent.conf appropriately:
#vi
/etc/waagent.conf
ResourceDisk.Format=y
ResourceDisk.Filesystem=ext4
ResourceDisk.MountPoint=/mnt/resource
ResourceDisk.EnableSwap=y
ResourceDisk.SwapSizeMB=2048
##
NOTE: set this to whatever values you need it to be.
9. Run the following commands to deprovision the virtual
machine and prepare it for provisioning on Azure:
sudo waagent -force -deprovision
export HISTSIZE=0
logout / exit
10. Click Action -> Shut Down
in Hyper-V Manager. Your Linux VHD is now ready to be uploaded to Azure.
You're now
ready to use your Ubuntu Linux virtual hard disk to create new virtual machines
in Azure.
No comments:
Post a Comment