linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Growing a single disk into a 2 disk raid0
@ 2011-01-28 17:17 Phillip Susi
  2011-01-28 17:53 ` Berkey B Walker
  2011-01-29  9:10 ` NeilBrown
  0 siblings, 2 replies; 7+ messages in thread
From: Phillip Susi @ 2011-01-28 17:17 UTC (permalink / raw)
  To: linux-raid

I had someone wanting to take an existing disk full of data and expand
it by adding a second disk.  This seemed reasonable, and I thought of
several ways you could do this, but none of them pan out:

1)  Create a single disk raid0 using the existing disk, then reshape it
adding the second disk.  mdadm fails to add the second disk as a spare
so that you can reshape, with the kernel complaining that personality
does not support diskops.

2)  Create a single disk raid1 using the existing disk, then reshape it
adding the second disk.  Apparently you can not reshape from raid1 to raid0.

3)  Create a raid10 using the existing disk, setting the number of near
copies to only 1 so as to preserve the existing data, then reshape
adding the second disk.  I ran into two problems here:

a) mdadm refuses to create a single disk raid10, saying that at least
two devices are needed for raid level 4 or 5.  I am surprised that you
can not create a single disk raid10 even with --force, and the message
mentions the wrong level.  I would think that a single disk raid10 with
2 far copies would be fairly useful.

b) I tried 2 disks with one missing and mdadm refuses to create a raid10
with only a single near copy.  The kernel complains that layout 0x101 is
unsupported.

Is there any way to accomplish this?

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

* Re: Growing a single disk into a 2 disk raid0
  2011-01-28 17:17 Growing a single disk into a 2 disk raid0 Phillip Susi
@ 2011-01-28 17:53 ` Berkey B Walker
  2011-01-28 18:14   ` John Robinson
  2011-01-28 18:19   ` Phillip Susi
  2011-01-29  9:10 ` NeilBrown
  1 sibling, 2 replies; 7+ messages in thread
From: Berkey B Walker @ 2011-01-28 17:53 UTC (permalink / raw)
  To: Phillip Susi; +Cc: linux-raid



Phillip Susi wrote:
> I had someone wanting to take an existing disk full of data and expand
> it by adding a second disk.  This seemed reasonable, and I thought of
> several ways you could do this, but none of them pan out:
>
> 1)  Create a single disk raid0 using the existing disk, then reshape it
> adding the second disk.  mdadm fails to add the second disk as a spare
> so that you can reshape, with the kernel complaining that personality
> does not support diskops.
>
> 2)  Create a single disk raid1 using the existing disk, then reshape it
> adding the second disk.  Apparently you can not reshape from raid1 to raid0.
>
> 3)  Create a raid10 using the existing disk, setting the number of near
> copies to only 1 so as to preserve the existing data, then reshape
> adding the second disk.  I ran into two problems here:
>
> a) mdadm refuses to create a single disk raid10, saying that at least
> two devices are needed for raid level 4 or 5.  I am surprised that you
> can not create a single disk raid10 even with --force, and the message
> mentions the wrong level.  I would think that a single disk raid10 with
> 2 far copies would be fairly useful.
>
> b) I tried 2 disks with one missing and mdadm refuses to create a raid10
> with only a single near copy.  The kernel complains that layout 0x101 is
> unsupported.
>
> Is there any way to accomplish this?
>
>    
Because 1) I'm old, and 2) I don't trust documentation, I do it the 
slow, easy way.  I use the blank disk and make a RAID missing a disk.  I 
then copy the data to the RAIDed disk.  If everything is OK, zero out 
the old data disk and add it to the raid (filling the "missing").  I do 
it this way any time I want to make  raid  of a disk full of data, to 
any level of raid.
b-


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

* Re: Growing a single disk into a 2 disk raid0
  2011-01-28 17:53 ` Berkey B Walker
@ 2011-01-28 18:14   ` John Robinson
  2011-01-28 18:29     ` Phillip Susi
  2011-01-28 18:19   ` Phillip Susi
  1 sibling, 1 reply; 7+ messages in thread
From: John Robinson @ 2011-01-28 18:14 UTC (permalink / raw)
  To: Berkey B Walker; +Cc: Phillip Susi, linux-raid

On 28/01/2011 17:53, Berkey B Walker wrote:
>
>
> Phillip Susi wrote:
>> I had someone wanting to take an existing disk full of data and expand
>> it by adding a second disk. This seemed reasonable, and I thought of
>> several ways you could do this, but none of them pan out:
>>
>> 1) Create a single disk raid0 using the existing disk, then reshape it
>> adding the second disk. mdadm fails to add the second disk as a spare
>> so that you can reshape, with the kernel complaining that personality
>> does not support diskops.
>>
>> 2) Create a single disk raid1 using the existing disk, then reshape it
>> adding the second disk. Apparently you can not reshape from raid1 to
>> raid0.
>>
>> 3) Create a raid10 using the existing disk, setting the number of near
>> copies to only 1 so as to preserve the existing data, then reshape
>> adding the second disk. I ran into two problems here:
>>
>> a) mdadm refuses to create a single disk raid10, saying that at least
>> two devices are needed for raid level 4 or 5. I am surprised that you
>> can not create a single disk raid10 even with --force, and the message
>> mentions the wrong level. I would think that a single disk raid10 with
>> 2 far copies would be fairly useful.
>>
>> b) I tried 2 disks with one missing and mdadm refuses to create a raid10
>> with only a single near copy. The kernel complains that layout 0x101 is
>> unsupported.
>>
>> Is there any way to accomplish this?
>>
> Because 1) I'm old, and 2) I don't trust documentation, I do it the
> slow, easy way. I use the blank disk and make a RAID missing a disk. I
> then copy the data to the RAIDed disk. If everything is OK, zero out the
> old data disk and add it to the raid (filling the "missing"). I do it
> this way any time I want to make raid of a disk full of data, to any
> level of raid.

At the moment, mdadm doesn't support reshaping RAID-0 and RAID-10, 
though if you've been following the many posts/patches from the Intel 
guys, you'll know it's coming in mdadm 3.2.

Anything involving mirroring (RAID-1 or RAID-10) isn't going to expand 
the available storage space; you've only got two discs, so the second 
will be consumed by a mirror of the first.

So, Philip, if all you have is one full disc and one empty one, I think 
pretty much your only option at the moment is --level linear, either by 
--creating a new array with on-disc metadata with the new disc only, 
copying the data, then adding the original disc to the new array (as 
Berkey suggests), or by --building an array (with no stored metadata, 
meaning it'll need to be built again every time you reboot) which adds 
the second disc onto the first one. (Actually there is a cunning third 
option: shrink the filesystem a little and create the array with 
metadata at the end, but I'd be very VERY wary of doing this on data of 
any value.) I think I'd use LVM instead (multiple PVs in a VG usable by 
one LV) though it has the same problems with what to do with metadata.

If you want some redundancy as well as more storage space, you need more 
discs.

Cheers,

John.


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

* Re: Growing a single disk into a 2 disk raid0
  2011-01-28 17:53 ` Berkey B Walker
  2011-01-28 18:14   ` John Robinson
@ 2011-01-28 18:19   ` Phillip Susi
  1 sibling, 0 replies; 7+ messages in thread
From: Phillip Susi @ 2011-01-28 18:19 UTC (permalink / raw)
  To: Berkey B Walker; +Cc: linux-raid

On 1/28/2011 12:53 PM, Berkey B Walker wrote:
> Because 1) I'm old, and 2) I don't trust documentation, I do it the
> slow, easy way.  I use the blank disk and make a RAID missing a disk.  I
> then copy the data to the RAIDed disk.  If everything is OK, zero out
> the old data disk and add it to the raid (filling the "missing").  I do
> it this way any time I want to make  raid  of a disk full of data, to
> any level of raid.

That works for raid1, but as I said, mdadm will not let you create a
single disk raid0.

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

* Re: Growing a single disk into a 2 disk raid0
  2011-01-28 18:14   ` John Robinson
@ 2011-01-28 18:29     ` Phillip Susi
  2011-01-29  1:38       ` Hank Barta
  0 siblings, 1 reply; 7+ messages in thread
From: Phillip Susi @ 2011-01-28 18:29 UTC (permalink / raw)
  To: John Robinson; +Cc: Berkey B Walker, linux-raid

On 1/28/2011 1:14 PM, John Robinson wrote:
> At the moment, mdadm doesn't support reshaping RAID-0 and RAID-10,
> though if you've been following the many posts/patches from the Intel
> guys, you'll know it's coming in mdadm 3.2.

Ahh, I will keep my eyes out for that and hopefully it will also enable
creating a single disk raid0 initially, then reshape.

> Anything involving mirroring (RAID-1 or RAID-10) isn't going to expand
> the available storage space; you've only got two discs, so the second
> will be consumed by a mirror of the first.

This is true for raid-1, but not raid-10.  If you add a disk to a
raid-10 then the majority of its space will be added to the capacity of
the array if you do not increase the number of duplicate copies ( i.e.
leave n=2 as it defaults to ).

> the second disc onto the first one. (Actually there is a cunning third
> option: shrink the filesystem a little and create the array with
> metadata at the end, but I'd be very VERY wary of doing this on data of

That is what I was trying to do, and had no trouble converting a plain
partition into an mdadm managed one using that technique, but then ran
into the problems I stated originally.

> any value.) I think I'd use LVM instead (multiple PVs in a VG usable by
> one LV) though it has the same problems with what to do with metadata.

Unfortunately that isn't an option if you aren't already using LVM,
though figuring out how to upgrade a plain disk to LVM is another
interesting problem.

> If you want some redundancy as well as more storage space, you need more
> discs.

The idea here was to get more storage and speed by converting to raid-0,
but without data loss.

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

* Re: Growing a single disk into a 2 disk raid0
  2011-01-28 18:29     ` Phillip Susi
@ 2011-01-29  1:38       ` Hank Barta
  0 siblings, 0 replies; 7+ messages in thread
From: Hank Barta @ 2011-01-29  1:38 UTC (permalink / raw)
  To: Phillip Susi; +Cc: John Robinson, Berkey B Walker, linux-raid

On Fri, Jan 28, 2011 at 12:29 PM, Phillip Susi <psusi@cfl.rr.com> wrote:
>
> The idea here was to get more storage and speed by converting to raid-0,
> but without data loss.

RAID0 has no redundancy so all of the media is required for the RAID
to be operable. RAID1 and RAID5 have sufficient redundancy to store
complete information without complete drives.

One implication of that is that if either drive fails, all information
is lost. Since two drives are involved, chance of failure is about
double that of a single drive.

-hank

-- 
'03 BMW F650CS - hers
'98 Dakar K12RS - "BABY K" grew up.
'93 R100R w/ Velorex 700 (MBD starts...)
'95 Miata - "OUR LC"
polish visor: apply squashed bugs, rinse, repeat
Beautiful Sunny Winfield, Illinois

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

* Re: Growing a single disk into a 2 disk raid0
  2011-01-28 17:17 Growing a single disk into a 2 disk raid0 Phillip Susi
  2011-01-28 17:53 ` Berkey B Walker
@ 2011-01-29  9:10 ` NeilBrown
  1 sibling, 0 replies; 7+ messages in thread
From: NeilBrown @ 2011-01-29  9:10 UTC (permalink / raw)
  To: Phillip Susi; +Cc: linux-raid

On Fri, 28 Jan 2011 12:17:50 -0500 Phillip Susi <psusi@cfl.rr.com> wrote:

> I had someone wanting to take an existing disk full of data and expand
> it by adding a second disk.  This seemed reasonable, and I thought of
> several ways you could do this, but none of them pan out:
> 
> 1)  Create a single disk raid0 using the existing disk, then reshape it
> adding the second disk.  mdadm fails to add the second disk as a spare
> so that you can reshape, with the kernel complaining that personality
> does not support diskops.
> 
> 2)  Create a single disk raid1 using the existing disk, then reshape it
> adding the second disk.  Apparently you can not reshape from raid1 to raid0.
> 
> 3)  Create a raid10 using the existing disk, setting the number of near
> copies to only 1 so as to preserve the existing data, then reshape
> adding the second disk.  I ran into two problems here:
> 
> a) mdadm refuses to create a single disk raid10, saying that at least
> two devices are needed for raid level 4 or 5.  I am surprised that you
> can not create a single disk raid10 even with --force, and the message
> mentions the wrong level.  I would think that a single disk raid10 with
> 2 far copies would be fairly useful.
> 
> b) I tried 2 disks with one missing and mdadm refuses to create a raid10
> with only a single near copy.  The kernel complains that layout 0x101 is
> unsupported.
> 
> Is there any way to accomplish this?

Yes.  Maybe.

You need to use the RAID5 personality to do the re-striping.

You should absolutely test out any procedure you end up with to make sure it
actually works.  e.g. with a couple of USB drives or something like that.
Maybe just a couple of loop-back devices on mostest sized files (100Meg would
be plenty for testing).

Firstly you need to convert the single device into a 2-device RAID4.
Something like:
 
  mdadm -C /dev/md0 -l4 -n2 -e 1.0 /dev/sda missing

The '-e 1.0'. will make sure the metadata goes at the end
of the device.
Note that this will DESTROY the last 8K or so of the device.  And will round
the remaining size down to the chuck size (which might be 512K by default).
You should check that the filesystem doesn't extend that far.  If it does,
you might need to resize the filesystem to be smaller.

Alternately you could create this md0 on the new device, and then
copy the original device onto the new md0 (mkfs, then "cp -a" or similar).

Once you have a degraded 2-drive RAID4 (i.e. with only one drive)  that
contains your data you are ready for step 2.
mdadm-3.2 might do this for you, but it isn't released yet and I haven't
tested so it probably doesn't.
You need to add the second device and then reshape to be a 3-drive RAID4
without the second device being recovered first.
So:

  echo frozen > /sys/block/md0/md/sync_action
  mdadm /dev/md0 --add /dev/the-other-device
  mdadm --grow --force /dev/md0 --raid-disks=2

You will of course test this before trying it on live data.
And you need a fairly recent kernel.

If/when the above works you will have a degraded 3-drive RAID4
which is much like a 2-drive RAID0 except that it does lots of pointless
parity calculations.
You can convert it to RAID0 with the command:

  echo raid0 > /sys/block/md0/md/level

and (drum roll) you have your RAID0 all configured.

You may decide that this isn't worth the effort and that you want to
wait for mdadm to support it natively.  The choice is yours.
But you will need to wait for at least 3.2.1.

If you do experiment with this, please report any success or failure.


NeilBrown

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

end of thread, other threads:[~2011-01-29  9:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-28 17:17 Growing a single disk into a 2 disk raid0 Phillip Susi
2011-01-28 17:53 ` Berkey B Walker
2011-01-28 18:14   ` John Robinson
2011-01-28 18:29     ` Phillip Susi
2011-01-29  1:38       ` Hank Barta
2011-01-28 18:19   ` Phillip Susi
2011-01-29  9:10 ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).