All of lore.kernel.org
 help / color / mirror / Atom feed
* add new disk with dd
@ 2021-04-29  8:52 d tbsky
  2021-04-29  9:05 ` Roman Mamedov
  2021-04-29  9:21 ` Mateusz
  0 siblings, 2 replies; 6+ messages in thread
From: d tbsky @ 2021-04-29  8:52 UTC (permalink / raw)
  To: list Linux RAID

Hi:
   I want to replace a fault disk for software raid5. there is
something like grub/biosgrub at the beginning of the disk, so if I can
use command below to copy them:

"dd if=/dev/sda of=/dev/sdb bs=1M count=10"

if it is a gpt disk I can use sgdisk to copy the partition table then
radmonize guid.

however dd may also copy the mdadm superblock which include internal
bitmap(since I don't caculate correct size). I don't know if there is
risk that mdadm will be confused with the bitmap in new disk. although
I have tried and it seems work fine.

should I disable internal bitmap before add new disk? or mdadm will
understand the superblock/bitmap at new disk is invalid and just
overwrite everything?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: add new disk with dd
  2021-04-29  8:52 add new disk with dd d tbsky
@ 2021-04-29  9:05 ` Roman Mamedov
  2021-04-29  9:21 ` Mateusz
  1 sibling, 0 replies; 6+ messages in thread
From: Roman Mamedov @ 2021-04-29  9:05 UTC (permalink / raw)
  To: d tbsky; +Cc: list Linux RAID

On Thu, 29 Apr 2021 16:52:21 +0800
d tbsky <tbskyd@gmail.com> wrote:

> Hi:
>    I want to replace a fault disk for software raid5. there is
> something like grub/biosgrub at the beginning of the disk, so if I can
> use command below to copy them:
> 
> "dd if=/dev/sda of=/dev/sdb bs=1M count=10"
> 
> if it is a gpt disk I can use sgdisk to copy the partition table then
> radmonize guid.

Do you use whole disks or partitions as MD members? Better use partitions. And
if so, you can simply run "wipefs -a /dev/sdb1" after your dd, to wipe all the
MD metadata that got copied.

> however dd may also copy the mdadm superblock which include internal
> bitmap(since I don't caculate correct size). I don't know if there is
> risk that mdadm will be confused with the bitmap in new disk. although
> I have tried and it seems work fine.

Without wiping the metadata, don't plug in both disks at the same time, and
don't even plug in the new disk alone. With metadata at the beginning, mdadm
might pick up the new one as a normally operating array member, whereas it
only has 10 MB of the actual data copied to it.

-- 
With respect,
Roman

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: add new disk with dd
  2021-04-29  8:52 add new disk with dd d tbsky
  2021-04-29  9:05 ` Roman Mamedov
@ 2021-04-29  9:21 ` Mateusz
  2021-04-29 15:32   ` d tbsky
  1 sibling, 1 reply; 6+ messages in thread
From: Mateusz @ 2021-04-29  9:21 UTC (permalink / raw)
  To: list Linux RAID, d tbsky

On czwartek, 29 kwietnia 2021 10:52:21 CEST d tbsky wrote:
> however dd may also copy the mdadm superblock which include internal
> bitmap(since I don't caculate correct size). I don't know if there is
> risk that mdadm will be confused with the bitmap in new disk. although
> I have tried and it seems work fine.
> should I disable internal bitmap before add new disk? 

No.

> or mdadm will
> understand the superblock/bitmap at new disk is invalid and just
> overwrite everything?

Should in most cases [1], but IMHO it's good idea to
mdadm --zero-superblock /dev/YOU_ARE_SURE_IS_ONE_YOU_WANT_TO_ADD
before adding disk already used somewhere else.

BTW,  IMHO it's better to clone partition layout, and than install bootloaders 
instead of dding disk.

[1] If disk/part was already used / cloned in same array it's bitmap may be 
recognized, not synced, resulting likely broken array.

-- 
Mateusz 
(...) mam brata - poważny, domator, liczykrupa, hipokryta, pobożniś,
	krótko mówiąc - podpora społeczeństwa."
		Nikos Kazantzakis - "Grek Zorba"




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: add new disk with dd
  2021-04-29  9:21 ` Mateusz
@ 2021-04-29 15:32   ` d tbsky
  2021-04-29 15:34     ` Reindl Harald
  2021-05-01 10:07     ` Wols Lists
  0 siblings, 2 replies; 6+ messages in thread
From: d tbsky @ 2021-04-29 15:32 UTC (permalink / raw)
  To: Mateusz; +Cc: list Linux RAID

Mateusz <mateusz-lists@ant.gliwice.pl>
> Should in most cases [1], but IMHO it's good idea to
> mdadm --zero-superblock /dev/YOU_ARE_SURE_IS_ONE_YOU_WANT_TO_ADD
> before adding disk already used somewhere else.

   "madam --zero-superblock" is great.  I will add it to my procedure.
   thanks a lot for the hint!

> BTW,  IMHO it's better to clone partition layout, and than install bootloaders
> instead of dding disk.

   yes. but sometimes dd is easy, especially for mbr layout.
anyway I think your suggestion "--zero-superblock" make things safe
with new and old disks.

   thanks again for your kindly help.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: add new disk with dd
  2021-04-29 15:32   ` d tbsky
@ 2021-04-29 15:34     ` Reindl Harald
  2021-05-01 10:07     ` Wols Lists
  1 sibling, 0 replies; 6+ messages in thread
From: Reindl Harald @ 2021-04-29 15:34 UTC (permalink / raw)
  To: d tbsky, Mateusz; +Cc: list Linux RAID



Am 29.04.21 um 17:32 schrieb d tbsky:
> Mateusz <mateusz-lists@ant.gliwice.pl>
>> Should in most cases [1], but IMHO it's good idea to
>> mdadm --zero-superblock /dev/YOU_ARE_SURE_IS_ONE_YOU_WANT_TO_ADD
>> before adding disk already used somewhere else.
> 
>     "madam --zero-superblock" is great.  I will add it to my procedure.
>     thanks a lot for the hint!
> 
>> BTW,  IMHO it's better to clone partition layout, and than install bootloaders
>> instead of dding disk.
> 
>     yes. but sometimes dd is easy, especially for mbr layout.
> anyway I think your suggestion "--zero-superblock" make things safe
> with new and old disks

doing both for years on dozens of machines which have 3 RAID partitions 
(boot, os, data) on 4 disks with a script

GOOD_DISK is a full working one and BAD_DISK the blank drive

[root@srv-rhsoft:~]$ cat /scripts/raid-recovery.sh
#!/usr/bin/bash

GOOD_DISK="/dev/sda"
BAD_DISK="/dev/sdd"

# --------------------------------------------------------------------------

echo "NOT NOW"
exit

# --------------------------------------------------------------------------

# clone MBR
dd if=$GOOD_DISK of=$BAD_DISK bs=512 count=1

# force OS to read partition tables
partprobe $BAD_DISK

# start RAID recovery
mdadm /dev/md0 --add ${BAD_DISK}1
mdadm /dev/md1 --add ${BAD_DISK}2
mdadm /dev/md2 --add ${BAD_DISK}3

# print RAID status on screen
sleep 5
cat /proc/mdstat

# install bootloader on replacement disk
grub2-install "$BAD_DISK"

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: add new disk with dd
  2021-04-29 15:32   ` d tbsky
  2021-04-29 15:34     ` Reindl Harald
@ 2021-05-01 10:07     ` Wols Lists
  1 sibling, 0 replies; 6+ messages in thread
From: Wols Lists @ 2021-05-01 10:07 UTC (permalink / raw)
  To: d tbsky; +Cc: list Linux RAID

On 29/04/21 16:32, d tbsky wrote:
> Mateusz <mateusz-lists@ant.gliwice.pl>
>> Should in most cases [1], but IMHO it's good idea to
>> mdadm --zero-superblock /dev/YOU_ARE_SURE_IS_ONE_YOU_WANT_TO_ADD
>> before adding disk already used somewhere else.
> 
>    "madam --zero-superblock" is great.  I will add it to my procedure.
>    thanks a lot for the hint!
> 
>> BTW,  IMHO it's better to clone partition layout, and than install bootloaders
>> instead of dding disk.
> 
>    yes. but sometimes dd is easy, especially for mbr layout.
> anyway I think your suggestion "--zero-superblock" make things safe
> with new and old disks.
> 
I notice you said mbr ... because with GPT it will give you a broken
partition table.

Note also it will copy all your guids, so you don't EVER want those two
disks to be in the same system at the same time ...

I'd do what the others have suggested - copy the partition table,
re-install grub or whatever (you have got it documented what to do? :-)
It should be easy), and simply add your replacement partition.

Oh - and did you say it was raid-5? You've just busted your redundancy
during the most dangerous period of an array's life - the rebuild. If
you add the new disk to your system then do a --replace before removing
the old, your array is fully protected at all times and the only two
disks being hammered are the old one that's not working properly anyway,
and the new one that should be able to take it.

(The other thing about doing a proper rebuild, is you can use a larger
disk, and a larger partition, ready to upgrade the other disks and grow
your array.)

Cheers,
Wol

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-01 10:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29  8:52 add new disk with dd d tbsky
2021-04-29  9:05 ` Roman Mamedov
2021-04-29  9:21 ` Mateusz
2021-04-29 15:32   ` d tbsky
2021-04-29 15:34     ` Reindl Harald
2021-05-01 10:07     ` Wols Lists

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.