So I did a fresh build with the --target raw
option in a virtual debian 8 i386 machine.
Once the raw files were ready, I manually ran the following commands (against both .raw images):
sudo losetup -f -P <whonix-*.raw>
sudo zerofree $(sudo losetup -j <whonix-*.raw> | awk '{print $1}' | cut -d: -f 1)p1
sudo losetup -D
After that, I manually launched the 2500_convert-raw-to-vdi, 2600_create-vbox-vm
and 2700_export-vm
scripts against the previously zeroed raw images.
Note that I had to comment the line
sudo -u "$user_name" VBoxManage modifyvm "$VMNAME" --synthcpu on
in the 2600 script, as I ran into a weird fatal error:
VBoxManage: error: Unknown option: --synthcpu
But I assume it is unrelated to this topic (maybe related to the 32 bits VM?).
_EDIT: OK, this is normal as the feature is not supported anymore in VBox 5 . âš“ T408 --synthcpu was removed from VirtualBox, use --cpuid-portability-level or --cpuidremoveall?
The end result is quite impressive:
Whonix-Gateway-13.0.0.1.4.ova: now 862.8MB instead of 1.8GB!
Whonix-Workstation-13.0.0.1.4.ova: now 990MB instead of 2.1GB!
Moreover, the KVM files seem to also benefit from the zeroing of the raw images. The Whonix-Gateway qcow2 file is reduced to a 826MB tar.gz file (instead of the 1.3GB distributed .xz) . But I don’t know how actual distributed Whonix KVM images are being produced (they are .xz files, I don’t know how to make that?).
For the peace of mind I imported these .ova files into VirtualBox and tested them. Everything worked as usual, only VBoxGuest Additions didn’t seem to work. Again, probably unrelated bug to this topic, but did I miss something during the build process? It’s my first time building Whonix.
I was less successful when trying to add these manual instructions into the 2500_convert-raw-to-vdi script
:
sudo -u "$user_name" \
losetup -f -P "$binary_image_raw"
sudo -u "$user_name" \
zerofree $(losetup -j "$binary_image_raw" | awk '{print $1}' | cut -d: -f 1)p1
sudo -u "$user_name" \
losetup -D
sudo -u "$user_name" \
VBoxManage convertfromraw "$binary_image_raw" "$HOMEVAR/VirtualBox VMs/$VMNAME/$VMNAME.vdi"
It always resulted in a failure (permission denied). I don’t know why I ran into a permission denied error as the script is run with sudo rights. I tried using kpartx as in the mount-raw
script but without success.
Unfortunately, I am afraid my limited bash script skills do not allow me to further patch the build process by myself without great pain. But I am sure someone more advanced will figure it out quickly, and I’ll be happy to learn how!