I have been using a Micro SD card that has been getting corrupted very frequently. I tested it with the badblocks
command on another Linux box and it said there were 0 errors. I also checked it with the F3
Fight False Flash tool and the results were 0% corruption.
I then checked the checksum of the image I was using (Raspbian Jessie Lite) and it was the same as the checksum on the official website. I doubt that the image was corrupted as I wrote the image to the card because I have done it multiple times with other images and until now have had no problems.
The reason I believe it is corrupted is because whenever I do an update/upgrade or shortly after while trying to install a package, it ends up giving a fatal error like:
Selecting previously unselected package htop.
dpkg: unrecoverable fatal error, aborting:
files list file for package 'tzdata' is missing final newline
E: Sub-process /usr/bin/dpkg returned an error code (2)
I have ran the apt-get -f install
command but that does not help. Could it be that I am not giving the Pi enough power? I am using a 2A power supply and have another card that does not have any problems with the Pi 3 and that power adapter. Also, the red light is solid on most of the time, only blinking every couple minutes. I using SSH and running it headless so there is not a great power draw.
What could be the issue? My power supply? The card?
EDIT Forgot to mention, Raspbian Lite automatically expands the filesystem on boot so I know it is not because the file system was full. Also, I ran df -h
and it said 12% full for the /root
partition.
UPDATE I found that I can fix the system by removing the .list
file of the package listed in the dpkg error and then run apt install package --reinstall
. However, my question still remains, why do parts of the file system corrupt like this on a regular basis?
UPDATE After running with -f
I get:
e2fsck 1.42.13 (17-May-2015)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts Unattached inode 139333
Connect to /lost+found<y>? yes
Inode 139333 ref count is 2, should be 1. Fix<y>? yes
Unattached inode 139343 Connect to /lost+found<y>? yes
Inode 139343 ref count is 2, should be 1. Fix<y>? yes
Unattached inode 139380 Connect to /lost+found<y>? yes
Inode 139380 ref count is 2, should be 1. Fix<y>? yes
Inode 139402 ref count is 1, should be 2. Fix<y>? yes
Inode 139403 ref count is 1, should be 2. Fix<y>? yes
Inode 139404 ref count is 1, should be 2. Fix<y>? yes
Inode 139405 ref count is 1, should be 2. Fix<y>? yes
Inode 139406 ref count is 1, should be 2. Fix<y>? yes
Inode 139408 ref count is 1, should be 2. Fix<y>? yes
Inode 139409 ref count is 1, should be 2. Fix<y>? yes
Inode 140012 ref count is 1, should be 2. Fix<y>? yes
Inode 140355 ref count is 1, should be 2. Fix<y>? yes
Pass 5: Checking group summary information
/dev/mmcblk0p2: ***** FILE SYSTEM WAS MODIFIED *****
/dev/mmcblk0p2: 63236/482880 files (0.2% non-contiguous), 452979/1948928 blocks