My main question:
How to create a GZIP compressed OVA file?
Not "create OVA first, then wrap it into a TAR.GZ." please. A "directly" gzip compressed OVA.
An OVA file is supposedly just a TAR file and in theory should support GZIP compression. (See below for references.)
Create OVA from Command Line using TAR - GZIP - Broken
Trying to import a VirtualBox OVA that I created manually using the command line, I am getting a
VERR_TAR_BAD_CHKSUM_FIELD error.
This was my command to manually create the OVA from command line using
tar (broken):
Code: Select all
tar --gzip --create --verbose --directory=/home/user/temp --file temp.ova temp-disk001.vmdk temp-disk002.vmdk temp.mf temp.ovf
temp-disk001.vmdk temp-disk002.vmdk temp.mf temp.ovf
Trying to import... No... Failing...
Code: Select all
vboxmanage import temp.ova ; echo $?
Progress state: VBOX_E_IPRT_ERROR
VBoxManage: error: Appliance read failed
VBoxManage: error: Error reading OVA '/home/user/temp/temp.ova' (VERR_TAR_BAD_CHKSUM_FIELD)
VBoxManage: error: Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component ApplianceWrap, interface IAppliance
VBoxManage: error: Context: "RTEXITCODE handleImportAppliance(HandlerArg*)" at line 471 of file VBoxManageAppliance.cpp
Create OVA from Command Line using TAR - Functional - But lacking GZIP Compression
If I drop
--gzip from
tar parameters it's functional.
This was my command to manually create the OVA from command line using
tar (functional):
Code: Select all
tar --create --verbose --directory=/home/user/temp --file temp.ova temp-disk001.vmdk temp-disk002.vmdk temp.mf temp.ovf
Then import works.
Code: Select all
vboxmanage import temp.ova ; echo $?
[...]
0
Notes:
For the error
VERR_TAR_BAD_CHKSUM_FIELD I have found the related VirtualBox source code. [1] [2]
What tar checksum does VirtualBox expect? I tried to learn more about if tar checksums exist and how they work but I couldn't figure out anything yet. See also
Does the tar format support checksums?
Also
tar parameter
--format=ustar did not help.
- What I am not looking for is vboxmanage modifymedium --compact / zerofree because that is already discussed elsewhere, it's great, and I am already using that. Additional gzip compression on top of it would be even better.
- What my main goal? A gzip compressed `.ova` VirtualBox appliances that can be imported directly into VirtualBox without an additional `.tar.gz`.
- Aren't VirtualBox ova's compressed anyhow? No. These are just tar files. Not gzip or xz compressed archives.
- But the `.vmdk` files in `.ova` files are compressed? Yes, but the compression is limited. By using an additional `.tar.gz` with maximum compression, the `.ova` gets smaller.
- Why not use an additional `.tar.gz` file? Compression, speed, usability, simplicity.
- Why do you think that VirtualBox can import `.ova`s that are actually `.tar.gz` files? In How to compress disk images (VMDK) inside an OVA with GZIP during VirtualBox export? I posted various references to gzip being mentioned in VirtualBox source code and OVA specification.
- Is How to compress disk images (VMDK) inside an OVA with GZIP during VirtualBox export? a duplicate? No. That one is about gzip compression of disk images inside OFV / OVA. This forum thread is about gzip compressed OVA. It's not exactly the same. It's a different approach that might accomplish the same end goal of better OVA compression.
- Why am I mentioning all of this? Because most questions that I've seen go into direction of `vboxmanage modifymedium --compact` / `zerofree`. Therefore I wanted to be very specific here: An `.ova` file that is gzip compressed.
[1]
Code: Select all
/**
* Validates the TAR header.
*
* @returns VINF_SUCCESS if valid, VERR_TAR_ZERO_HEADER if all zeros, and
* the appropriate VERR_TAR_XXX otherwise.
* @param pTar The TAR header.
* @param penmType Where to return the type of header on success.
*/
static int rtZipTarHdrValidate(PCRTZIPTARHDR pTar, PRTZIPTARTYPE penmType)
{
/*
* Calc the checksum first since this enables us to detect zero headers.
*/
int32_t i32ChkSum;
int32_t i32ChkSumSignedAlt;
if (rtZipTarCalcChkSum(pTar, &i32ChkSum, &i32ChkSumSignedAlt))
return VERR_TAR_ZERO_HEADER;
/*
* Read the checksum field and match the checksums.
*/
int64_t i64HdrChkSum;
int rc = rtZipTarHdrFieldToNum(pTar->Common.chksum, sizeof(pTar->Common.chksum), true /*fOctalOnly*/, &i64HdrChkSum);
if (RT_FAILURE(rc))
return VERR_TAR_BAD_CHKSUM_FIELD;
if ( i32ChkSum != i64HdrChkSum
&& i32ChkSumSignedAlt != i64HdrChkSum) /** @todo test this */
return VERR_TAR_CHKSUM_MISMATCH;
[2]
Code: Select all
/*
* Copyright (C) 2010-2020 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
Create OVA from Command Line using VBoxManage - GZIP - Broken
This is might actually be a different approach from above. The following might create (if that was working) an ova that is wrapped into a separate tar.gz?
Syntax shown when running "VBoxManage export" (built-in help).
Code: Select all
VBoxManage export <machines> --output|-o <name>.<ovf/ova/tar.gz>
functional:
Code: Select all
vboxmanage export test --output test.ova
So a uncompressed ova can be created using vboxmanage.
broken:
Code: Select all
vboxmanage export test --output test.tar.gz
Code: Select all
vboxmanage export test --output test.ova.tar.gz
In both cases...
VBoxManage: error: Appliance file must have .ovf or .ova extension
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component ApplianceWrap, interface IAppliance, callee nsISupports
VBoxManage: error: Context: "Write(Bstr(strOvfFormat).raw(), ComSafeArrayAsInParam(options), Bstr(pszAbsFilePath).raw(), progress.asOutParam())" at line 1934 of file VBoxManageAppliance.cpp
Is this a bug or am I using it wrong?