Few of the articles are posted as Images, Please use Laptop / Computers to go through the articles for best experience. For phone users, switch to Web Version

Please Share with your colleagues if you found these blogs informative. Happy Learning :-)

Showing posts with label VMware. Show all posts
Showing posts with label VMware. Show all posts

Registering VM via Command Line


VM is perf-worker-01a & 
Esxi is esx-01a.corp.local


Steps
 Navigate to the Esx host & enable SSH.
To enable SSH, Click on Esx --> Configure --> Services --> SSH & Start the service.








Open Putty & connect the Esx.








We will first inode of the datastore where VM is present. To do it use below command,
     find -iname VMNAME






Copy the output & traverse to it using below command.
Cd Ouputof first command









Use below command to register the VM.

Vim-cmd solo/registervm /vmfs/volumes/5a905bc6-8f09ccc8-9e77-00505601dfda/perf-worker-01a/perf-worker-01a.vmx






Validate the results from Host & Cluster View.





Mounting Disk of One VM to Another VM

 I ran into a Problem where one of VM crashed & hence unable to boot it. I had important data in one of the disk attached to the VM.


To recover data, we can mount the disk to some other VM & then can recover our data. To implement follow below steps -

1. Note down the Disk holding your data along with the datastore name. You can easily get this info by right clicking on the VM & Edit Settings.





2. We first need to remove the disk attached to the affected VM. Click on "X" icon to remove it. ( Don't check mark delete from Datastore also option)




3. One removed, we can navigate to other Working VM , Right click --> Edit Settings --> Add Hard drive & here select existing Hard disk Option.




4. Navigate to the datastore containing the disk. ( This was noted in Step 1)







5. Login to the VM. Navigate to Disk management & mark the newly disk as Online.







Able to see all the data now.




Disk Modes - Dependent Vs Independent

 We have two type of disk modes - Dependent & Independent modes.

Further independent disk modes has two flavors which are Independent Persistent & Independent Non Persistent modes.


Difference between them comes into the picture when we talk about Snapshot.

Dependent Disk - By default every newly created Hard drive/disk is Dependent disk. So assume if you have a VM which is having dependent disk then after taking snapshot, you will see two .VMDK's one for the base / parent disk & other would be a delta disk.

This means dependent disk are considered in Snapshots. Below highlighted .vmdk is a delta disk created after snapshot. All the changes would be written first to this vmdk & once we decide to delete the snapshot, then all the things from this vmdk will be committed to Parent disk (Non highlighted VMDK)











Independent Disk - Whether it's Persistent or Non Persistent, these type of disk are not considered in Snapshots.

In Independent Persistent mode, once you do any changes on this disk, then it would be permanently written to that disk, so snapshot here doesn't make any sense & that why even if you take a snapshot for a VM, then you won't be seeing snapshot delta disk for the disk which is independent persistent type.

Ex - I have created a disk of 10GIG which is of Independent Persistent mode, and for testing purpose I have taken a snapshot.

























Datastore view post adding 10 GIG disk.















Taking Snapshot 













So if we explore the files inside the VM folder in datastore, then we will see only one delta disk which is for first disk as it was Dependent disk. You won't be seeing any delta disk for 2nd disk & the reason being it is independent persistent disk.

In below snap, highlighted disk is a delta disk for disk 1 & no delta disk for disk 2.



















Independent Non Persistent - In this mode, once we create a snapshot, then instead of delta disk, some redo logs are created. These are like temporary storage & all the changes that you do on Non Persistent delta disk after taking snapshot will be written to the redo logs.

Since it is temporary, so once you delete the snapshot or even shutdown the VM, all the written changes from the redo logs will be gone.

Ex - I have added a New Disk of 5GIG as an Independent Non Persistent mode & then took a snapshot.




























Datastore view post creating Non Persistent disk - 

Uploading: 54737 of 54737 bytes uploaded.
Taking Snapshot




Exploring the files inside VM folder, we will be seeing a new Delta disk on the second row created & this is for first disk as it was Dependent mode, whereas we won't see any delta disk for second disk as it was Independent Persistent mode & finally for third disk we don't see any delta disk created but we do see redo logs created on last two rows & this is primarily because the disk mode is Independent Non Persistent.







Finish ..


Fixing Remove Permission Failed Error from Esxi

I mistakenly added a Group named  "Infra VMware Team" in Permissions tab on an Esxi directly.













 


When trying to  remove it, getting below error - 


















Fix - 
This is due to a bug which prevents removing explicit Users or Groups added to Esx Permissions. We can make use of PowerCLi to fix this.


1. We will connect to our Vcenter using PowerCLi, provide correct User ID & Password.














2. Once connected, we can view all the Esx in the Vcenter by typing "Get-VMHost" cmdlet.








3.  Viewing all the permission on esx-02a.corp.local by typing below command - 

Get-VIPermission -Entity Esxhostname | Format-Table  - Autosize




















4. We can also use Principal switch as show below to check permission of a specific user or a group.




5.  To remove permission, type below command - 

Get-VIPermission -Entity Esxhost -Principal 'domain\userorgroup'  | Remove-VIPermission -confirm:$false





& we are done. We can cross check it through GUI or through CLI as well. (Repeat command mentioned in step 3)











































Finish

Difference in Template & Cloning


People often get confuse in Templates & Cloning Concept. Let's understand the concept using a Scenario - 

Consider today is 1st Jan 2022, and you have deployed a VM named "VM1", configured various settings, Install required basic applications, Patching etc. Now the management has asked you to create 10 more identical VM's ( meaning same configuration , Applications, Patching etc). It would take so much time if you create & configure VM one by one, also there might be good chances of human errors as well.

In order to overcome this, we have two Concepts "Templates" & "Cloning". Both these concept serve similar purpose and that is creating VM's from existing Setup/VM. This saves our time & reduces chances of human errors.

Since both serve same purpose, then why do we have two Concepts ? Why not only one ?

Answer to this is the way these are used & when they are used.

To understand Template, Suppose the VM that we created & configure on Jan1 "VM1" is converted to a state where it can't be powered on. Now that state will act as a template & we can use it to create  new VM's.
So if I have converted VM1 to a template & use it to create new VM's  then no matter when you create New VM's, all will contain consistent settings & configurations.

Cloning - Here you are creating a new VM from a Live VM. So if you create another VM from VM1 on Jan1 itself, then that would ideally contain all the same configuration & settings ( Considering you haven't made any changes to VM1), but let's assume you created another VM from VM1 after 2 months, then the New VM might contain some extra/different settings from other VM's cloned from VM1 & this is simply because of changes made on VM1 in two months.

In Short, Template ensures consistent state & settings on all new VM's deployed from it whereas Cloning ensures identical duplicate copy of an existing/master VM's.


Apart from this, there are few more differences in both these concept's - 

1. You can't create a Template of a VM when it's powered on. You need to Powered off the VM first, whereas in cloning you can create a New VM from a Live running VM.

2. If required any editing on the template, you first need to convert the template back to a VM, do the changes & then convert it back to the template. In Cloning, since the VM is live, you can do the changes on the Live VM & then cloned a new VM out of the existing /parent VM.

Note - Administrators needs to be careful while Cloning a VM because there are good chances of IP conflict when they powered on the cloned VM & this is primarily because you master VM is also online & having same IP configuration.
To avoid, Administrators first uncheck NIC for the Cloned VM, power it on, login via Console,  do the IP, hostname, SID changes & then enable NIC.