Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am about to add a second harddisk to my server for data storage and have decided to use LVM. My plan is to use one volume group with server logical volumes. Since the disk is new I need to partition it first.

How many primary partitions should I create? What is the difference between the LVM filesystem built on s single-partition disk and one, say, on a four-partition disk?

share|improve this question

4 Answers 4

I recommend creating one large whole-disk partition to contain the PV. Set the partition type to be "8e" (Linux LVM). The reason being that if the disk is moved to a different host in the future, it is obvious that the disk was used with LVM and could help prevent mistakes with the handling of the data.

A second reason for a whole-disk partition: if you run pvcreate /dev/sdX on a device that already has a partition table, the LVM will work correctly until a reboot, at which time the LVM drivers will have a hard time finding the PV. (The LVM drivers assume that if there is a partition table on a disk, the PV must be located within a partition.)

share|improve this answer

You shouldn't use any partitions at all. They belong in the 20th century (well, with one nasty exception actually: x86 BIOSes can't read LVM, so we're stuck with /boot on /dev/sda1).

With the disk online, just do pvcreate /dev/sdX and go from there.

share|improve this answer
    
To make this maybe a bit clearer: you don't create any partitions, no need for {c,s,}fdisk. With the pvcreate command as above, you create just one physical volume that spans the entire disk. –  Jürgen A. Erhard Jan 11 '10 at 9:01
5  
I've always found it to be a Good Idea to at least have a single disk-encompassing partition so that various tools or people know there's something there. –  MikeyB Jan 28 '10 at 22:07
1  
I second having a big partition. We had a problem because we didn't use partitions and just did pvcreate on the whole disk. Unfortunately I can't remember what it was now. –  ptman Jan 28 '10 at 22:12
1  
Agreed with MikeyB. Many tools will detect the disk as being unpartitioned and you can happily blow it away without realizing it. –  Kamil Kisiel Jan 28 '10 at 22:24
    
FYI, grub2 can boot straight into an LVM, no DOS partitions needed. Mind you, some distro installers may whine and not let you install without /boot on a DOS partition, but it's not actually necessary. I've only done this on one system so far using ubuntu 10.10 server, but it works fine. –  Kyle__ Apr 1 '11 at 16:29

Actually I think it depends on your needs. If, say, for example, you will need 3 different VGs, and you don't know how much disk space each will use, and want to grow them in the future based on the needs, you will probably be better off with multiple spare PVs on different partitions, say, 20GB each (or whatever). So, when the time comes, you can add 20GB to the VG that needs it, and still have more to spare in case other VG needs space.

share|improve this answer

I believe the point of LVM is to move the partitioning "up one layer" and for it to work best, it should know the most it can about the physical disk itself. So, one partition from LVM's point of view is right. The more you add, the more choices you are removing from its control and the less good it will become.

This is not about LVM as much as ANY physical/logical split like this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.