Skip to content

Instantly share code, notes, and snippets.

@vanhalt
Created March 30, 2016 05:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanhalt/baffe5becd1914867b9caad40db73f50 to your computer and use it in GitHub Desktop.
Save vanhalt/baffe5becd1914867b9caad40db73f50 to your computer and use it in GitHub Desktop.
Kali Linux ARM (kali-2.1.2-rpi2.img) running on Raspberry 3 with a 32GB micro sd

Installation

Installation steps:

http://docs.kali.org/kali-on-arm/install-kali-linux-arm-raspberry-pi

ARM download site:

https://www.offensive-security.com/kali-linux-arm-images/

If dding from OSX do the following for speed:

$ dd bs=1m if=kali-2.1.2-rpi2.img of=/dev/rdisk2
7000+0 records in
7000+0 records out
7340032000 bytes transferred in 514.267776 secs (14272782 bytes/sec) # fast!

I had a 32GB SD card, this image transform it to a 7GB memory. To fix to the following (inspired by this:

$ cd /boot

$ wget https://raw.githubusercontent.com/lgierth/pimesh/master/files/raspi-expand-rootfs.sh

# Check the partitions

# replace $PART_START with 125001 if fdisk -l shows:
...
/dev/mmcblk0p2      125001 60367871 60242871 28.7G 83 Linux
...

$ chmod -x raspi-expand-rootfs.sh

$ sh raspi-expand-rootfs.sh

$ reboot

After successful reboot, run:

$ resize2fs /dev/mmcblk0p2
#!/bin/sh
#
# Taken from http://www.raspberryvi.org/wiki/doku.php/raspi-expand-rootfs
#
# Resize the root filesystem of a newly flashed Raspbian image.
# Directly equivalent to the expand_rootfs section of raspi-config.
# No claims of originality are made.
# Mike Ray. Feb 2013. No warranty is implied. Use at your own risk.
#
# Run as root. Expands the root file system. After running this,
# reboot and give the resizefs-once script a few minutes to finish expanding the file system.
# Check the file system with 'df -h' once it has run and you should see a size
# close to the known size of your card.
#
# Get the starting offset of the root partition
PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^2" | cut -f 2 -d:)
[ "$PART_START" ] || return 1
# Return value will likely be error for fdisk as it fails to reload the
# partition table because the root fs is mounted
fdisk /dev/mmcblk0 <<EOF
p
d
2
n
p
2
$PART_START
p
w
EOF
# now set up an init.d script
cat <<\EOF > /etc/init.d/resize2fs_once &&
#!/bin/sh
### BEGIN INIT INFO
# Provides: resize2fs_once
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5 S
# Default-Stop:
# Short-Description: Resize the root filesystem to fill partition
# Description:
### END INIT INFO
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting resize2fs_once" &&
resize2fs /dev/mmcblk0p2 &&
rm /etc/init.d/resize2fs_once &&
update-rc.d resize2fs_once remove &&
log_end_msg $?
;;
*)
echo "Usage: $0 start" >&2
exit 3
;;
esac
EOF
chmod +x /etc/init.d/resize2fs_once &&
update-rc.d resize2fs_once defaults &&
echo "Root partition has been resized. The filesystem will be enlarged upon the next reboot"
Copy link

ghost commented Oct 12, 2016

Nice ! Thank you !

@danielcaruaru
Copy link

Thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment