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

Richard Weinberger richard.weinberger at gmail.com
Tue May 5 07:35:08 PDT 2015


On Mon, May 4, 2015 at 2:42 PM, Marcin Adamski <mass85 at tlen.pl> wrote:
> 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?

I'd say "it's complicated". :)

UBIFS was created to deal with such situations.
If you want to be on the safe side, use it.

-- 
Thanks,
//richard



More information about the linux-mtd mailing list