HOWTO: Repair filesystem using fsck on a raid setup

From Sabayon Wiki
Jump to: navigation, search

If you need to check your filesystem on a raid setup, here is a quick way to get to it. Boot your sabayon live desktop and open up a terminal and become root. (type su and the password in live is "root") There is a command that can quickly scan your raid setup it looks like this:

sabayon sabayonuser # mdadm --examine --scan
ARRAY /dev/md1 level=raid1 num-devices=2 UUID=18da210b:6e9d1d99:38c4b11d:065b4669
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=55af4bbb:9f0a9666:7c15b592:e914b925
ARRAY /dev/md2 level=raid1 num-devices=2 UUID=a9921c21:43cc1f10:fb25275b:4b619534

My example has 3 partitions, /boot a swap and a / partition. On my / partition (/dev/md2 in the array) i'm getting a warning so in this example i'm going to check this out.

For our next step we simply do the same but we store this output in a file so the next step can use this information.

Step 1.

sabayon sabayonuser # mdadm --examine --scan >> /etc/mdadm.conf

Step 2.

sabayon sabayonuser # mdadm --assemble /dev/md2

mdadm: /dev/md2 has been started with 2 drives.

Step 3.

From here it works like any normal fsck.

sabayon sabayonuser # fsck /dev/md2
fsck 1.41.3 (12-Oct-2008)
e2fsck 1.41.3 (12-Oct-2008)
/dev/md2 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Inodes that were part of a corrupted orphan linked list found.  Fix<y>? yes

Inode 61670074 was part of the orphaned inode list.  FIXED.
Inode 61671606 was part of the orphaned inode list.  FIXED.
Inode 63766553 was part of the orphaned inode list.  FIXED.
Inode 63766554 was part of the orphaned inode list.  FIXED.
Inode 63766555 was part of the orphaned inode list.  FIXED.
Inode 63766567 was part of the orphaned inode list.  FIXED.
Inode 63766571 was part of the orphaned inode list.  FIXED.
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences:  -61020160 -(61678592--61678942) -(61679616--61679966) -(61680640--61680999)
Fix<y>? yes

Free blocks count wrong for group #1882 (15090, counted=16152).
Fix<y>? yes

Free blocks count wrong (70491297, counted=70492359).
Fix<y>? yes

Inode bitmap differences:  -61669497 -61670074 -61671606 -(63766553--63766555) -63766567 -63766571
Fix<y>? yes

Free inodes count wrong for group #1882 (30730, counted=30733).
Fix<y>? yes

Free inodes count wrong for group #1946 (32751, counted=32756).
Fix<y>? yes

Free inodes count wrong (77558369, counted=77558377).
Fix<y>? yes


/dev/md2: ***** FILE SYSTEM WAS MODIFIED *****
/dev/md2: 331159/77889536 files (0.3% non-contiguous), 7368649/77861008 blocks