The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,161 other followers

Archive for the ‘Virtualization’ Category

OSX 10.13 with vSphere 6.7 – Virtual Odyssey

Posted by jpluimers on 2020/11/16

Interesting: I never realised that getting MacOS installed on ESXi was relatively easy!

[WayBack] OSX 10.13 with vSphere 6.7 – Virtual Odyssey:

vCenter 6.7a/ESXi 6.7a Installing OSX 10.13 seemed pretty straight forward on 6.7. Essentially, you mount the ISO as per usual, and the only thing I had to do before starting the installation was to format the disk via terminal. Once…

So no need for all this:

–jeroen

 

Posted in ESXi6.5, ESXi6.7, Power User, Virtualization, VMware, VMware ESXi | Leave a Comment »

Packer template for Alpine Linux on Hyper-V and Azure; GitHub – tomconte/packer-alpine-azure

Posted by jpluimers on 2020/10/05

Cool: a Packer template for Alpine Linux on Hyper-V and Azure: [WayBack] GitHub – tomconte/packer-alpine-azure

I like Alpine Linux because it is lightweight and the focus of being very secure, how popular it is in the Docker scene where it replaced Ubuntu and is now the standar package at [Archive.is/A2] library/alpine – Docker Hub and the motto [WayBack] Alpine Linux; Small. Simple. Secure. Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busybox.

Alpine is not yet out of of the box endorsed by Azure ([WayBack] Endorsed distributions of Linux | Microsoft Docs) so this is a very welcome tool.

From the readme:

Packer template for Alpine Linux on Hyper-V and Azure

This Packer template will generate a VHD suitable for use in Hyper-V or Azure.

How it works

  • The Packer template downloads the Alpine 3.6 ISO from the official download site.
  • It then uses setup-alpine to perform an installation to disk.
  • The answers file is served using Packer’s built-in HTTP server.
  • It also installs the hvtools package and enables the hv_kvp_daemon service so Hyper-V can detect the VM is running and retrieve its IP address. (Read more about Hyper-V Integration Services.)

Software installed

The Packer provisioning step performs the following actions in order to prepare a proper Azure image:

  • Installs Python and OpenSSL, plus sudo and bash
  • Installs the shadow package (for useradd)
  • Installs the Azure Linux Agent
  • Adds recommended boot parameters
  • Sets the ssh client interval to 180
  • Enables the Azure Agent to start at boot

The template also installs a custom useradd script (in /usr/local/sbin) that changes the behavior of adding password-less accounts (i.e. accounts that log in using SSH keys). By default useradd locks the password-less account, preventing it from logging in. The custom script forces an illegal password, so that the password cannot be used to log in, but leaves the account unlocked so it can be access via SSH.

How to use the template

On Linux, using qemu

Check out the packer-qemu branch for a WIP version that builds the Alpine image using qemu, allowing you to generate the image from a Linux machine.

Detailed docs TBD, but the Windows instructions below should help.

On Windows, using Hyper-V

The commands need to be run from an elevated PowerShell prompt so that they can interact with Hyper-V.

First run the template. This will generate a VHDX file locally, in output-hyperv-iso.

packer build alpinehv.json

To use the image in Azure, you need to convert the image to VHD using convert.ps1.

The deploy.cmd script will upload the VHD to Azure and start a VM based on the image. Please amend the script variables as necessary.

Once the VM is started, you can log on via ssh and make any additional changes. Then deprovision the VM to get it ready to be used as an image:

waagent -deprovision

Finally, makeimage.cmd will deallocate the VM, capture it as an image, and start another VM based on that image.

TODO

  • Review/tweak boot command based on ladar’s comment
  • Investigate iptables error messages

Used tooling:

If you are Dutch, or you are fine with a Google translate, then read this background info:

Endorsed version combinations grouped by heritance:

A few others covered in [WayBack] Review: The best Linux distros for Docker and containers | InfoWorld:

and [WayBackLinux Distributions Optimized for Hosting Docker · Sweetcode.io:

  • Alpine Linux,
  • Container Linux,
  • RancherOS,
  • Atomic Host,
  • Boot2Docker,
  • Ubuntu Core

–jeroen

Posted in Azure Cloud, Cloud, Cloud Development, Development, Hyper-V, Infrastructure, Power User, Virtualization, Windows Azure | Leave a Comment »

Converting a virtual IDE disk to a virtual SCSI disk (1016192)

Posted by jpluimers on 2020/09/11

Just in case I have a VM with only IDE disks of which one ore more need to become SCSI disks: [WayBack] Converting a virtual IDE disk to a virtual SCSI disk (1016192)

TL;DR

  1. Add one SCSI disk
  2. Install drivers for it and get it recognised
  3. When the VM is shutdown:
    1. Modify the disk description of the IDE disk to SCSI (hack) or
    2. (often easier) remove the disk, then attach it to the SCSI controller

–jeroen

Posted in Power User, Virtualization, VMware, VMware ESXi | Leave a Comment »

ESXi: shrinking a thin provisioned disk by first exploding it with zero content

Posted by jpluimers on 2020/09/07

In addition to ESXi: shrinking a Windows disk, you can shrink any ESXi thin provisioned disk by first exploding it with zero content, then shrinking it like described by [WayBack] How to Shrink a Thin VMDK on ESXi 5.0 | Boerlowie’s Blog.

It comes down to using this command:

 vmkfstools --punchzero myVirtualMachineDisk.vmdk

You can replace --punchzero with -K if you like more cryptic arguments.

This works because thin provisioned vmdk disk files are sparse files where zero content can be non-allocated.

The trick requires all empty space to be zeroed out (which usually comes down using a tool like sdelete on Windows or shred on Linux), hence the “exploding” in the post title.

For a good explanation on thin, versus thick versus eagerlyZeroedThick, read [WayBackThin Provisioning – What’s the scoop? – VMware vSphere Blog.

A few remarks:

  • this only works within datastores, so when you transfer your file out, then the file will be the thick size
  • an OVF exported virtual machine will benefit from thin provisioned disks
  • the du command will show the actual storage size (including the savings from think provisioned disks)
  • the ls command will show then “virtual” storage size (excluding any thin provisioning gains)
  • the difference between ls and du output is the thin provisioning gain

–jeroen

Posted in Power User, Virtualization, VMware, VMware ESXi | Leave a Comment »

ESXi: shrinking a Windows disk

Posted by jpluimers on 2020/09/04

I had to shrink down a Windows disk of an ESXi based Virtual Machine from 240 Gibibyte to about 140 gigabyte.

In this case, it was Windows 7 on ESXi 6.5, but the actual versions do not really matter.

The only way to decrease ESXi .vmdk files is by fiddling with disk sector counts in the text based .vmdk files (not the binaries .vmdk files!) of a diskname.vmdk / diskname-flat.vmdk text/binary pair. This is described for instance in these two articles:

Notes:

  1. This article presumes you already shrunk your NTFS partition (for instance as described in Consolidating NTFS free space).
  2. If you only have a binary .vmdk file, then you can use vmkfstools to create a text/binary pair for you, for instance by using these commands:
    vmkfstools --clonevirtualdisk Windows7.vmdk Windows7.thick.vmdk
    vmkfstools --clonevirtualdisk Windows7.vmdk Windows7.thin.vmdk --diskformat thin
  3. You cannot workaround 2. as the --geometry functionality of vmkfstools only displays existing geometry, see

ESXi has .vmdk files that count disk sizes in sectors, but the tooling that ship with Windows to not show partition sizes in sectors, especially not the partition ending sector.

All permutations of tooling like DISKPART, PowerShell, WMIC and terms partition, ending sector, cylinder, head, etc failed me to return built-in tools.

Luckily, “powershell” “partition” “ending sector” found the documentation for [WayBack] Test Disk | File System | Data Management titled “TestDisk Documentation, Release 7.1, Christophe GRENIER” which lead to:

[WayBack] TestDisk Download – CGSecurity

Download TestDisk & PhotoRec. TestDisk is a free and open source data recovery software tool designed to recover lost partition and unerase deleted files. PhotoRec is a file carver data recovery software tool.

It is available for many platforms, including Windows x86 (fully featured) and x64 (limited features):

There was also the much more convoluted PowerForensics which is also more difficult to install:

As a check (because the calculations by hand are too cumbersome to trust on a first trey), I also downloaded the ISO image of gparted:

Let’s get started for real!

Read the rest of this entry »

Posted in Power User, Virtualization, VMware, VMware ESXi, Windows, Windows 7 | Leave a Comment »

 
%d bloggers like this: