# Ext4 on mdadm reverting data

I have a problem with my home server setup. The problem is that sometimes, but really rarely, it reverts (for a lack of a better term) all my data back to an earlier state (somewhere between months and weeks earlier).

The setup is a 4TB ext4 on a Software RAID 5 with 3 disks running on an Ubuntu 12.04 (linux 3.2). Samba serves files of that partition.

/proc/mdstat tells me that the array is healthy smartclt -H /dev/sdX says PASSED for all devices. I tried to find something in the logs but I couldn't find anything suspicious.

Last time the error occurred I rebooted the server whilst using files on the shear however fsck didn't find any errors.

The nature of the error baffles me. Since ext is not a copy on write file system, I would have assumed something like this is impossible. If you can think of any diagnostics I can run, please don't hesitate.

I guess the question is what happened to my data and how can I stop it from happening again?

— edit —

OK I found the error:
The problem had nothing to do with ext4. The problem was the way I mounted the device.

I have the raid 5 for my data and a raid 0 with an backup. But the way I mounted this at startup was not 100% stable; sometimes the backup was mounted as the main.

From /etc/fstab:

# main RAID array
/dev/md126p1 /media/Main        ext4    defaults        0       0


From /etc/mdadm/mdadm.conf:

# definitions of existing MD arrays
ARRAY /dev/md/Main metadata=1.2 UUID=c2ccbd00:ce414404:0ee05911:eebe2832
ARRAY /dev/md/Backup metadata=1.2 UUID=b4973c41:e735e1c0:29e8be4b:4fe7c007 name=:Backup


Whoever can answer me this small question gets the bounty: What is the best way to mount the backup and the main in a guaranteed stable way.

–edit–

/dev/md/Backup:

    Version : 1.2
Creation Time : Sun Jun 19 15:45:35 2011
Raid Level : raid0
Array Size : 3907021824 (3726.03 GiB 4000.79 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent

Update Time : Sun Jun 19 15:45:35 2011
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Chunk Size : 512K

Name : :Backup
UUID : b4973c41:e735e1c0:29e8be4b:4fe7c007
Events : 0

Number   Major   Minor   RaidDevice State
0       8       33        0      active sync   /dev/sdc1
1       8       81        1      active sync   /dev/sdf1


/dev/md/Main:

    Version : 1.2
Creation Time : Sun Jun 12 02:13:25 2011
Raid Level : raid5
Array Size : 3907021568 (3726.03 GiB 4000.79 GB)
Used Dev Size : 1953510784 (1863.01 GiB 2000.40 GB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent

Intent Bitmap : Internal

Update Time : Mon Jan 28 19:00:45 2013
State : active
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 128K

Name : :Neue RAID-Anordnung
UUID : c2ccbd00:ce414404:0ee05911:eebe2832
Events : 17846

Number   Major   Minor   RaidDevice State
0       8       49        0      active sync   /dev/sdd1
1       8        1        1      active sync   /dev/sda1
3       8       65        2      active sync   /dev/sde1


• The best way is to mount using UUIDs, in your fstab:

UUID=c2ccbd00:ce414404:0ee05911:eebe2832 /media/Main ext4 defaults 0 0
UUID=b4973c41:e735e1c0:29e8be4b:4fe7c007 /media/Backup ext4 defaults 0 0


As pointed out by @Floyd, using labels is also nice, since you could create a new device with the same data and the same label if you need to change things. So you can do

tune2fs -L RAIDMain /dev/disk/by-uuid/c2ccbd00:ce414404:0ee05911:eebe2832
tune2fs -L RAIDBackup /dev/disk/by-uuid/b4973c41:e735e1c0:29e8be4b:4fe7c007


and then in your fstab:

LABEL=RAIDMain /media/Main ext4 defaults 0 0
LABEL=RAIDBackup /media/Backup ext4 defaults 0 0