post #1 of 1
Thread Starter 
I found this on the net and did could not find it on OCN so here it is. I have not tried this yet though as the F4 2TBs I need to expand are now $150+ .

Quote:
When you record and download lots of TV, movies, music, etc. it can chew up the disk space pretty quickly. If you don't keep on top of your DVD burning you will end up running out of disk space, like me.

That's okay, I have two 200GB drives mirrored in a RAID1 array. If I break the mirror and concatenate the drives I could use all 400GB of space available to me... but if one drive died, I would lose everything that was not backed up.

Buying two more drives isn't the answer as I only have one more PATA drive connection available.

Perhaps I could back everything up, buy two bigger drives, install a new RAID1 array and copy everything back over. That means giving up two perfectly servicable 200GB drives.

If only I could add a third drive and convert the RAID1 array to a RAID5 array. Then I would get the full 400GB of space, and still retain the redundancy. Yeah, right...

Then I stumbled across this blog entry in which a guy creates some experimental loopback devices, creates a RAID1 array and then converts it to a RAID5 array with no data loss.

I was intrigued.

The theory says that the RAID5 algorithm, when applied to 2 disks only, ends up looking like a RAID1 array except for the RAID metadata. If you overwrite the RAID1 metadata with the RAID5 metadata, mdadm should recognise the 2 disk RAID5 array and not mess with the contents.

Once the metadata is updated, you can then add a third partition to the array and grow the RAID5 array to utilise it. All that remains is to then resize the filesystem to fill the new space.

The main question is, am I brave enough to try it?

You bet I am!

Of course, everything is caveated with the usual "back everything up before you attempt this procedure" and, like a good boy, I borrowed a 400GB external drive from work and rsync'd all the important stuff across... and, with heart in mouth, followed the procedure...

Boot from a Fedora Core 6 rescue CDROM and get to a command prompt.

You must ensure you have a recent kernel (> 2.6.17) and that you have a recent version of the mdadm software:

Code:
# uname -a Linux localhost.localdomain 2.6.18-1.2798.fc6 #1 SMP Mon Oct 16 14:54:20 EDT 2006 i686 unknown  # mdadm --version mdadm - v2.5.4 - 13 Ocotober 2006

Stop the array:

Code:
# mdadm --stop /dev/md0

Overwrite the RAID1 metadata with the RAID5 metadata:

Code:
# mdadm --create /dev/md0 --level=5 -n 2 /dev/hda1 /dev/hdb1 
mdadm: /dev/hda1 appears to contain an ext2fs file system
     size=1946592K  mtime=Sat Apr 14 07:18:32 2007 
mdadm: /dev/hda1 appears to be part of a raid array:
     level=1 devices=2 ctime=Sat Sep 17 16:17:45 2005 
mdadm: /dev/hdb1 appears to contain an ext2fs file system
     size=1946592K  mtime=Sat Apr 17 07:18:32 2007 
mdadm: /dev/hdb1 appears to be part of a raid array:
     level=1 devices=2 ctime=Sat Sep 17 16:17:45 2005 
Continue creating array? y 
mdadm: array /dev/md0 started.

At this point the RAID software decided it wanted to rebuild the array. Uh-oh, there goes my data...

I quickly mounted /dev/md0 and had a look... all my data is still intact! Oh well, let the software do it's thing. Who am I to argue?

Add in the third, new partition:

Code:
# mdadm --add /dev/md0 /dev/hdd1

So far, so good. Once the rebuild is complete, grow the RAID5 onto the new partition: (NB: use the --backup-file option in case the grow is interrupted. It will allow a safe recovery.)

Code:
# mdadm --grow /dev/md0 --raid-disks=3 --backup-file=/mnt/tmp/raid1-5.backup.file 
mdadm: Need to backup 128K of critical section .. 
mdadm: ... critical section passed.

I'm impressed that I've had no problems so far.

The reshaping of the RAID5 from a 2 disk to a 3 disk array takes quite a while (about 6.5 hours for around 200GB of raw data) but the filesystem resize shouldn't take anywhere near as long:

Code:
# e2fsck -f /dev/md0  # resize2fs -p /dev/md0

Apart from the modification of the RAID metadata, the whole operation can be done "online". I chose to do it from single-user/rescue mode as I wanted to make sure there was no data loss. If you're not too bothered then you could leave the whole thing up and running.

Thanks to Neil Brown for his wonderful software RAID drivers, Nathan Gray for his cunning RAID1/RAID5 conversion technique and, of course, everyone who makes Linux the great OS it is.
by scottwallacesh at 12:01 pm
Source

This post is also in "RAID Controllers and Software" sub-forum.
Gojira
(20 items)
 
Mosura
(10 items)
 
Jira
(11 items)
 
CPUMotherboardGraphicsRAM
i7-6800k @ 4.2Ghz ASUS Strix X99 Gaming MSI GTX 1080 SeaHawk EK X Corsair Dominator Platinum 32GB (4x8GB) 3000Mhz... 
Hard DriveCoolingCoolingCooling
1TB Samsung 960 Pro EK CoolStream XE 360 EK-FB ASUS X99 Monoblock SeaHawk EK X 
CoolingCoolingOSMonitor
Corsair ML120 Pro x3 Corsair ML140 Pro x1 Windows 10 Pro x64 3x ASUS VS248H-P 
MonitorKeyboardPowerCase
Acer Predator XB241H Corsair K95 RGB Cherry MX Brown CORSAIR AX860i Fractal Design S 
MouseMouse PadAudioAudio
Corsair Scimitar Black Edition Vipamz Extended XXXL Gaming Mouse Pad 36"x12"x0... ASUS Zonar Essence STX Beyerdynamic DT 990 PRO 
CPUMotherboardRAMHard Drive
AMD Opteron 6276 SuperMicro H8SGL-F 64GB (8x8GB) Hynix PC3L-10600R 8x WD Red 3TB in RAID-Z2 Storage 
Hard DriveHard DriveCoolingOS
2x Corsair Force LE RAID-Z Jails 2x LSI 9211 8i Noctua NH-U12DO A3 FreeNAS 
PowerCase
SeaSonic SS-660XP2 Fractal Design Define R5 
CPUGraphicsRAMHard Drive
Intel Core i7-6700HQ Processor 2.6GHz NVIDIA GeForce GTX 960M 2GB GDDR5 16GB RAM Samsung 960 Evo 250GB 
Hard DriveOSMonitorMouse
Samsung 850 Evo 250GB Windows 10 Pro IPS Touchscreen 1080p Razer Naga 2014 
Mouse PadAudioAudio
Razer Vespula FiiO Q1 Brainwavz M2 
  hide details  
Reply
Gojira
(20 items)
 
Mosura
(10 items)
 
Jira
(11 items)
 
CPUMotherboardGraphicsRAM
i7-6800k @ 4.2Ghz ASUS Strix X99 Gaming MSI GTX 1080 SeaHawk EK X Corsair Dominator Platinum 32GB (4x8GB) 3000Mhz... 
Hard DriveCoolingCoolingCooling
1TB Samsung 960 Pro EK CoolStream XE 360 EK-FB ASUS X99 Monoblock SeaHawk EK X 
CoolingCoolingOSMonitor
Corsair ML120 Pro x3 Corsair ML140 Pro x1 Windows 10 Pro x64 3x ASUS VS248H-P 
MonitorKeyboardPowerCase
Acer Predator XB241H Corsair K95 RGB Cherry MX Brown CORSAIR AX860i Fractal Design S 
MouseMouse PadAudioAudio
Corsair Scimitar Black Edition Vipamz Extended XXXL Gaming Mouse Pad 36"x12"x0... ASUS Zonar Essence STX Beyerdynamic DT 990 PRO 
CPUMotherboardRAMHard Drive
AMD Opteron 6276 SuperMicro H8SGL-F 64GB (8x8GB) Hynix PC3L-10600R 8x WD Red 3TB in RAID-Z2 Storage 
Hard DriveHard DriveCoolingOS
2x Corsair Force LE RAID-Z Jails 2x LSI 9211 8i Noctua NH-U12DO A3 FreeNAS 
PowerCase
SeaSonic SS-660XP2 Fractal Design Define R5 
CPUGraphicsRAMHard Drive
Intel Core i7-6700HQ Processor 2.6GHz NVIDIA GeForce GTX 960M 2GB GDDR5 16GB RAM Samsung 960 Evo 250GB 
Hard DriveOSMonitorMouse
Samsung 850 Evo 250GB Windows 10 Pro IPS Touchscreen 1080p Razer Naga 2014 
Mouse PadAudioAudio
Razer Vespula FiiO Q1 Brainwavz M2 
  hide details  
Reply