Skip to content

Instantly share code, notes, and snippets.

@jfstenuit
Last active April 17, 2018 12:37
Show Gist options
  • Save jfstenuit/e1f1fc7512b6f9abc4dedac43002b742 to your computer and use it in GitHub Desktop.
Save jfstenuit/e1f1fc7512b6f9abc4dedac43002b742 to your computer and use it in GitHub Desktop.
Installing Kali on headless Xen system

Get the Kali netinstall ISO

 cd /root/iso
 wget 'http://http.kali.org/dists/kali-rolling/main/installer-amd64/current/images/netboot/mini.iso'

Create storage for the Kali VM

 lvcreate -n kali-disk -L 40G vg
 lvcreate -n kali-swap -L 4G  vg
 mkfs.ext4 /dev/vg/kali-disk
 mkswap /dev/vg/kali-swap

Mount the ISO image

 mount -t iso9660 -o loop /root/iso/mini.iso /media/cdrom

Configure the Xen VM config (here /etc/xen/kali.cfg) to boot from the Installer image

kernel      = '/media/cdrom/linux'
ramdisk     = '/media/cdrom/initrd.gz'

vcpus       = '2' 
memory      = '2048'

root        = '/dev/xvda1 ro'
disk        = [   
                  'phy:/dev/vg/kali-disk,xvda1,w',
                  'phy:/dev/vg/kali-swap,xvda2,w',
                  'file:/root/iso/install.iso,xvdb:cdrom,r',
              ]   

Boot the VM - as no graphic display is available, it will fall back to text installer.

xl create -c /etc/xen/kali.cfg

After the VM is created, it will reboot into the installer. One this is done, "power off" the VM

xl destroy <vm id>

Then edit back the configuration file to use your host kernel. You could use Kali's own kernel, but I'm not sure it is Xen-aware. Also, you should remove the reference to the installer's ISO file.

kernel      = '/boot/vmlinuz-4.9.0-3-amd64'
ramdisk     = '/boot/initrd.img-4.9.0-3-amd64'

vcpus       = '2' 
memory      = '2048'

root        = '/dev/xvda1 ro'
disk        = [   
                  'phy:/dev/vg/kali-disk,xvda1,w',
                  'phy:/dev/vg/kali-swap,xvda2,w',
              ]   

That's it. You should end up with a basic system, so best to install the SSH server and the various kali stuff :

# apt-get install openssh-server
# systemctl enable ssh.service
# systemctl start ssh
# apt-get install kali-linux kali-linux-web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment