Software Raid Questions

General support questions
Post Reply
ukhost4u
Posts: 7
Joined: 2007/12/27 13:29:07
Contact:

Software Raid Questions

Post by ukhost4u » 2017/07/25 19:13:52

Hello.

We are running a Linux Raid 1 built during the install of Centos 7. At this time the /dev/sdb drive in the raid failed.

What we have done is replace the drive and its showing at /dev/sdb using fdisk -l

I want to make sure I do this rebuild correct. Currently we have 3 raid volumes dm0 / dm1 / dm2 which are the /boot, / folder and swap. The problem is to rebuild the raid I guess I need to duplicate the partitions on /dev/sda1, /dev/sda2, /dev/sda3 on the /dev/sdb drive. Is there first of all a correct way to do this? Am I also doing this in the correct method.

Then my guess is that I need to resync the raid which I would like to confirm the correct commands for but does look more simple.

Anyway I guess I want to make sure and get this correct first time before I make any mistakes or loose any data.

Any help would be great.

Thanks.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Software Raid Questions

Post by TrevorH » 2017/07/25 19:18:13

Show the contents of /proc/mdstat so we can see how it looks now.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

ukhost4u
Posts: 7
Joined: 2007/12/27 13:29:07
Contact:

Re: Software Raid Questions

Post by ukhost4u » 2017/07/27 15:38:43

Hello.

The output is:

Code: Select all

root@server [~]# cat /proc/mdstat
Personalities : [raid1] 
md0 : active raid1 sda2[0]
      511936 blocks super 1.0 [2/1] [U_]
      
md2 : active raid1 sda3[0]
      451429376 blocks super 1.1 [2/1] [U_]
      bitmap: 4/4 pages [16KB], 65536KB chunk

md1 : active raid1 sda1[0]
      16760832 blocks super 1.1 [2/1] [U_]
      
unused devices: <none>
root@server [~]# 
Also if this helps:

Code: Select all

root@server [~]# fdisk -l

Disk /dev/sda: 480.1 GB, 480103981056 bytes
255 heads, 63 sectors/track, 58369 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b596e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        2089    16777216   fd  Linux raid autodetect
/dev/sda2   *        2089        2153      512000   fd  Linux raid autodetect
/dev/sda3            2153       58370   451560448   fd  Linux raid autodetect

Disk /dev/md1: 17.2 GB, 17163091968 bytes
2 heads, 4 sectors/track, 4190208 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/md2: 462.3 GB, 462263681024 bytes
2 heads, 4 sectors/track, 112857344 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/md0: 524 MB, 524222464 bytes
2 heads, 4 sectors/track, 127984 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/sdb: 480.1 GB, 480103981056 bytes
255 heads, 63 sectors/track, 58369 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

root@server [~]# 
Thanks,

Paul.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Software Raid Questions

Post by TrevorH » 2017/07/27 16:23:38

So you'll want to duplicate the exact layout of your current partition of /dev/sda on the new disk (I presume /dev/sdb). You can do that with sfdisk by listing sda and piping it into sfdisk run against sdb but you can also do it manually if you prefer. I would make sure that if you use fdisk you put it in sector mode and print the current start positions on the partitions on sda so you can create them on the exact same sector on the new disk. Once that's done - it may require a reboot to take effect but if the disk is otherwise unused then it should take effect immediately - then you can use mdadm --add /dev/mdX /dev/sdbY to add each of the new partitions to the md0-2 arrays, one at a time then let each one finish before you start on the next. Make sure you add the correct partition to the correct mdX.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

ukhost4u
Posts: 7
Joined: 2007/12/27 13:29:07
Contact:

Re: Software Raid Questions

Post by ukhost4u » 2017/07/27 16:59:22

Hello.

The new drive is /dev/sdb and the original /dev/sda so your assumption is correct.

I have not used sfdisk much before so do you have some example commands which you would use to do what I need to do?

The raid commands were as I expected but its the partition part which I have never done before.

Thanks,

Paul.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Software Raid Questions

Post by TrevorH » 2017/07/27 17:19:30

Never had to do it myself but google finds a raft of hits using "sfdisk clone partition table". Read a few, use the one that makes the most sense!
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

ukhost4u
Posts: 7
Joined: 2007/12/27 13:29:07
Contact:

Re: Software Raid Questions

Post by ukhost4u » 2017/07/27 17:51:27

Hello.

I have figured it out, easy in the end:

sfdisk -d /dev/sda > part_table

then:

sfdisk /dev/sdb --force < part_table

Thanks,

Paul.

ukhost4u
Posts: 7
Joined: 2007/12/27 13:29:07
Contact:

Re: Software Raid Questions

Post by ukhost4u » 2017/07/27 18:16:38

Hi.

So that anyone else reading this post might run into this situation I have written a guide to help people:

https://www.ukhost4u.com/blog/replacing ... nd-sfdisk/

Any feedback I will be happy to include. Also thanks to: TrevorH

Paul.

Post Reply