万博网页版登陆页派论坛

如创建一个定制的Raspberry Pi ARM版Kali Linux镜像

树老大 发表于 2016-3-16 10:37:04 | 显示全部楼层 |阅读模式
01. 创建Kali rootfs

创建一个armel架构的如Kali文档中所述的Kali rootfs.最后生成的rootfs将位于~/arm-stuff/rootfs/kali-armel目录.

02. 创建镜像文件

然后,我们创建用于存放我们Raspberry Pi rootfs和boot镜像的物理镜像文件.

  1. apt-get install kpartx xz-utils sharutils
  2. cd ~
  3. mkdir -p arm-stuff
  4. cd arm-stuff/
  5. mkdir -p images
  6. cd images
  7. dd if=/dev/zero of=kali-custom-rpi.img bs=1MB count=5000
复制代码

03. 分区并挂载镜像文件

  1. parted kali-custom-rpi.img --script -- mklabel msdos
  2. parted kali-custom-rpi.img --script -- mkpart primary fat32 0 64
  3. parted kali-custom-rpi.img --script -- mkpart primary ext4 64 -1
复制代码
  1. loopdevice=`losetup -f --show kali-custom-rpi.img`
  2. device=`kpartx -va $loopdevice| sed -E 's/.*(loop[0-9])p.*/1/g' | head -1`
  3. device="/dev/mapper/${device}"
  4. bootp=${device}p1
  5. rootp=${device}p2

  6. mkfs.vfat $bootp
  7. mkfs.ext4 $rootp
  8. mkdir -p root
  9. mkdir -p boot
  10. mount $rootp root
  11. mount $bootp boot
复制代码

04. 复制和修改Kali rootfs

  1. rsync -HPavz /root/arm-stuff/rootfs/kali-armel/ root
  2. echo nameserver 8.8.8.8 > root/etc/resolv.conf
复制代码

05. 编译Raspberry Pi内核和模块

如果你不是以ARM硬件作为开发环境,需要搭建ARM交叉编译环境来编译ARM内核和模块.完成后,执行如下命令.

  1. cd ~/arm-stuff
  2. mkdir -p kernel
  3. cd kernel
  4. git clone https://github.com/raspberrypi/tools.git
  5. git clone https://github.com/raspberrypi/linux.git raspberrypi
  6. cd raspberrypi
  7. export ARCH=arm
  8. export CROSS_COMPILE=~/arm-stuff/kernel/toolchains/arm-eabi-linaro-4.6.2/bin/arm-eabi-
  9. make bcmrpi_cutdown_defconfig
  10. # configure your kernel !
  11. make menuconfig
  12. make -j$(cat /proc/cpuinfo|grep processor|wc -l)
  13. make modules_install INSTALL_MOD_PATH=~/arm-stuff/images/root
  14. cd ../tools/mkimage/
  15. python imagetool-uncompressed.py ../../raspberrypi/arch/arm/boot/Image
  16. cd ~/arm-stuff/images
  17. git clone git://github.com/raspberrypi/firmware.git rpi-firmware
  18. cp -rf rpi-firmware/boot/* boot/
  19. rm -rf rpi-firmware
复制代码

  1. cp ~/arm-stuff/kernel/tools/mkimage/kernel.img boot/
  2. echo "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait" >  boot/cmdline.txt
  3. umount $rootp
  4. umount $bootp
  5. kpartx -dv $loopdevice
  6. losetup -d $loopdevice
复制代码

使用dd工具克隆这个文件到你的SD卡.在本例中,我们假设存储设备在/dev/sdb.请按需修改.

  1. dd if=kali-pi.img of=/dev/sdb bs=1M
复制代码

dd操作完成后,卸载并弹出SD卡.然后启动进入到Kali Linux
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版 | Archiver | 万博网页版登陆页派论坛 ( 粤ICP备15075382号-1 )