LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   mdadm - forgot to set up partitions (https://www.linuxquestions.org/questions/linux-server-73/mdadm-forgot-to-set-up-partitions-765748/)

MrAngel 10-31-2009 04:25 AM

mdadm - forgot to set up partitions
 
Hi,
The problem here is entirely my fault - adding an extra disk at an odd time in the morning, I think I missed out a step.

Original setup: /dev/md0 is a raid5 array, 3 disks, 500GB each, /dev/sd[bcd].

Hardware modification: Added 2 new disks, 1TB each.

Intended change: Add /dev/sd[ef]1 to /dev/md0. Create /dev/md1 using /dev/sd[ef]2.

What actually happened: Added /dev/sd[ef] to /dev/md0. I think I should have partitioned it first, but only realized this after doing all the LVM stuff and resize2fs.


So ... how do I make use of the remaining 500GB on my newer disks?

My first guess would be to remove one drive from the array, partition it properly, and then re-add it. Is this a sane solution? Is it possible to turn a /dev/sde into /dev/sde1 without losing the data on it? I never really used partitions before, so I'm not sure how to go about this.

I guess if all else fails, I can just knock one disk out of the array, fdisk, and rebuild the array as if I'd replaced the disk. Or am I missing something really obvious here?

jlinkels 10-31-2009 07:18 PM

Replace the first disk with 1 TB as well? So you end up with a 1 TB RAID5 array without partitions...

That was just an idea.

I don't see the difference between the last to options you propose, but it seems sound anyway. Take one disk out of the RAID, repartition and add the new partition to the RAID, rebuild. Once that it finished, do the same for the second new one.

BTW, what are you doing with the additional 500 GB you have on the new disks? Using them unRAIDed?

jlinkels

MrAngel 11-04-2009 09:21 AM

Quote:

Originally Posted by jlinkels (Post 3739591)
Replace the first disk with 1 TB as well? So you end up with a 1 TB RAID5 array without partitions...

That was just an idea.

Probably the most elegant solution. I don't quite have the money for another 3 new disks right now, though.

Quote:

Originally Posted by jlinkels (Post 3739591)
I don't see the difference between the last to options you propose, but it seems sound anyway. Take one disk out of the RAID, repartition and add the new partition to the RAID, rebuild. Once that it finished, do the same for the second new one.

If I had a spare disk, I could do something like:
fdisk /dev/sdg (create 2 500GB partitions on the extra disk)
dd if=/dev/sde of=/dev/sdg1

Then use /dev/sdg1 to replace /dev/sde in the raid config, and repeat for the other unpartitoned disk.

As far as I understand it, if I repartition my sde and then add sde1 to the array where sde was, I'd have to rebuild the 'new' disk as if I was replacing a failed one. That means no redundancy for 24 hours, and I'd rather not do that if there's any alternative.

So, the question could be restated as:

Is it possible to partition my disk so that /dev/sde1 contains the data formerly found in /dev/sde? Does this just work anyway?

Quote:

Originally Posted by jlinkels (Post 3739591)
BTW, what are you doing with the additional 500 GB you have on the new disks? Using them unRAIDed?

jlinkels

OK ... I must be missing something big here. The new disks have not been partitioned. I just added /dev/sde and /dev/sdf to the raid array using mdadm. I don't see any way I could be using the extra 500GB until I've poked at them with fdisk.

If I'm missing something obvious here, please give me a pointer.

latinmusic74 11-04-2009 04:09 PM

Do not you need to:

1. Partition the disks
2. Add a system file to the disk: RAID "df"
3. Format the partition and run partprobe or reboot the server.
4. then #mdadm -a /dev/md.. /dev/sd..

MrAngel 11-05-2009 06:13 AM

Quote:

Originally Posted by latinmusic74 (Post 3744854)
Do not you need to:

1. Partition the disks

Yes ... I've not got that far yet, though. I was asking whether this will lose the data already on the disk, and if so whether there's any way not to.

Quote:

Originally Posted by latinmusic74 (Post 3744854)
2. Add a system file to the disk: RAID "df"

OK ... now I'm confused. What's a system file?

Quote:

Originally Posted by latinmusic74 (Post 3744854)
3. Format the partition and run partprobe or reboot the server.

Thanks for informing me about partprobe, I've not seen that before.
Why/how do I need to format the partition?



So far, the plan I've got is:
Code:

# umount /home/amedia/
# mdadm --stop /dev/md0
mdadm: fail to stop array /dev/md0: Device or resource busy

(and this is where I'm not sure what to do next)

# fdisk /dev/sde
  (new partition, primary, 1, cylinders 1-60801)
  (new partition, primary, 2, cylinders 60802-end)
  (save)
# partprobe
# mdadm --assemble /dev/md0 /dev/sdb /dev/sdc /dev/sdd /dev/sdf /dev/sde1
  (I assume that it will rebuild the data on sde from the other ones)
  (wait for it to finish)
# mdadm --stop /dev/md0
# fdisk /dev/sdf
  (new partition, primary, 1, cylinders 1-60801)
  (new partition, primary, 2, cylinders 60802-end)
  (save)
# partprobe
# mdadm --assemble /dev/md0 /dev/sdb /dev/sdc /dev/sdd /dev/sdf1 /dev/sde1
  (wait for it to finish again)

# mdadm --create /dev/md1 --raid-devices=2 --level=5 /dev/sde1 /dev/sdf1
# pvscan
# vgextend VolGroup02 /dev/md1
# lvresize VolGroup02/Media 100%VG
# resize2fs -p /dev/VolGroup02/Media
  (and wait some more)
# mount /home/amedia/

So ... can anyone point out the flaws in my plan?


All times are GMT -5. The time now is 06:49 PM.