[RndTbl] Expanding hard drive to utilized unused space
Adam Thompson
athompso at athompso.net
Thu May 4 02:23:17 CDT 2006
It's fairly easy, but tricky the first time you do it. You must have a
fairly recent 2.6 kernel and fairly recent raid tools (mdadm, anyway).
I would suggest doing a reboot first, and bring the system back up in
single-user mode, BUT this can theoretically be done on a live system.
YMMV.
# remove secondary mirror from array
mdadm --manage /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
# resize the partition
fdisk /dev/hdb
* change hdb1 to be bigger
# re-add the partition. MD will automatically use only as much size
as /dev/hda1 at this time
mdadm --manage /dev/md0 --add /dev/hdb1
* wait for re-sync (watch /proc/mdstat)
# remove primary mirror from array
mdadm --manage /dev/md0 --fail /dev/hda1 --remove /dev/hda1
# resize the partition
fdisk /dev/hda
* change hda1 to be bigger
# re-add the partition. MD will still only use as much size as the
original array
mdadm --manage /dev/md0 --add /dev/hda1
* wait for re-sync (watch /proc/mdstat)
# NOW we can tell MD to expand the RAID set to fill the underlying
block device (hda1/hdb1)
mdadm --grow /dev/md0
* wait for re-sync (watch /proc/mdstat)
# and now that we have a bigger block device underlying the
filesystem, we can resize the filesystem itself
resize2fs -p /dev/md0
If you can't do that for whatever reason, see the following complicated
set of steps.
Definitely do-able, but scary. Well, sorta.
Make sure you have a good backup first. Read the mdadm(8) manpage
carefully. Now read it again, you didn't grasp it all the first time -
no-one can.
Assuming you're starting out with md0 (root, including boot) as a RAID-1
set across /dev/hda1 and /dev/hdb1:
1. Hot remove hda1 from md0.
2. Delete hda1.
3. Re-create hda1, filling the entire disk. (Make sure it isn't bigger
than hdb1 will be in step 11.)
4. Create md1 as RAID-1 across hda1 and a "missing" device.
5. Create new filesystem on md1.
6. Mount md1 to /mnt.
7. Transfer all files:
cd /
init S
dump -0 / | ( cd /mnt ; restore - )
** or use tar(1), or cpio(1) or whatever works for your
filesystem type **
grub-install /dev/md1
** see my previous post about getting GRUB installed on the
non-currently-booted disk
(http://www.muug.mb.ca/pipermail/roundtable/2006-April/001086.html) **
umount /dev/md1
8. Reboot (hopefully onto md1 AKA hda1)
9. Stop mdX (whatever hdb1 came up as... likely md0 and md1 got swapped
around during the reboot, but check carefully!)
10. Delete hdb1.
11. Re-create hdb1, filling the entire disk.
12. Hot add hdb1 to md0
13. Wait for md-sync to finish (check via /proc/mdstat)
Step 8 is the most problematic - it might be a good idea to have a GRUB
boot floppy with a local copy of the grub.conf on the floppy... and a
printout of your grub.conf. If you can boot off floppy but not off
hda1, you can at least try to correct the problem. If you can't boot at
all, well...
Good luck!
-Adam
John Lange wrote:
> I have a system built on a Linux raid 1 using ext3.
>
> When the system was created there was a large amount of space left
> available on both of the raid 1 disks for future expansion of a
> partition as required.
>
> I know expanding the file system using LVM is relatively trivial but
> this system was not built using LVM.
>
> Is it possible to expand the partitions, expand the RAID 1 to fill the
> partitions, and then expand the ext3 file system on the RAID1?
>
>
More information about the Roundtable
mailing list