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

21 Jan

Sync linux server time with network time protocol(NTP) servers

Sync linux server time with network time protocol(NTP) servers

To sync linux server time with network time protocol(NTP) servers, you need to have the NTP client installed in your machine. To perform the installation in an Ubuntu server, please execute the below command.

1
apt-get install ntp 

Sync linux server time with network time protocol(NTP) servers

To perform the installation in a Redhat or in a CentOS server, please execute the below command,

1
 yum install ntp

Once you are done with the NTP client installation, we need to edit the NTP configuration file /etc/ntp.conf

1
 vi /etc/ntp.conf

By default, you may find a list of NTP servers listed in the configuration file.

Sync linux server time with network time protocol(NTP) servers

If you wish to change the default values to the ones closer to your location, please visit the NTP site http://www.pool.ntp.org/. You will see the list of NTP servers for each time zone listed at the NTP portal.

Sync linux server time with network time protocol(NTP) servers

For India location, you need to visit the link http://www.pool.ntp.org/zone/in

Sync linux server time with network time protocol(NTP) servers

Once the configuration changes are made, we need to restart the NTP service

1
 /etc/init.d/ntp restart

Sync linux server time with network time protocol(NTP) servers

To run the time synchronisation with  the NTP servers, please execute the below command, after stopping the NTP service.

1
 /usr/sbin/ntpdate pool.ntp.org

If the ntpdate is not installed in your server, then you can run the below command to install it.

1
apt-get install ntpdate

Sync linux server time with network time protocol(NTP) serversIf you are facing the error “the NTP socket is in use, exiting“, upon executing the above command, which points to the issue that the NTP service is still running.

Sync linux server time with network time protocol(NTP) serversSo stop the service and execute the command again.

Sync linux server time with network time protocol(NTP) servers

If you are encountering the error “no server suitable for synchronization found“, please check your firewall settings. Please ensure that, the UDP port 123 is enabled.

Verify the NTP client status

To verify the NTP client status, three major utilities can be used,

NTPQ

NTPQ is a standard NTP Query program, which is used to monitor NTP daemon ntpd operations and analyse its performance.

Run the below command to obtain the current status of ntp

1
 ntpq -pn
1
2
 -n  :  Output all host addresses in dotted-quad numeric format rather than converting to the canonical host names.
-p  :  Print a list of the peers known to the server as well as a summary of their state. This is equivalent to the peers interactive command.

Sync linux server time with network time protocol(NTP) serversTo know more about the utility, please refer the man page

1
man ntpq

NTPSTAT

The ntpstat utility  will display the network time synchronisation status. If your server is synchronised to reference NTP value, then the ntpstat command will return the approximate time accuracy.

If the ntpstat is not installed in your machine, please execute the below command to install it.

1
apt-get install ntpstat

Execute the below command to get the status of your NTP daemon,

1
ntpstat

The return value of ntpstat will tell you the status. Please execute the below command to get the return value,

1
echo $? 

The clock is synchronised, if the return value is “0”. If the ntpstat return value is “1”, then the clock is not synchronised. If the return value is “2”, then the clock is indeterminant, Eg : If ntp is not reachable.

To know more about the ntpstat usage, please refer its man page

1
man ntpstat

timedatectl

On a systemd based system, you can use the command timedatectl. The status can be checked by executing the below command,

1
 timedatectl status

If NTP enabled is set to No, then you can edit the systemd-timesyncd configuration file “/etc/systemd/timesyncd.conf” to change it.

 

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

15 Jan

Step to modify time stamp value of files in linux

Modify time stamp value of files in linux

We can modify time stamp value of files using the touch command. It can be changed based on Access Time, Modify Time or combination of both. To check the time stamp value of a file, please execute,

1
stat testfile

modify time stamp value of filesPlease use the below commands to create a file with an older time stamp, say May 05 2013,

1
touch -d 20130505 testfile

modify time stamp value of files

Copying time stamp from existing file to new file,

1
touch -r testfile newtestfile

Copying time stamp from existing file to multiple new files \ existing files

1
touch -r testfile newtestfile  newtestfile2 newtestfile3

modify time stamp value of files

Make changes to Access Time and Modify Time

To modify the Access Time parameter of a file, please use the switch “-a“.  It will change access time to the current date and time as given below.

1
touch –a testfile

To make changes to  “Modify Time” parameter of a file, please use the switch “-m“.  It will change modify time to the current date and time as given below.

modify time stamp value of files

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

12 Jan

Configure and administering UFW using commands

Administering UFW

UFW or uncomplicated firewall is for managing firewall rules in Ubuntu, Debian and Arch Linux. You can use the below commands for administering UFW.

To install UFW, please execute the below command,

1
sudo apt-get install ufw
UFW InstallAllow Rules

Always make sure to add allow rule fo SSH as priority,

1
sudo ufw allow ssh

or

1
sudo ufw allow 22

You can allow or deny a service based on protocol. For example, to allow TCP on port 80, please execute,

1
sudo ufw allow 80/tcp

or

1
sudo ufw allow http/tcp

To allow https on port 443, please execute,

1
sudo ufw allow 443/tcp

or

1
sudo ufw allow https/tcp

UFW AllowIf you wish to allow UDP protocol on port 1234, please execute,

1
sudo ufw allow 1234/udp

If you wish to allow traffic from a specific IP address 111.222.333.444, please execute,

1
sudo ufw allow from 111.222.333.444

If you wish to allow traffic from a specific subnet, then execute,

If you wish to allow a particular IP address to access a specific port, say port 80, then execute,

If you wish to allow a particular subnet address to access a specific port, say port 80, then execute,

 

Block Traffic

To deny traffic from a particular IP address,

1
sudo ufw deny from 111.222.333.444

If you wish to deny traffic from a particular IP address to a specific network interface, please execute,

1
sudo ufw deny in on eth1 from 111.222.333.444

If you wish to allow a particular service to a private ethernet interface, say eth1,

Allow Traffic to network interface using UFW
1
sudo ufw allow in on eth1 to any port 3306

To list the rules set in UFW, please execute,

1
sudo ufw status

To Action From
— —— —-
22 ALLOW Anywhere
8080/tcp ALLOW Anywhere
3306 ALLOW Anywhere
80 ALLOW Anywhere
443 ALLOW Anywhere
22 (v6) ALLOW Anywhere (v6)
8080/tcp (v6) ALLOW Anywhere (v6)
3306 (v6) ALLOW Anywhere (v6)
80 (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)

administering UFW statusTo enable the UFW firewall, please execute,

1
sudo ufw enable

To disble the UFW firewall, please execute,

1
sudo ufw disable

To enable the UFW logging, please execute,

1
sudo ufw logging on

Refer : https://en.wikipedia.org/wiki/Uncomplicated_Firewall

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