Add script to do vmdk files
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@ FROM debian:trixie
|
|||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||||
live-build ca-certificates debootstrap xorriso squashfs-tools dosfstools \
|
live-build ca-certificates debootstrap xorriso squashfs-tools dosfstools qemu-utils \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /work
|
WORKDIR /work
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ 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
|
||||||
|
|
||||||
|
Create a writable monolithic-sparse VMDK from the root ISO with `qemu-img` (`qemu-utils` on Debian):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./create-vmdk.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
The script defaults to `ep-eraser-amd64.hybrid.iso` and writes `ep-eraser-amd64.vmdk` plus a SHA-256 sidecar in the project root. You can pass an ISO path and output VMDK path explicitly. The VMDK contains the same live boot image, not an installed OS or persistent live session. Attach it as an existing disk in VMware or VirtualBox; ESXi may require importing it into a datastore with `vmkfstools`.
|
||||||
|
|
||||||
|
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`.
|
||||||
|
|
||||||
## 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.
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
#!/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.vmdk]\n' "$0"
|
||||||
|
printf 'Defaults: %s/ep-eraser-amd64.hybrid.iso and %s/ep-eraser-amd64.vmdk\n' "$root" "$root"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( $# > 2 )); then
|
||||||
|
printf 'Usage: %s [INPUT.iso] [OUTPUT.vmdk]\n' "$0" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
input=${1:-"$root/ep-eraser-amd64.hybrid.iso"}
|
||||||
|
output=${2:-"$root/ep-eraser-amd64.vmdk"}
|
||||||
|
|
||||||
|
command -v qemu-img >/dev/null 2>&1 || {
|
||||||
|
printf 'ERROR: qemu-img is required (install qemu-utils).\n' >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
command -v sha256sum >/dev/null 2>&1 || {
|
||||||
|
printf 'ERROR: sha256sum is required.\n' >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
[[ -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
|
||||||
|
|
||||||
|
mkdir -p -- "$(dirname -- "$output")"
|
||||||
|
temporary_output="$output.tmp.$$"
|
||||||
|
temporary_checksum="$checksum.tmp.$$"
|
||||||
|
trap 'rm -f -- "$temporary_output" "$temporary_checksum"' EXIT
|
||||||
|
|
||||||
|
qemu-img convert -p -f raw -O vmdk -o subformat=monolithicSparse "$input" "$temporary_output"
|
||||||
|
hash=$(sha256sum < "$temporary_output")
|
||||||
|
printf '%s %s\n' "${hash%% *}" "$(basename -- "$output")" > "$temporary_checksum"
|
||||||
|
mv -- "$temporary_output" "$output"
|
||||||
|
mv -- "$temporary_checksum" "$checksum"
|
||||||
|
trap - EXIT
|
||||||
|
|
||||||
|
qemu-img info "$output"
|
||||||
|
printf 'SHA-256: %s\n' "$checksum"
|
||||||
Reference in New Issue
Block a user