Custom EfikaMX Image

Table of Contents

The following document describes our own method of creating a custom Kali Linux EfikaMX ARM image and is targeted at developers. If you would like to install a pre-made Kali image, check out our Install Kali on an EfikaMX article.

You’ll need to have root privileges to do this procedure, or the ability to escalate your privileges with the command “sudo su”.

01. Create a Kali rootfs

Build a Kali rootfs as described in our Kali documentation, using an armhf architecture. By the end of this process, you should have a populated rootfs directory in ~/arm-stuff/rootfs/kali-armhf.

02. Create the Image File

Next, we create the physical image file, which will hold our EfikaMX rootfs and boot images.

[email protected]:~$ sudo apt install -y kpartx xz-utils sharutils
[email protected]:~$ mkdir -p ~/arm-stuff/images/
[email protected]:~$ cd ~/arm-stuff/images/
[email protected]:~$ dd if=/dev/zero of=kali-custom-efikamx.img conv=fsync bs=4M count=7000

03. Partition and Mount the Image File

[email protected]:~$ parted kali-custom-efikamx.img --script -- mklabel msdos
[email protected]:~$ parted kali-custom-efikamx.img --script -- mkpart primary ext2 4096s 266239s
[email protected]:~$ parted kali-custom-efikamx.img --script -- mkpart primary ext4 266240s 100%
[email protected]:~$ loopdevice=$( losetup -f --show kali-custom-efikamx.img )
[email protected]:~$ device=$( kpartx -va $loopdevice| sed -E 's/.*(loop[0-9])p.*/\1/g' | head -1 )
[email protected]:~$ device="/dev/mapper/${device}"
[email protected]:~$ bootp=${device}p1
[email protected]:~$ rootp=${device}p2
[email protected]:~$
[email protected]:~$ mkfs.ext2 $bootp
[email protected]:~$ mkfs.ext4 $rootp
[email protected]:~$ mkdir -p boot
[email protected]:~$ mkdir -p root
[email protected]:~$ mount $bootp boot
[email protected]:~$ mount $rootp root

04. Copy and Modify the Kali rootfs

[email protected]:~$ rsync -HPavz /root/arm-stuff/rootfs/kali-armhf/ root
[email protected]:~$ echo nameserver > root/etc/resolv.conf
[email protected]:~$ sed 's/0-1/0//g' root/etc/init.d/udev

05. Compile the EfikaMX Kernel and Modules

If you’re not using ARM hardware as the development environment, you will need to set up an ARM cross-compilation environment to build an ARM kernel and modules. Once that’s done, proceed with the following instructions.

[email protected]:~$ mkdir -p ~/arm-stuff/kernel/
[email protected]:~$ cd ~/arm-stuff/kernel/
[email protected]:~$ git clone --depth 1
[email protected]:~$ cd linux-legacy/
[email protected]:~$ export ARCH=arm
[email protected]:~$ export CROSS_COMPILE=~/arm-stuff/kernel/toolchains/arm-eabi-linaro-4.6.2/bin/arm-eabi-
[email protected]:~$ make efikamx_defconfig

# configure your kernel !
[email protected]:~$ make menuconfig
[email protected]:~$ make -j$(cat /proc/cpuinfo|grep processor | wc -l)
[email protected]:~$ make modules_install INSTALL_MOD_PATH=~/arm-stuff/images/root
[email protected]:~$ make uImage
[email protected]:~$ cp arch/arm/boot/uImage ~/arm-stuff/images/boot
[email protected]:~$
[email protected]:~$ cat <<EOF > ~/arm-stuff/images/boot/boot.script
setenv ramdisk uInitrd;
setenv kernel uImage;
setenv bootargs console=tty1 root=/dev/mmcblk0p2 rootwait rootfstype=ext4 rw quiet;
${loadcmd} ${ramdiskaddr} ${ramdisk};
if imi ${ramdiskaddr}; then; else
setenv bootargs ${bootargs} noinitrd;
setenv ramdiskaddr "";
${loadcmd} ${kerneladdr} ${kernel}
if imi ${kerneladdr}; then
bootm ${kerneladdr} ${ramdiskaddr}
[email protected]:~$
[email protected]:~$ mkimage -A arm -T script -C none -n "Boot.scr for EfikaMX" -d ~/arm-stuff/images/boot/boot.script ~/arm-stuff/images/boot/boot.scr
[email protected]:~$ umount $bootp
[email protected]:~$ umount $rootp
[email protected]:~$ kpartx -dv $loopdevice
[email protected]:~$ losetup -d $loopdevice

Use the dd command to image this file to your SD card. In our example, we assume the storage device is located at /dev/sdb. Change this as needed.

[email protected]:~$ dd if=kali-linux-efikamx.img of=/dev/sdb conv=fsync bs=4M

Once the dd operation is complete, unmount and eject the SD card and boot your EfikaMX into Kali Linux

Updated on: 2022-Aug-14
Author: steev