Grow a LVM over software raid with a new harddisk
Owen Townend
bowbowbow at optushome.com.au
Wed Nov 14 09:29:12 UTC 2007
On Wed, 2007-11-14 at 16:10 +0800, Shu Hung (Koala) wrote:
> Hello all,
>
> Anyone knows how to grow a LVM over software raid with a new harddisk?
>
> What I mean is I have a new harddisk. I plugged it in my machine. And
> now, how do I:
> (1) add this harddisk to my existing software raid, grow it without
> affecting files in it
> (2) grow my LVM volume group accordingly without affecting files in it
> (3) add the new storage space to a specific lvm without affecting the
> data in it
>
> Is there any way?
>
>
> Thanks,
> Koala Yeung
Hey,
There is definitely a way!
In this case the man pages are your friend.
So long as your setup isn't too exotic it should be fairly straight
forward. Substitute your devices etc for the ones I've used and read the
man pages and check options etc before running anything.
There are three stages, grow mdadm, extend lvm and extend the
filesystem. How each of these is done is dependant on your setup namely
raid level & filesystem type as well as the use the setup is put to. LVM
should be able to extend anyway so long as you're using LVM2. (LVM1 had
some hard limits on sizing that needed to be decided on creation.)
If this is used as your root partition you'll need to boot a livecd
distro or rescuecd to access it and allow you to make the changes. Also,
if you are extending a raid5 array you'll want another device (hdd,
floppy, usb stick, etc) to store the mdadm backup data it keeps while
performing the extension.
If it's just a storage array then the expansion should be as easy as
(for example)
# mdadm --add /dev/md0 /dev/sdd1
# mdadm --grow /dev/md0 --raid-devices=4
This can be done online (mounted) if you wish but it'll be slower.
Then wait for a few hours watching /proc/mdstat as something like this
shows up
[>....................] reshape = 0.0% (166656/390708736)
finish=1347.2min speed=4830K/sec
(from http://scotgate.org/?p=107)
Then let LVM know you've changed the disk
# pvresize /dev/md0
Next extend the logical volume by the desired amount,
For example all of the new space:
# lvextend -l 100%FREE /dev/datavg/datalv
Lastly, extend the filesystem. In my case this is usually reiserfs so:
The default if no new size is given is to fill the available space.
Unmount if you haven't already
# umount /dev/datavg/datalv
# resize_reiserfs /dev/datavg/datalv
# mount /dev/datavg/datalv
This is similar for ext3:
# resize2fs /dev/datavg/datalv
Hopefully all done :)
cheers,
Owen.
More information about the ubuntu-users
mailing list