2006/06/27 13:13:00
I have a lvm partition that contains all my music, tv recordings and photos on my server at home. Just recenetly it has stated to make a clunking noise and then timing out on a read or write. I think that this is a bad sign!
So out the the virtual shop I went and got me some 300Gb of new drive. What follows is a short note of how I upgraded the disk.
The drive is handled under lvm there is a single partition (sda1) that is providing the physical storage for the lvm volume group media_vg and then I have just one logical volume called media_vg (This would work with any number of lv).
I am going to use the whole of the new disk (sdb) as lvm so first do a pv create on that disk
# pvcreate /dev/sdb
Next add it to the media_vg volume group
# vgextend media_vg /dev/sdb
Now comes the big part of moving the data off the old drive
# pvmove -v /dev/sda1
That will take some time! But at the end it should have moved all the data to the new drive. Now just remove the old drive from the volume group.
# vgreduce media_vg /dev/sda1
Jobs done!
Almost..
Because I have now got a larger disk then I want to extend the the file system as well.
First find the total size of your now vg
# vgdisplay maindata_vg |grep Total
Next extend your lv to use all the extents
# lvextend -l
Now we have a larger logical volume but the file systems is still the same size. On very modern kernel this can all be done online but due to me using a stable version of debian and my general paranoia I will unmount first. Up till now this has all been done with the system online and me playing music off it across the network!
# umount /dev/media_vg/media_lv
Now check the filesystem to make sure it’s okay before you start.
# fsck -f /dev/media_vg/media_lv
Good? Now extend the filesystem
# resizeex2fs /dev/media_vg/media_lv
One more check for paronioa.
# fsck -f /dev/media_vg/media_lv
The mount it back up and you are set to go!
Listen to this podcast