So, why VM Build scripts, and not real build scripts (as in building ISO's )?
Because building ISO's takes time, and if you're gonna run it in a VM like VirtualBox, then why not save some time :)
For building real iso's, go read Custom Kali desktop build - chapter one and Custom Kali desktop build - chapter two
But, let's have a look at OffSecs VM build scripts.
First, you'll need a Kali machine, and VirtualBox, or some other VM, here it's VBox.
First install it / GIT Clone it
sudo apt install git
git clone https://gitlab.com/kalilinux/build-scripts/kali-vm.git
cd kali-vm/
Now, install some dependencies
sudo apt install debos p7zip qemu-utils zerofree
Now, let's talk switches for the build script for a bit.
./build.sh -h
Usage: build.sh [<option>...] [-- <debos option>...]
Build a Kali Linux OS image.
Build options:
-a ARCH Build an image for this architecture, default: amd64
Supported values: amd64 i386
-b BRANCH Kali branch used to build the image, default: kali-rolling
Supported values: kali-dev kali-last-snapshot kali-rolling
-f FORMAT Format to export the image to, default depends on the VARIANT
Supported values: ova ovf raw qemu virtualbox vmware
-k Keep raw disk image and other intermediary build artifacts
-m MIRROR Mirror used to build the image, default: http://http.kali.org/kali
-r ROOTFS Rootfs to use to build the image, default: none
-s SIZE Size of the disk image in GB, default: 80
-v VARIANT Variant of image to build (see below for details), default: generic
Supported values: generic qemu rootfs virtualbox vmware
-z Zip images and metadata files after the build
Customization options:
-D DESKTOP Desktop environment installed in the image, default: xfce
Supported values: e17 gnome i3 kde lxde mate none xfce
-L LOCALE Set locale, default: en_US.UTF-8
-P PACKAGES Install extra packages (comma/space separated list)
-T TOOLSET The selection of tools to include in the image, default: default
Supported values: default everything headless large none
-U USERPASS Username and password, separated by a colon, default: kali:kali
-Z TIMEZONE Set timezone, default: US/Eastern
The different variants of images are:
generic Image with all virtualization support pre-installed, default format: raw
qemu Image with QEMU and SPICE guest agents pre-installed, default format: qemu
rootfs Not an image, a root filesystem (no bootloader/kernel), packed in a .tar.gz
virtualbox Image with VirtualBox guest utilities pre-installed, default format: virtualbox
vmware Image with Open VM Tools pre-installed, default format: vmware
The different formats are:
ova streamOptimized VMDK disk image, OVF metadata file, packed in a OVA archive
ovf monolithicSparse VMDK disk image, OVF metadata file
raw sparse disk image, no metadata
qemu QCOW2 disk image, no metadata
virtualbox VDI disk image, .vbox metadata file
vmware 2GbMaxExtentSparse VMDK disk image, VMX metadata file
Supported environment variables:
http_proxy HTTP proxy URL, refer to the README for more details.
Refer to the README for examples.
These are the switches / parameters for the build script, so what do we need. It depends on what we want,
./build.sh -v virtualbox -s 150 -T everything
#Choose VirtualBox format, disk 150 GB, and type everything (All tools)
This is the generic way, but I would go for something like this
./build.sh -b kali-rolling -v virtualbox -s 150 -T default -D mate
And maybe thow in a -U kali:kali for setting the user and password to kali:kali, and since I'm not a native english speaker, I would problably set locale and timezone also ;)
The advantage of this is that building these images is fast, even on a laptop, so to build a test system, as a base for a custom VM takes no time, and is much faster than building a real ISO made for installation.
At least if you want a custom ISO, that takes time. A way to shorten build time and effort when it comes to install ISO's is taking the time to do it by hand the first time, and then write a good build script for repeating the process, so I highly recommend learning to write build scripts for ISO's also :)
Much Happy Hacking :)