05 Feb

Create SWAP partition – Azure Linux Virtual Machine

Create SWAP partition – Azure Linux Virtual Machine

The swap partition created using the standard methods may not persist after a machine reboot, for a linux virtual machine hosted in Microsoft Azure environment. The Microsoft Azure provide the option to create SWAP partition – Azure Linux Virtual Machine,  using the /dev/sdb partition and WAAGENT service.  The  WAAGENT service is an Azure Linux agent for Microsoft Azure environment and will be present in Azure Linux virtual machines by default on each VM. The /dev/sdb partition is a volatile partition(similar to RAM). The data stored in this partition will be lost after each machine reboot. So we can make use of this partition as our swap partition.

To enable the swap in Azure linux VM, you need to do edit the file, that is located at /etc/waagent.conf. Look for the below two lines,

Change the ResourceDisk.EnableSwap=y and ResourceDisk.SwapSizeMB=10240, the value 10240 = 10GB. This will create a /swapfile in the resource disk and persistent system swap space will be created. By default the resource disk in an Azure Virtual Machine will be /mnt/resource(/dev/sdb)

After the change is made, please unmount /mnt and restart the waagent service.

To unmount /mnt, please execute the below command,

Once the /mnt is unmounted, please execute the below command to restart the WAAGENT service.

For Ubuntu,please execute the below command,

For CoreOS, please execute the command,

For other linux distributions, please execute the command,

https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-agent-user-guide

 

04 Feb

Extend Microsoft Azure Data Disk & OS Disk

Extend Microsoft Azure Data Disk & OS Disk

To extend Microsoft Azure Data Disk & OS Disk,  the Powershell method can be used for both Classic and ARM models. By default, the OS disk will be 30 GB for Virtual Machines, which may not be sufficient as the ore data is started to get saved into the OS drive.

Extend Data Disk using Powershell – Classic Mode

To extend a Data disk in an Azure Virtual Machine in Classic Mode, we need to perform the below steps,

  1. Open the Windows Powershell ISE and execute the below script

Extend Data Disk using powershell – ARM Mode

To extend a Data disk in an Azure Virtual Machine in ARM Mode, we need to perform the below steps,

  1. Open the Windows Powershell ISE and execute the below script

Extend OS Disk using Powershell – Classic Mode

To extend a OS disk in an Azure Classic Mode Virtual Machine, we need to perform the below steps,

Open the Windows Powershell ISE and execute the below script

Extend OS Disk using Powershell – ARM Mode

To extend a OS disk in an Azure ARM mode Virtual Machine, we need to perform the below steps,

Open the Windows Powershell ISE and execute the below script

Extend the File System Volume of Extended Data or OS Disk – Windows

Once the data disk is extended, the next step is to extend the file system volume on that data disk. For Windows based virtual machines, You can do the volume extension from Server Manager -> Tools -> Computer Management -> Disk Management

Step 1. Open the Server Manager Window

Extend Microsoft Azure Data Disk & OS Disk

Step 2 : Click Tools and then click Computer Management

Extend Microsoft Azure Data Disk & OS Disk

It will open up a window similar to the below picture. Click the Disk Management menu. It will list all the available volumes.

Extend Microsoft Azure Data Disk & OS Disk

Select the Volume, that you wish to extend. Right click the volume to open the menu. Click the Extend Volume option.

Extend Microsoft Azure Data Disk & OS Disk

Click Next button as shown below

Extend Microsoft Azure Data Disk & OS Disk

Then select the size as shown below. Here, we are using a sample volume to extend. So we are extending by 397 MB. After the size is selected, click “Next

Extend Microsoft Azure Data Disk & OS Disk

Now click “Finish” to complete the volume resize.

Extend Microsoft Azure Data Disk & OS Disk

Now you will see the extended volume under Disk Management.
Extend Microsoft Azure Data Disk & OS Disk

https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-expand-os-disk

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/

22 Jan

Error : Hyper-V cannot installed. hypervisor already running

Error : Hyper-V cannot installed. hypervisor already running

When you try to install Hyper-V role on a VM, you may face the error message “Hyper-V cannot installed. hypervisor already running”.

Hyper-V cannot installed. hypervisor already running

To resolve this issue, you may need to run the below commands,

Try installing the Hyper-V feature using the below command,

1
Enable-WindowsOptionalFeature –Online -FeatureName Microsoft-Hyper-V –All -NoRestart 

Hyper-V cannot installed. hypervisor already running

Hyper-V cannot installed. hypervisor already running

Next step is to install the RSAT-Hyper-V Tools. To install the Hyper-V RSAT tools, please execute the below command.

1
Install-WindowsFeature RSAT-Hyper-V-Tools -IncludeAllSubFeature


Hyper-V cannot installed. hypervisor already running

If you wish to enable the clustering, then you need to install the RSAT-Clustering also.

1
Install-WindowsFeature RSAT-Clustering -IncludeAllSubFeature

Hyper-V cannot installed. hypervisor already running
Hyper-V cannot installed. hypervisor already running

To install the MPIO in your server, please execute the below command,

1
Install-WindowsFeature Multipath-IO


Hyper-V cannot installed. hypervisor already running
Hyper-V cannot installed. hypervisor already running

To know more about the MPIO, refer the link https://technet.microsoft.com/en-us/library/ee619734(v=ws.10).aspx

To know more about the MPIO usage, please refer the link, https://blogs.msdn.microsoft.com/san/2012/07/20/managing-mpio-with-windows-powershell-on-windows-server-2012/

Now we need to restart the server once. To restart the server, please execute the below command,

1
Restart-Computer

Hyper-V cannot installed. hypervisor already running

After the server restart, please verify the Hyper-V installation. In the server manager, you will be able to see the Hyper-V installed. Open the Hyper-V manager to start your LAB setup.Hyper-V cannot installed. hypervisor already runningHyper-V cannot installed. hypervisor already running

22 Jan

Windows package manager Chocolatey, installation using Powershell

Windows package manager Chocolatey, installation using Powershell

Here, we are discussing about the Windows package manager Chocolatey, installation using powershell. To start the installation process, open the Windows Powershell ISE in your machine, and type the command,

1
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex 

Windows package manager Chocolatey, installation using Powershell

If you are getting the error “running scripts is disabled in this system“, please follow the below steps.

Open the Windows Powershell ISE as “Administrator” using the “Run as Administrator” option. Once you have opened the  Windows Powershell ISE as “Administrator“, please proceed to execute the below command,

1
Set-ExecutionPolicy RemoteSigned

Windows package manager Chocolatey, installation using Powershell

Press “Yes to All“, if you wish to allow the script execution permanently.

Once the script is executed, please run the installation command once again,

1
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex

Windows package manager Chocolatey, installation using Powershell

To upgrade the windows package manager, “Chocolatey“, please run the command,

1
choco upgrade chocolatey

Windows package manager Chocolatey, installation using Powershell

You can read more about the package manager installation from the official Chocolatey page, https://chocolatey.org/docs/installation

15 Jan

Install Microsoft Azure Linux Agent – WAAGENT

Install Microsoft Azure Linux Agent – WAAGENT

To install Microsoft Azure Linux Agent – WAAGENT, it is required to meet two requirements.

  1. SSH access should be working against the Azure virtual machine.
  2. VM should be running.

To install the package in CentOS, please execute the below command,

1
sudo yum install waagent

To install the package in Ubuntu, please execute the below command,

1
sudo apt-get install walinuxagent

If you couldn’t install the linux agent by following the above steps, please proceed with manual installation as given below,

Download Microsoft Azure Linux Agent – WAAGENT

To download Microsoft Azure Linux Agent 2.0.x, please execute,

1
2
3
4
5
wget wget https://github.com/Azure/WALinuxAgent/archive/WALinuxAgent-2.0.<version>.zip

unzip WALinuxAgent-2.0.<version>.zip

cd WALinuxAgent-[version]

Example

1
2
3
4
5
wget https://github.com/Azure/WALinuxAgent/archive/WALinuxAgent-2.0.16.zip

unzip WALinuxAgent-2.0.16.zip

cd WALinuxAgent-2.0.16

Refer : https://github.com/Azure/WALinuxAgent/releases

To download the latest version,

1
2
3
4
5
wget wget https://github.com/Azure/WALinuxAgent/archive/v2.x.x.zip

unzip v2.x.x.zip

cd v2.x.x

Example

1
2
3
4
5
wget https://github.com/Azure/WALinuxAgent/archive/v2.2.2.zip

unzip v2.2.2.zip

cd v2.2.2

Refer : https://github.com/Azure/WALinuxAgent/releases

Install Microsoft Azure Linux Agent – WAAGENT

The python package setuptools is a prequisite to install the waalinux agent. To install the setuptools in your virtual machine, please execute,

1
pip install -U pip setuptools

If pip is not installed in your machine, then download it and install it by following the below steps,

1
2
3
wget https://bootstrap.pypa.io/get-pip.py

python get-pip.py

Once the python package setuptools is installed, proceed with Azure Linux Agent installation,

1
sudo python setup.py install

Restart Azure Linux Agent – waagent

For Ubuntu based servers, please execute the below command to restart the agent,

1
sudo service walinuxagent restart

For most of other linux distros, the below command will work,

1
sudo service waagent restart

If not working, please try the below command,

1
sudo systemctl restart waagent

Check Azure Linux Agent Version

To check the Azure linux agent – waagent version, please execute the below command,

1
waagent -version

To know more about Azure linux agent installation, please refer the link,

 https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-update-agent#install-the-azure-linux-agent

14 Jan

Domain Join a Hyper-V 2016 host

Domain Join Hyper-V 2016 host

To domain join Hyper-V 2016 host to a windows domain, first you need to login to the server,

Hyper V 2016 Welcome Screen

Once your login is supplied, you will be directed to sconfig.cmd page, where you can modify your domain settings. To join your Hyper-V 2016 host to windows domain, select the option “1” , in the main menu, as shown in the below picture.

domain join hyper-v 2016

Now the sub menu will provide you wit 2 options, (D)omain and (W)orkgroup. Enter the letter “Ddomain join hyper-v 2016

Enter your domain name as as shown above. We have used testdomain.local as our domain. Please replace it with your domain name. Now it will ask you to supply the domain’s administrator user details. Please supply your domain’s administrator user name here.

domain join hyper-v 2016Now it will ask you to enter the password for your domain user account, which you have supplied during the previous step.

If your password is correct, it will join your hyper-V host to your domain.

14 Jan

Configure network in Hyper-V 2016

Login to Hyper V 2016

To configure the network in hyper-V 2016 server, first you need to login to the server. Press Cntrl+Alt+Del and type in your administrator password

Hyper V 2016 Welcome Screen

Configure Network in Hyper-V 2016

Once you are logged in, you will see a sconfig window(blue screen). Then select “Network Settings” by entering the number “8” on the option menu

It will list you the network adapters present in your server. Please note the Index value. In our case, the index value is 0. To select the Network Adapter Index, enter 0(In our case).

Since our aim is to setup an IP address against our network adapter, please select the option 1 in the menu.

To assign a Static IP address to your hyperV host, please enter the letter “S“.

You can set the following parameters under this menu,

  1. Set your static IP address as required.
  2. Enter the subnet mask, if you wish to change it.
  3. Enter the default gateway

Once done, please press “Enter“, so that Hyper V 2016 will start to configure the network settings.

Configure network in Hyper-V 2016

Configure DNS Settings

To configure the DNS settings of your Hyper-V 2016 host server, please select the option “2

Network Hyper-V 2016

Enter your “new preferred DNS server” and “alternate DNS Server” and then press “Enter” twice. It will show a popup window, where you need to press “OK

Network Hyper-V 2016

11 Jan

Hyper V 2016 Setup – Step by Step process explained

Hyper-V 2016 Server Setup

To start with the Hyper-V 2016 Server setup, please insert your bootable disk to your server. You can boot the ISO from a thumbdrive or DVD or from a network location. Once you have mounted and selected the bootable ISO, it will show the below window

Click the “Install now” button to proceed with the server setup.

In the succeeding page, you need to set your Language, Date\Time & Keyboard input preferences. Once done, please press “Next

Now you need to accept or reject the License conditions. To proceed with the Hyper-V 2016 setup, please check the “I accept the license terms” check box and press “Next

Install Hyper-V Server

In the next page, you can select to upgrade, if you are already running an older version of Hyper-V. In our setup, we are going ahead with a custom installation. So select the option 2, “Custom:Install the newer version of Hyper-V Server only(advanced)

Drive Allocation

In this page, you can allocate a drive for your setup. Since this is demo installation, we are going ahead with a 20GB drive. Ideally, the size should be equal to 1TB, if available. To start the drive creation, click “New

Once you have selected the size, click “Apply

Please click “OK” in the poup window, like below.

Now your drive will get formatted as required.

The installation of Microsoft Hyper-V server 2016 will start. You may need to wait for next 30 – 60 minutes to complete the installation.

Once the OS installation is done, the server will go for a reboot. Press “Restart now” to perform a quick reboot of the server.

After the reboot, the server will present you with a LogonUI.exe window, where you need to set your user details to manager your setup.

Type the administrator user name as “Administrator” and supply its corresponding password twice to confirm it.

In the next window, you will get a message that, your password has been changed.

You will be directed to the sconfig.cmd page.

To configure the network of your Hyper-V 2016 Server, please refer the link below

Configure network in Hyper-V 2016

To domain join your Hyper-V host to your domain, please refer the link below,

Domain Join a Hyper-V 2016 host

08 Jan

Attach a new datadrive to your Azure VM

Command to attach a datadrive in Azure Virtual Machine

Please execute the below command to attach a data drive of size 1TB to your Azure VM.

1
PS C:\> Get-AzureVM "Your_Cloud_Service_Name" -Name "Your_VM_Name" | Add-AzureDataDisk -CreateNew -DiskSizeInGB 1024 -DiskLabel "My Data" -LUN1 | Update-AzureVM
08 Jan

Selecting Azure Subscription

Steps to select Azure Subscription

To select Azure subscription, as the first step,  Login to your computer and open up your Azure PowerShell and type,

1
Add-AzureAccount

Press Enter

Now you will see a popup, which will ask you to sign in to your Azure account. Enter your username(email address) and press ‘Continue’. Now you enter your password.

The below command will list all the subscriptions, that you have,

1
Get-AzureSubscription

To view the currently selected subscription, please execute the below command,

1
Get-AzureSubscription -Current

To select a subscription from the list of your subscriptions, please execute the below command,

1
Select-AzureSubscription –SubscriptionName ""

If you wish to set the selected the subscription as your default subscription, please add the switch -Default.

1
Select-AzureSubscription -SubscriptionName "" -Default

If you do not wish to have a default subscription, please execute the below command,

1
Set-AzureSubscription -NoDefaultSubscription