0

I have recently built a Raspberry Pi 3b+ with Kali Linux for the Pi (https://images.offensive-security.com/arm-images/kali-linux-2018.2-rpi3-nexmon.img.xz).

I have unpacked and dd the image onto my 32GB SanDisk microSD card. It has been configured for headless operation to connect to it with my cellphone for C&C through following this guide: https://null-byte.wonderhowto.com/how-to/set-up-headless-raspberry-pi-hacking-platform-running-kali-linux-0176182/

I can login to the Pi just fine, but as I started loading tools onto it through apt-get and Kali repositories, during the install of Metasploit (and dependencies) it error saying there was not enough space. Considering I access this through my phone, I am having to type the output I am seeing, so the format may be off, but the information is proper to the best of my ability. All commands are run as root.

First I did a df -h which shows:

Filesystem       Size    Used   Avail  Use%   Mounted On
/dev/root        6.7G    6.3G    31M   100%   /
devtmpfs         460M       0   460M     0%   /dev
tmpfs            464M       0   464M     0%   /dev/shm
tmpfs            464M     13M   452M     3%   /run
tmpfs            5.0M       0   5.0M     0%   /run/lock
tmpfs            464M       0   464M     0%   /sys/fs/cgroup
/dev/mmcblk0p1    61M     22M    40M    36%   /boot
tmpfs             93M     12K    93M     1%   /run/user/0
tmpfs             93M    4.0K    93M     1%   /run/user/109

I also did a lsblk output:

NAME          MAJ:MIN    RM    SIZE  RO   TYPE MOUNT
mmcblk0       179:0       0   29.7G   0   disk
|-mmcblk0p1   179:1       0     61M   0   part /boot
|-mmcblk0p2   179:2       0   29.7G   0   part /

I also tried a manual resize of the partitions, fdisk -l reports:

Device          Boot    Start         End   Sectors   Size  Id  Type
/dev/mmcblk0p1              1      125000    125000    61M   c  W95 FAT32 (LBA)
/dev/mmcblk0p2         125001    62333951  62208951  29.7G  83  Linux

As suggested, I also tried resize2fs /dev/mmcblk0p2:

Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 4
resize2fs: Permission denied to resize filesystem

I tried also installing both a 2015 and a 2016 copy of raspi-config to use the expand file system part.

As you can see, the /dev/mmcblk0p2 does register as 32GB and mounted to / but the /dev/root which is also mounted to / only shows 6.7GB in size (which was the default after flashing Kali originally). I work in cyber but I do not do pen testing, nor am I a net/sys admin, so I am out of my element here. I just don't know what else I can do to fix this problem. I don't understand why / shows as 32GB in one place but only 7GB in another.

I don't mind wiping the card and starting over, but I would like to avoid it if possible. I also understand that the card may be physically damaged, had too many writes, or be partially "ghostlocked" as suggested by some forum posts. I would like to try a few more things before I accept the card as bad and having to replace it.

1

Probably because you adjusted partition table with fdisk, but did not resize the partition with resize2fs

See Expanding partition on SD

Try running sudo resize2fs /dev/mmcblk0p2

NOTE This is what raspi-config does - it also sets the OS to run resize2fs on reboot.

  • Did you use sudo? It is safest to reboot immediately before use. I haven't used Kali, but it should work. You can also mount on another Linux system (even the Pi itself running Raspbian). – Milliways May 12 '18 at 1:16
  • Sorry I had to update the question to post the full output, yes I tried with sudo, but Kali also defaults to root login, so I am doing this as root. It was off earlier, so it was a fresh boot before I tried the command you suggested. – Katya Veselnitskaya May 12 '18 at 1:16
0

I was able to fix the issue by plugging the card into another Kali machine and doing:

umount /dev/sdf2
fsck.ext4 /dev/sdf2

The /dev/sdf2 may differ on other machines, but I had to answer a few questions with a (all) and y (yes) for the fsck.ext4 check. It output a lot of fixed error messages and then a warning that the file system was modified. I removed the card from the desktop machine and put it back into the Pi, after boot I was able to do df -h to verify that / was 30GB in size as intended.

I am giving the points to @Milliways due to him suggesting me mount in another Linux machine, as I had not considered that it would matter, and that fsck would fix the error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.