lossless growing of linear RAID (resizing)
I had great difficulty finding info. on how to convert from RAID-0 to
linear and then grow the system.
I have since found out, and am documenting the details here in case
others have similar needs.
My setup (for the compelte debian mirror at debian.fapeal.br) was 2 80
Gb disks on separate controllers, running RAID-0. This gave me about
150 Gb on /dev/md0 but the Debian mirror now needs more space. I
bought one more disk of 120 Gb but I needed to switch from RAID-0 to
linear, since with 3 disks raid-0 makes no sense if you have only 2
controllers.
This is what ended up working:
1. copy the data from RAID-0 /dev/md0 to the new disk, on an ext2 fs.
the disk cannot become 100% full, leave some empty space.
2. then, destroy the old RAID-0 system by running mke2fs
3. edit /etc/raidtab to remove the old md0 device
4. edit raidtab to include a new raid linear device. The new disk should
be the 1st disk, and the old (former RAID-0) disks can be 2 and 3.
5. create a new raid linear device, with persistent superblock, using
mkraid -f. You will have to use --really-force and you will get a nasty
warning about your data being lost. Just sit tight and ignore the warning.
6. The new raid device will have the full size of the 3 (or more) disks
concatenated. However, the existing fs will still be in place, so that
after fsck and mounting, df will show a total size only of the 1st disk.
the full md device size will not be accessible. Your old data will still
be there.
7. so after runnign fsck, run resize2fs /dev/md0 (or other device)
and the fs size will expand to include the full space. No data
will be lost.
I tested this and it works (and my mirror will be back online soon I
hope).
Of course, make backups, etc. (IN my case this was not possible due to
the sheer size and my limited resources).
There are other methods, like mke2fs -S, but of all the methods I
tested, this one is the best method for growing a raid-linear device.
-gandhi
Reply to: