VMWare ESXi

From Edgar BV Wiki
Jump to navigation Jump to search

Installation Steps

  1. install ESXi onto the hardware (use unetbootin to create the image, don't follow the manual: it's shit)
  2. install VMWare vSphere client onto your PC
  3. Connect using the vSphere client
  4. In the server -> configuration -> Licensed Features (under Software) - Edit (on the right) and enter the license key: JM28P-8UJE1-68Z81-02ARH-81L04 (edgarbv) H401K-82H0M-K8F49-0H9A4-95CM0
  5. Create a datastore and on that create a directory .locker-HOSTNAME
  6. Go to Manage -> System -> Advanced settings and find ScratchConfig.ConfiguredScratchLocation edit this to be /vmfs/volumes/UUID/.locker-HOSTNAME
  7. now find Syslog.global.logdir and set this to the datastorename [platters]/.locker-HOSTNAME/log or via syslog.global.loghost (for remote logging)

Expanding HDs on a VM

Turn off the VM, change the size of the disk in the settings. Start up the vm.

use fdisk /dev/sda to view the free space. If fdisk doesn't work, use parted or cfdisk.

Format the extra space as type 8e (LVM). Use vgextend and then lvextend to increase the size

From here

Run this command to extend the physical volume:

# vgextend VolGroup00 /dev/sda3

Note: To determine which volume group to extend, use the command vgdisplay.

Run this command to verify how many physical extents are available to the Volume Group:

# vgdisplay VolGroup00 | grep "Free"

Run the following command to extend the Logical Volume:

# lvextend -L+#G /dev/VolGroup00/LogVol00

Where # is the number of Free space in GB available as per the previous command. Use the full number output from Step 10 including any decimals.

Note: To determine which logical volume to extend, use the command lvdisplay.

Run the following command to expand the ext3 filesystem online, inside of the Logical Volume:

# ext2online /dev/VolGroup00/LogVol00

Notes:

    Use resize2fs instead of ext2online if it is not a Red Hat virtual machine.
    By default, Red Hat and CentOS 7 use the XFS file system you can grow the file system by running the xfs_growfs command.

Run the following command to verify that the / filesystem has the new space available:

# df -h /

adding new disks to a vm and booting

When you add a new disk, you may get an OS not installed / can't boot up error. This is because for some reason, esxi adds the new disk as scsi 0:0 (which is the first disk that wants to boot up). So you need to edit the new hard disk to scsi 0:2, the old one to 0:0 and then the new one to 0:1 again.

cloning VMs using the CLI

Cloning a virtual machine disk without delta files or snapshots To clone a virtual machine disk using the ESXi/ESX host terminal:

   Log in to the terminal of the ESXi/ESX host.
   Navigate to the virtual machine's directory using the cd command. It is located at:
   /vmfs/volumes/source_datastore/virtual_machine/
   Confirm the destination directory where the clone will be copied to. Create this directory, if required.
   For example, if this destination directory does not exist:
   /vmfs/volumes/destination_datastore/virtual_machine/
   Create the directory using this command:
   mkdir /vmfs/volumes/destination_datastore/virtual_machine/
   Clone the virtual hard disk using the vmkfstools -i command after shutting down the virtual machine:
   # vmkfstools -i /vmfs/volumes/Storage1/examplevm/examplevm.vmdk /vmfs/volumes/Storage2/examplevm_clone.vmdk
   You see output similar to:
   Destination disk format: VMFS thick
   Cloning disk '/vmfs/volumes/Storage1 (3)/examplevm/examplevm.vmdk'...
   Clone: 100% done.
   Notes:
       Encapsulate objects with quotes where appropriate to ensure spaces and other special characters are interpreted correctly.
       By default, the vmkfstools -i command will create a destination thick provisioned disk. If you want the destination disk to be thin provisioned, add -d thin to the end of the preceding command.
       For example:
       # vmkfstools -i /vmfs/volumes/Storage1/examplevm/examplevm.vmdk /vmfs/volumes/Storage2/examplevm_clone.vmdk -d thin

Cloning a virtual machine disk with delta files or snapshots

To clone a virtual machine disk using the ESXi/ESX host terminal:

   Log in to the ESXi/ESX host's terminal.
   Navigate to the virtual machine's directory using the cd command. It is located at:
   /vmfs/volumes/source_datastore/virtual_machine/
   Confirm the destination directory where the clone will be copied to. Create this directory, if required.
   For example, if this destination directory does not exist:
   /vmfs/volumes/destination_datastore/virtual_machine/
   Create the directory using this command:
   mkdir /vmfs/volumes/destination_datastore/virtual_machine/
   Clone the virtual hard disk from its current snapshot delta point using the vmkfstools -i command.
   # vmkfstools -i /vmfs/volumes/Storage1/examplevm/examplevm-000003.vmdk /vmfs/volumes/Storage2/examplevm_clone.vmdk
   You see output similar to:
   Destination disk format: VMFS thick
   Cloning disk '/vmfs/volumes/Storage1 (3)/examplevm/examplevm-000003.vmdk'...
   Clone: 100% done.

Impact/Risks

Downtime during the clone procedure.

Additional Information

Additional steps for virtual machine disks with delta files or snapshots

The original virtual machine files are still intact without modifications. You may opt to either create a new virtual machine and attach the cloned disk file(s), or replace the existing disks attached to the virtual machine with the cloned copies. These steps encompass the latter option.

To replace the original virtual machine disk(s) and delta snapshot file(s) with the cloned copy or copies:

   Detach the virtual hard disk from the virtual machine's configuration in the VMware vSphere or Infrastructure Client.
   Attach the new (cloned) virtual hard disk, /vmfs/volumes/Storage2/examplevm_clone.vmdk to the virtual machine.
   Rename the snapshot database (.vmsd) file for the virtual machine. At this time, it is no longer valid due to manipulation of the virtual machine's disk layout during troubleshooting:
   # mv examplevm.vmsd examplevm.vmsd.old
   Power on the virtual machine and confirm the guest operating system can boot successfully. Verify data integrity and confirm data is not missing or corrupt.
   With the virtual machine still powered-on, you may remove the original disk files to free datastore space. Files in use by the powered-on virtual machine cannot be removed by the VMware ESX server. This can be used as a safeguard.

add new user

Go to local users and groups and right click on the screen to add a new user. The password needs to be 8 characters long.

Then go to permissions and right click on the screen to add a permission. Choose the assigned role and then add the new user (on the left)

auto start vm's

under the configuration tab for the machine, at "Virtual Machine Startup/Shutdown"

Choose Properties. You can configure the startup/shutdown here.

starting from a cdrom or iso after OS has been installed

In advanced boot options change the bootup delay to 99999 milliseconds. Then when you start up the VM you can press esc to select a boot device

keyboard shortcuts for console

Ctrl+Shift+Insert Sends Ctrl+Alt+Delete

Ctrl+G Transfers mouse and keyboard input from the local machine to the virtual machine (same as clicking in the window) great for when you don't have a mouse handy

Ctrl+Alt+Enter Full Screen VM

Ctrl+Alt Unlocks mouse/keyboard from VM console window, also exists full screen mode

Ctrl+Shift+X Exit VM Console

installing tools on a VM

The tools allow you to do things like copy paste into the console. In order to install the tools, you mount a CD from the internal datastore. Choose the version for the OS you have. Mount the CD, then copy the contents to /usr/local/src and unzip them. Inside this directory you run the perl scripts. For Linux you will need the kernel headers package

Debian

apt-get install open-vm-tools

Resetting the password for ESXi

There is the Cisco Way and the

Unofficial way

NB you will have to use udpkg to install gzip from the cdrom (find the deb and use udpkg -i file.deb). Also you will need nano editor because vi isn't installed with the rescue disk.

After the host was shut down, I booted up with the Linux live CD. I then ran the commands fdisk -l and ls -l /mnt/sda5/ / ls -l /mnt/sda6/ to determine the location of the most recent state.tgz file. Note that if you're using ESXi Embedded then you may only see local.tgz instead of state.tgz and you should then copy and recreate that file.


After determining where the most recent state.tgz file was located, this was copied to /tmp. gzip and tar were then used to extract local.tgz from state.tgz. If you're using ESXi Embedded then you will copy local.tgz to tmp and run gzip and tar on that file. Once local.tar was extracted the cd etc command was run followed by vi shadow


ssentially you'll want to have the root entry as root::13358:0:99999:7::: . Once you have removed the password hash, press ESC and to save the change type in :wq and press Enter. You can run cat shadow to confirm that the change was saved successfully.


Once the shadow file has been updated, you'll use cd .. to go back to /tmp and then run tar -czvf local.tgz etc to create the local.tgz file. If you're using ESXi Embedded then you'll copy this file to the drive where it came from in step 3. Otherwise you'll run tar -czvf state.tgz local.tgz to create state.tgz which should then be copied to the correct location. In the below image you'll notice that I don't always use the -v option with the tar command.


Once the file has been copied back to the /bootbank partition the host can be rebooted back into ESXi. You'll be able to login with the root account with no password and will be greeted with the familiar message to change the root password

Import VirtualBox harddisks

On your VirtualBox host create a clone of the VMs hard disk like that: vboxmanage clonehd in.vdi out.vmdk –format VMDK –variant Fixed,ESX

If your VirtualBox drive is allready a vmdk then in.vmdk

This creates two files. One with the actual data and the other holding a descriptor. If the virtual hard drive is not completely filled, zipping the image will dramatically reduce its size.

On your ESXi host create a new VM without hard drive. Use the advanced mode to do so.

Copy the hard drive image to your ESXi host by using scp (or similar). Place it (both files) into the directory of you newly created VM.

Edit the settings of your new VM and add that hard drive.

That’s all. Using this method your virtual hard drive should now be a SCSI hard drive as expected by ESXi even if it was a SATA drive in VirtualBox before.

From [1]

Import Windows 7 client from VirtualBox

Same as above, but change HD type from SCSI to SATA

Virtualdisk manager

This can be used to expand, shrink, repair, create, etc vmdk files

Download from vmware (vmware-vdiskmanager.exe is part of the The Virtual Disk Development Kit (VDDK)

Some examples of use can be found here

Items disappearing from the navigation tree

If the inventory tree views are no longer showing items and you can't click on the triangle any more, in 6.5 you can click on your username, go to settings and turn off show only recent objects