PDA

View Full Version : Filesystem corruption on RPi 3 B+ when filling expanded SD card



garrett
2018-05-09, 17:56
I have an RPi 3 B+ that I have been trying for weeks to get a full install of Kali on. The install always goes fine, I get the system up and running, I expand the storage to fill the SD card, but as soon as I start to fill the SD card, I get rampant file corruption and bork the entire system.

Hardware:
All of this was performed on a Raspberry Pi 3 B+ using on of two SD cards:


A 64 GB Patriot SD Card (https://smile.amazon.com/gp/product/B00BTYZ3GM/)
A 16 GB Patriot SD Card (https://smile.amazon.com/gp/product/B01EV6TFQ8/)


General Process:
1. I always start by imaging the SD card from my Mac with
sudo dd if=/path/to/img of=/dev/rdisk2 bs=2m
2. Then I boot up the pi, wait a few minutes (for any initial disk writes to finish), then reboot.
3. On the second boot, I expand the storage, then reboot again.
4. Finally I do something that uses up significant disk space, which eventually kills the system.

Images Used:
These are the different Kali images I have attempted these procedures with, in case it was just an issue with just one or a few versions.


kali-linux-light-2018-W16-armhf
kali-linux-2018.1a-rpi3b+-re4son
StickyFingers-Kali-Pi-armhf-180405
kali-linux-2018.1a-rpi3-re4son (didn't boot because the kernel wasn't updated for the 3 B+)
kali-linux-2018.2-rpi3-nexmon

Each of these images (which booted) experienced the same issue.

Expanding Storage:
I have tried several different methods of expanding storage, in case the one I was using was wrong or had an issue. All of these were performed live on the pi.

1. parted


I tried using parted to delete and recreate (bigger) the primary partition in place.
The general procedure can be found here (https://www.elinux.org/RPi_Resize_Flash_Partitions#Manually_resizing_the_ SD_card_on_Raspberry_Pi)


2. raspi-config


I tried cloning raspi-config from here (https://github.com/RPi-Distro/raspi-configw11)
I ran through the gui to expand the root filesystem and rebooted


3. gparted


I found this answer (https://raspberrypi.stackexchange.com/questions/46520/expand-file-system-kali-linux-on-sd-card-of-16gb/77110#77110) saying to try gparted
I followed the method laid out in that post


All of these methods resulted in the same corruption.

Using the Disk:
For each of these methods, the corruption occurred after a significant portion of the disk was used. Because it killed the system, it is difficult to tell exactly when it starts happening, but one attempt after the corruption I was able to run a `df -h` and see it had used about 10 GB (notably, more than the 8 GB in the original partition). On most attempts, I used this much space through `apt-get install kali-linux-full`, leading me to believe that the issue was related to the installation of that meta-package. However, on my most recent attempts, I refrained from doing that particular install and instead used the space by downloading a large wordlist, to the same end result.

The Corruption:
The corruption occurred at different points each time, but all with similar results. Sometimes the install broke partway through, and others it finished seemingly successfully. The wordlist (here (https://thepiratebay.org/torrent/5945498/WPA-PSK_WORDLIST_3_Final_(13_GB).rar)) would never finish fully expanding. In any case, the symptoms remained the same:



Whatever commands I was using at the time started spitting out some strange characters in the output
Commands for installed tools were about 50-50 whether they would run
Built in commands like `ls ` and `shutdown` would start to say either `illegal instruction` or throw a `segmentation fault`
Unable to shut down the pi, I’d eventually pull the power (making sure the SD Card access light was off). Then the pi would not reboot


The Conclusion:
I’m completely out of ideas for what could be causing the issue or how to proceed from here. I very much want a full Kali install which is small and portable, and limiting it to 8 GB is not an option. Any suggestions would be much appreciated.