LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-02-2012, 10:22 AM   #1
czezz
Member
 
Registered: Nov 2004
Distribution: Slackware/Solaris
Posts: 924

Rep: Reputation: 43
Software Raid - maintenance


Assumptions:
- Linux software RAID1
- /dev/md0 = /dev/sdb1 + /dev/sdc1
- /dev/md0 mount point /data
- no spare disk

It is very easy to replace fail disk of the array when the system is up and running. Lets say disk /dev/sdc fail. A few steps need to be done to replace a disk:
Code:
mark bad disk:
# mdadm --manage /dev/md0 --fail /dev/sdc1

remove bad disk:
# mdadm --manage /dev/md0 --remove /dev/sdc1

reboot and replace bad disk

copy a disk layout for a new disk
# sfdisk -d /dev/sdb | sfdisk /dev/sdc

add a new disk to array and wait for resynchronization
# mdadm --manage /dev/md0 --add /dev/sdc1
Done

But, lets say we have a situation where one of disk fail and just after this machine has a power failure.
When it starts again there is no way to use /dev/md0 again and it means that all files at file system /data are not available.

Is there any procedure to restore it ?

Last edited by czezz; 09-02-2012 at 12:52 PM.
 
Old 09-02-2012, 12:16 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
In the scenario you proposed, the system will start with md0 in degraded mode following the fsck during initialization. You can then replace the failed drive as usual.
 
Old 09-02-2012, 12:45 PM   #3
czezz
Member
 
Registered: Nov 2004
Distribution: Slackware/Solaris
Posts: 924

Original Poster
Rep: Reputation: 43
I have just tried to use fsck. I dont really how can it helps ?
Please, have a look at output:
Note - I have changed scenerio. In fact fail disk is /dev/sdc

Code:
root@cslack:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md0 : inactive sdb1[2](S)
      203648 blocks super 1.2

unused devices: <none>

root@cslack:~# fsck -t ext4 /dev/md0
fsck from util-linux 2.21.2
e2fsck 1.42.5 (29-Jul-2012)
/sbin/e2fsck: Invalid argument while trying to open /dev/md0

The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>

root@cslack:~#  e2fsck -b 8193 /dev/md0
e2fsck 1.42.5 (29-Jul-2012)
e2fsck: Invalid argument while trying to open /dev/md0

The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>

Last edited by czezz; 09-02-2012 at 12:59 PM.
 
Old 09-02-2012, 01:31 PM   #4
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
The init software used by your distribution doesn't start degraded raid arrays (inactive). You will have to start the array manually.

Code:
mdadm -S /dev/md0
mdadm --assemble --scan --run
You can then fsck the array.
 
Old 09-02-2012, 01:56 PM   #5
czezz
Member
 
Registered: Nov 2004
Distribution: Slackware/Solaris
Posts: 924

Original Poster
Rep: Reputation: 43
Code:
root@cslack:~# mdadm -S /dev/md0
mdadm: stopped /dev/md0

root@cslack:~# mdadm --assemble --scan --run

root@cslack:~# fsck.ext4 /dev/sdb1
e2fsck 1.42.5 (29-Jul-2012)
ext2fs_open2: Bad magic number in super-block
/sbin/e2fsck: Superblock invalid, trying backup blocks...
/sbin/e2fsck: Bad magic number in super-block while trying to open /dev/sdb1

The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>

root@cslack:~# e2fsck -b 8193 /dev/sdb1
e2fsck 1.42.5 (29-Jul-2012)
e2fsck: Invalid argument while trying to open /dev/sdb1

The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
I have just tried to simply mount disk to see is there are any data yet... no luck
Code:
root@cslack:~# mount /dev/sdb1 /mnt/tmp/
NTFS signature is missing.
Failed to mount '/dev/sdb1': Invalid argument
The device '/dev/sdb1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
 
Old 09-02-2012, 02:36 PM   #6
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
You assembled the raid array; /proc/mdstat should show it active. You must then fsck the array, not the underlying device.
 
1 members found this post helpful.
Old 09-02-2012, 03:22 PM   #7
czezz
Member
 
Registered: Nov 2004
Distribution: Slackware/Solaris
Posts: 924

Original Poster
Rep: Reputation: 43
Now I got this!
Thank you.

Code:
root@cslack:~# mdadm -S /dev/md0
mdadm: stopped /dev/md0
root@cslack:~# mdadm --assemble --scan --run
mdadm: /dev/md/0 has been started with 1 drive (out of 2).
root@cslack:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md0 : active raid1 sdb1[0]
      200640 blocks super 1.2 [2/1] [U_]
root@cslack:~# sfdisk -d /dev/sdb | sfdisk /dev/sdc
root@cslack:~# mdadm --manage /dev/md0 --add /dev/sdc1
mdadm: added /dev/sdc1

root@cslack:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md0 : active raid1 sdc1[2] sdb1[0]
      200640 blocks super 1.2 [2/2] [UU]

unused devices: <none>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Server maintenance documentation software? ncsuapex Linux - Software 6 12-30-2008 04:10 PM
Adding an old software-RAID array to a software-RAID installation.. Boot problems GarethM Linux - Hardware 2 05-05-2008 03:16 PM
Linux Pool Maintenance Software? Crazed_Mofo Linux - Software 1 04-19-2006 06:50 PM
Maintenance and installing new software a nightmare? sthemage Linux - General 12 03-07-2006 08:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration