Add create-ova script for esxi image creation
This commit is contained in:
@@ -30,7 +30,7 @@ docker build -t ep-eraser-builder .
|
|||||||
docker run --rm -v "$PWD:/work" ep-eraser-builder
|
docker run --rm -v "$PWD:/work" ep-eraser-builder
|
||||||
```
|
```
|
||||||
|
|
||||||
## VMware/VirtualBox disk
|
## VMware/VirtualBox images
|
||||||
|
|
||||||
Create a writable monolithic-sparse VMDK from the root ISO with `qemu-img` (`qemu-utils` on Debian):
|
Create a writable monolithic-sparse VMDK from the root ISO with `qemu-img` (`qemu-utils` on Debian):
|
||||||
|
|
||||||
@@ -42,6 +42,16 @@ The script defaults to `ep-eraser-amd64.hybrid.iso` and writes `ep-eraser-amd64.
|
|||||||
|
|
||||||
The Docker builder includes `qemu-img` too. After building that image, run the converter with `docker run --rm -v "$PWD:/work" --entrypoint /work/create-vmdk.sh ep-eraser-builder`.
|
The Docker builder includes `qemu-img` too. After building that image, run the converter with `docker run --rm -v "$PWD:/work" --entrypoint /work/create-vmdk.sh ep-eraser-builder`.
|
||||||
|
|
||||||
|
Create an ESXi-importable OVA with its own OVF descriptor and stream-optimized disk:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./create-ova.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
The default output is `ep-eraser-amd64.ova` plus a SHA-256 sidecar. Import it in ESXi with **Deploy OVF Template**; VirtualBox can import the same OVA. The appliance defaults to BIOS boot and 2 CPUs/2 GiB RAM. It runs the same temporary live environment, not an installed persistent OS. Wiping host disks from a VM requires separately attaching the target disk through supported passthrough/RDM; the OVA disk itself is the protected boot medium. Use physical boot media for direct hardware wiping.
|
||||||
|
|
||||||
|
To build the OVA in Docker, use `docker run --rm -v "$PWD:/work" --entrypoint /work/create-ova.sh ep-eraser-builder`.
|
||||||
|
|
||||||
## Use
|
## Use
|
||||||
|
|
||||||
Boot the target machine from the image, inspect the disk list, and choose the exact device path. The program detects rotational media and presents the appropriate operation. Reboot after completion; do not remove the USB device until the result is shown.
|
Boot the target machine from the image, inspect the disk list, and choose the exact device path. The program detects rotational media and presents the appropriate operation. Reboot after completion; do not remove the USB device until the result is shown.
|
||||||
|
|||||||
+155
@@ -0,0 +1,155 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
root=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||||
|
|
||||||
|
if [[ "${1:-}" == -h || "${1:-}" == --help ]]; then
|
||||||
|
printf 'Usage: %s [INPUT.iso] [OUTPUT.ova]\n' "$0"
|
||||||
|
printf 'Defaults: %s/ep-eraser-amd64.hybrid.iso and %s/ep-eraser-amd64.ova\n' "$root" "$root"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( $# > 2 )); then
|
||||||
|
printf 'Usage: %s [INPUT.iso] [OUTPUT.ova]\n' "$0" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
input=${1:-"$root/ep-eraser-amd64.hybrid.iso"}
|
||||||
|
output=${2:-"$root/ep-eraser-amd64.ova"}
|
||||||
|
|
||||||
|
for command_name in qemu-img sha256sum tar stat realpath; do
|
||||||
|
command -v "$command_name" >/dev/null 2>&1 || {
|
||||||
|
printf 'ERROR: %s is required.\n' "$command_name" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
[[ -f "$input" ]] || {
|
||||||
|
printf 'ERROR: ISO not found: %s\n' "$input" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
input=$(realpath -- "$input")
|
||||||
|
output=$(realpath -m -- "$output")
|
||||||
|
checksum="$output.sha256"
|
||||||
|
|
||||||
|
for path in "$output" "$checksum"; do
|
||||||
|
if [[ -e "$path" || -L "$path" ]]; then
|
||||||
|
printf 'ERROR: refusing to overwrite existing file: %s\n' "$path" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
input_bytes=$(stat -c %s -- "$input")
|
||||||
|
if (( input_bytes % 1048576 != 0 )); then
|
||||||
|
printf 'ERROR: ISO size must be a whole number of MiB for OVF disk capacity.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
disk_capacity_mib=$((input_bytes / 1048576))
|
||||||
|
|
||||||
|
mkdir -p -- "$(dirname -- "$output")"
|
||||||
|
temp_dir=$(mktemp -d)
|
||||||
|
temp_ova="$output.tmp.$$"
|
||||||
|
temp_checksum="$checksum.tmp.$$"
|
||||||
|
trap 'rm -rf -- "$temp_dir"; rm -f -- "$temp_ova" "$temp_checksum"' EXIT
|
||||||
|
|
||||||
|
ovf_name=ep-eraser-amd64.ovf
|
||||||
|
disk_name=ep-eraser-amd64-disk1.vmdk
|
||||||
|
manifest_name=ep-eraser-amd64.mf
|
||||||
|
disk_path="$temp_dir/$disk_name"
|
||||||
|
|
||||||
|
qemu-img convert -p -f raw -O vmdk -o subformat=streamOptimized "$input" "$disk_path"
|
||||||
|
disk_file_bytes=$(stat -c %s -- "$disk_path")
|
||||||
|
|
||||||
|
cat > "$temp_dir/$ovf_name" <<EOF
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ovf:Envelope xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
|
||||||
|
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
|
||||||
|
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
|
||||||
|
xmlns:vmw="http://www.vmware.com/schema/ovf" ovf:version="1.0">
|
||||||
|
<ovf:References>
|
||||||
|
<ovf:File ovf:id="file1" ovf:href="$disk_name" ovf:size="$disk_file_bytes"/>
|
||||||
|
</ovf:References>
|
||||||
|
<ovf:DiskSection>
|
||||||
|
<ovf:Info>Virtual disk information</ovf:Info>
|
||||||
|
<ovf:Disk ovf:diskId="disk1" ovf:fileRef="file1" ovf:capacity="$disk_capacity_mib" ovf:capacityAllocationUnits="byte * 2^20" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized"/>
|
||||||
|
</ovf:DiskSection>
|
||||||
|
<ovf:NetworkSection>
|
||||||
|
<ovf:Info>Logical networks</ovf:Info>
|
||||||
|
<ovf:Network ovf:name="VM Network">
|
||||||
|
<ovf:Description>Network connection for EP Eraser</ovf:Description>
|
||||||
|
</ovf:Network>
|
||||||
|
</ovf:NetworkSection>
|
||||||
|
<ovf:VirtualSystem ovf:id="EP-Eraser">
|
||||||
|
<ovf:Info>EP Eraser live environment</ovf:Info>
|
||||||
|
<ovf:Name>EP Eraser</ovf:Name>
|
||||||
|
<ovf:OperatingSystemSection ovf:id="94" vmw:osType="otherLinux64Guest">
|
||||||
|
<ovf:Info>64-bit Linux</ovf:Info>
|
||||||
|
<ovf:Description>Debian Live</ovf:Description>
|
||||||
|
</ovf:OperatingSystemSection>
|
||||||
|
<ovf:VirtualHardwareSection>
|
||||||
|
<ovf:Info>Virtual hardware requirements</ovf:Info>
|
||||||
|
<ovf:System>
|
||||||
|
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
|
||||||
|
<vssd:InstanceID>0</vssd:InstanceID>
|
||||||
|
<vssd:VirtualSystemIdentifier>EP Eraser</vssd:VirtualSystemIdentifier>
|
||||||
|
<vssd:VirtualSystemType>vmx-10</vssd:VirtualSystemType>
|
||||||
|
</ovf:System>
|
||||||
|
<ovf:Item>
|
||||||
|
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
|
||||||
|
<rasd:Description>Number of virtual CPUs</rasd:Description>
|
||||||
|
<rasd:ElementName>2 virtual CPUs</rasd:ElementName>
|
||||||
|
<rasd:InstanceID>1</rasd:InstanceID>
|
||||||
|
<rasd:ResourceType>3</rasd:ResourceType>
|
||||||
|
<rasd:VirtualQuantity>2</rasd:VirtualQuantity>
|
||||||
|
</ovf:Item>
|
||||||
|
<ovf:Item>
|
||||||
|
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
|
||||||
|
<rasd:Description>Memory Size</rasd:Description>
|
||||||
|
<rasd:ElementName>2048 MB of memory</rasd:ElementName>
|
||||||
|
<rasd:InstanceID>2</rasd:InstanceID>
|
||||||
|
<rasd:ResourceType>4</rasd:ResourceType>
|
||||||
|
<rasd:VirtualQuantity>2048</rasd:VirtualQuantity>
|
||||||
|
</ovf:Item>
|
||||||
|
<ovf:Item>
|
||||||
|
<rasd:Address>0</rasd:Address>
|
||||||
|
<rasd:Description>SCSI Controller</rasd:Description>
|
||||||
|
<rasd:ElementName>SCSI Controller 0</rasd:ElementName>
|
||||||
|
<rasd:InstanceID>3</rasd:InstanceID>
|
||||||
|
<rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
|
||||||
|
<rasd:ResourceType>6</rasd:ResourceType>
|
||||||
|
</ovf:Item>
|
||||||
|
<ovf:Item>
|
||||||
|
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||||
|
<rasd:ElementName>EP Eraser live disk</rasd:ElementName>
|
||||||
|
<rasd:HostResource>ovf:/disk/disk1</rasd:HostResource>
|
||||||
|
<rasd:InstanceID>4</rasd:InstanceID>
|
||||||
|
<rasd:Parent>3</rasd:Parent>
|
||||||
|
<rasd:ResourceType>17</rasd:ResourceType>
|
||||||
|
</ovf:Item>
|
||||||
|
<ovf:Item>
|
||||||
|
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||||
|
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
|
||||||
|
<rasd:Connection>VM Network</rasd:Connection>
|
||||||
|
<rasd:ElementName>Network Adapter 1</rasd:ElementName>
|
||||||
|
<rasd:InstanceID>5</rasd:InstanceID>
|
||||||
|
<rasd:ResourceSubType>E1000</rasd:ResourceSubType>
|
||||||
|
<rasd:ResourceType>10</rasd:ResourceType>
|
||||||
|
</ovf:Item>
|
||||||
|
<vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="bios"/>
|
||||||
|
</ovf:VirtualHardwareSection>
|
||||||
|
</ovf:VirtualSystem>
|
||||||
|
</ovf:Envelope>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
ovf_hash=$(sha256sum "$temp_dir/$ovf_name" | awk '{print $1}')
|
||||||
|
disk_hash=$(sha256sum "$disk_path" | awk '{print $1}')
|
||||||
|
printf 'SHA256(%s)= %s\nSHA256(%s)= %s\n' "$ovf_name" "$ovf_hash" "$disk_name" "$disk_hash" > "$temp_dir/$manifest_name"
|
||||||
|
|
||||||
|
tar --format=ustar -C "$temp_dir" -cf "$temp_ova" "$ovf_name" "$disk_name" "$manifest_name"
|
||||||
|
hash=$(sha256sum < "$temp_ova")
|
||||||
|
printf '%s %s\n' "${hash%% *}" "$(basename -- "$output")" > "$temp_checksum"
|
||||||
|
mv -- "$temp_ova" "$output"
|
||||||
|
mv -- "$temp_checksum" "$checksum"
|
||||||
|
trap - EXIT
|
||||||
|
|
||||||
|
printf 'Created OVA: %s\nSHA-256: %s\n' "$output" "$checksum"
|
||||||
Reference in New Issue
Block a user