As part of my media server, one of the things that I need to be able to do is to add disks when I need them. I decided to run the server from an 80Gb drive that I had spare, but knew the first drive I would add would be a 400Gb SATA drive so I installed my Debian system with LVM2 support.
The latest kernel (2.6.8.15) has good SATA support for my Maxtor card, so I upgraded through Debian and wanted to increase my /assets LVM logical drive.
I had already created a volume group called volume1 and I had create a logical volume called assets which I mounted at /assets
Adding the drive was easy, just plug in the hardware and start the system up.
will show that it has seen the new harddrive after it has booted, just look for a device that is the same size as the one that you have added. If the device doesn’t show up it may mean that you have installed it incorrectly or that there is some problem supporting the device that you have installed.
The
the new drive. Being a SATA drive it is seen as a SCSI device, and as it is my first SCSI device on the system it will be at /dev/sda
Create as many partitions as needed, I created one primary partition.
See what has happened with all the partitions by issuing the following:
Extend the existing Volume group by:
Now take alook at the exist volume groups:
Unmount the logical group that you wish to expand:
Now checkout how much space that you have on your volume group so that you can determine how much you can add to your existing logical group.
It will show the Free PE / Size – this will be the amount that you can resize by.
Resize the logical group:
Check the filesystem is ok (I am using the ext3 file system, you will need other tools for other file systems):
Now resize the data in that logical group.
On my 400Gb drive this resizing took some time. Finally remount the drive and continue using it.
And check that you have all that space added.
10 Comments
Thanks. I usually google around for awhile before I get something working, this one did the trick on the first try. Interestingly, I tried all the above on a live filesystem (it’s just a vmware test image, didn’t matter if I broke it), and successfully added a drive & extended the / partition. Didn’t unmount or reboot.
so this will keep all the data on volume1 and add the new drive size to volume1? If so thank you so much, I have been looking for a way to do this forever and haven’t been able to find a good tutorial on LVM.
Interestingly, I was unable to successfully add a drive and extend the partition without unmounting it first. it kept giving me some extraneous errors about matchpathcon failed: No such file or directory
umounting the drive and trying the same exact thing worked like a charm though
Badi: Yes thats basically what it will do. Its just an cheap way of having expandable mount points.
Joe: Well I am not surprised really, its probably a good idea to umount it first.
You can skip using fdisk and use pvcreate instead if you like.
Thanks for this post. It helped me Extend my LVM. Only thing though, when I tried to use vgextend it told me that my partition wasn’t a physical volume. so i had to go to another forum to learn about the “pvcreate” command:
pvcreate /dev/hdb (the new drive you are adding to LVM)
Might be useful to someone else.
Thanks for the comment.
[...] http://blog.timc3.com/2006/03/19/lvm2-and-adding-disks/ [...]
Maybe a cloud based system would match your requirements much more better.
Well not really considering that I want this in my home.