File in JFFS2 corrupted after power loss during removal of other files

Marcin Adamski mass85 at tlen.pl
Mon May 4 05:42:52 PDT 2015


Hi

I am working with Linux (3.4.31+) embedded system booting from JFFS2 partition. I frequently encounter a problem of a file corruption when power loss occurs while other files are being removed. It happens during upgrade procedure of the platform. These are simplified steps of the upgrade:
1. Download tar.gz containing (among other files) rootfs.squashfs image of file system that I am upgrading to, verify md5 checksum of the image.
2. Boot linux from a small JFFS2 partition that has a minimal set of tools required to perform upgrade.
3. Mount the large partition that must be upgraded.
4. Mount rootfs.squashfs which is stored in the big partition.
5. Remove all files from the large partition except from some migrated data files, the rootfs.squashfs image etc.
6. Copy all files from mounted rootfs.squashfs to the large partition
7. Boot from the large partition

The mentioned power loss occurs in 5. step. Note that the rootfs.squashfs is mounted as read only and is never altered during upgrade. Even though this file gets corrupted and after device is powered on you can see that the file's md5 checksum is different, size stays unchanged, image can be mounted but it is impossible to read some of the files from this image.

Shouldn't JFFS2 deal with this kind of scenario? Is there any way to recover from this situation?

Regards
Marcin Adamski



More information about the linux-mtd mailing list