:: Re: [DNG] [OT] Help on change (spli…
Startseite
Nachricht löschen
Nachricht beantworten
Autor: Simon
Datum:  
To: Devuan ML
Betreff: Re: [DNG] [OT] Help on change (split) partitions of an md raid
Antony Stone <Antony.Stone@???> wrote:
>
> On Tuesday 27 June 2023 at 19:34:25, al3xu5 via Dng wrote:
>
>> Hi all
>>
>> I know I am OT (again), but I need help and hope you will excuse me...
>>
>> I have two identical disk, each with two partitions of the same size, with
>> no unpartitioned space left:
>>
>> DISK1: Disk1Part1 + Disk1Part2
>> DISK2: Disk2Part1 + Disk2Part2
>>
>> I have a md RAID1 (mirror) on those disks:
>>
>> md1: Disk1Part1 + Disk2Part1
>> md2: Disk1Part2 + Disk2Part2
>>
>> Now I need to split each of the 2nd partitions in two smaller partitions,
>> so as to obtain:
>>
>> DISK1: Disk1Part1 + Disk1Part2 + Disk1Part3
>> DISK2: Disk2Part1 + Disk2Part2 + Disk2Part3
>>
>> and:
>>
>> md1: Disk1Part1 + Disk2Part1
>> md2: Disk1Part2 + Disk2Part2
>> md3: Disk1Part3 + Disk2Part3
>>
>> Please can you suggest the best and safe way (correct procedure, commands,
>> tools to use etc.) to do this (obviously, I have a backup of all the data)?
>
> 1. Unmount anything which is using /dev/md2
>
> 2. mdadm --stop /dev/md2
>
> 3. Use fdisk, sfdisk, parted or whatever your preferred tool of choice is, to
> delete /dev/sda2 and /dev/sdb2 (I'm guessing at your device names here)
>
> 4. Create /dev/sda2 / sda3 and /dev/sdb2 / sdb3 with whatever sizes you
> require
>
> 5. mdadm --create /dev/md2 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2
>
> 6. Same as above for md3 / sda3 / sdb3
>
> 7. Use /usr/share/mdadm/mkconf to re-create /etc/mdadm/mdadm.conf
>
> 8. Use "update-initramfs -u -k all" to re-create your initramfs with knowledge
> of the new arrays
>
> 9. Format /dev/md2 and /dev/md3 and mount as you wish...
>
>
> I would expect steps 4, 5 and 6 to show some warnings about the partitions
> containing raid signatures. Confirm that you want to delete them.


There’s (I think) a non-destructive alternative, as long as your data will fit into DisknPart2

Resize the filesystem to be smaller than the end size of md2
Stop md2
Delete both Part2s
Recreate new Part2s using the same starting block as the old Part2s
I *think* you should now be able to start md2.
Resize the filesystem on md2 up to the new size
Create the new Part3s, create the new md3, create the filesystem on md3
Update your initramfs

What I’m not sure about is whether md will barf when presented with smaller partitions. Do we have anyone with enough detailed knowledge to answer that ?

I could see that under the old md raid1 scheme it could barf since md kept it’s data at the end of the partition. However, you could create a new md2 (ensuring that you don’t initialise it) as md would simply shrink the apparent size of the partition and put it’s data at the end - thus the partition can be read as a non-raid volume identical to the array (I use this in setting up my /boot arrays).

Under the current scheme it keeps data at the start of the partition. So I see two possibilities - it accepts the partitions as-is, or it barfs as the partitions aren’t the size it expects.


As long as you have backups, some of these conversions can be quite interesting to do ;-)


Simon