1

I have some few servers (Ubuntu 16) and it's a mess who LVM was configured and used by my predecesor (for me, maybe is not). I have to install new server (Ubuntu 18) but I won't do a mess like is it right now. So I start looking for the best pratice and reason to do it it'so hard to find answers.

My idea right now is to that, separate data and OS (there is a drive only for the /boot, don't ask me why). Now I can add disk and add it to a Volume Group for the OS or for the data. And if a drive die only one of the volume group will be lost right ?

                                                      mount on /
                                                  with the swap file            mount on /data
                                                          ^                             ^
                                                          |                             |
                                                          |                             |
                                              +-----------+----------+      +-----------+----------+
                                              |                      |      |                      |
                                              |    LV: vg_1_lv_1     |      |    LV: vg_2_lv_2     |
                                              |                      |      |                      |
                                              +----------+-----------+      +----------+-----------+
                                                         |                             |
                                                         |                             |
                                              +----------+-----------+      +----------+-----------+
                        mount on /boot        |                      |      |                      |
                               ^              |       VG: vg_1       |      |       VG: vg_2       |
                               |              |                      |      |                      |
                               |              +----------+-----------+      +----------+-----------+
                               |                         |                             |
+-------------+      +---------+-------+      +----------+-----------+      +----------+-----------+
|  /dev/sda1  |      |   /dev/sda2     |      |                      |      |                      |
|  BIOS boot  |      | Linux filesystem|      |    PV: /dev/sdb      |      |    PV: /dev/sdc      |
+------+------+      |      ext4       |      |                      |      |                      |
       |             +---------+-------+      +----------+-----------+      +----------+-----------+
       |                       |                         |                             |
+------+-----------------------+-------+      +----------+----------+       +----------+----------+
|               /dev/sda               |      |      /dev/sdb       |       |      /dev/sdc       |
+--------------------------------------+      +---------------------+       +---------------------+

I have few question:

  • Do I need to partitionning a disk before use it in a LVM instance ?
    One said "yes" source and in The documentation of RedHat it said "no"source

  • If I need to partitionning a disk, which type I choose ?
    I mean is a long list of partition types

  • Use a whole disk isn't good ? Why ?
    Second thing, TLDP LVM HOW TO don't recommand to use a whole disk as a PV and explain but in the RedHat Doc (above) they are no warning about it. Actually, I quite abuse of this utilisation.

  • Possible duplicate of [Does LVM need a partition table?](https://serverfault.com/questions/439022/does-lvm-need-a-partition-table) – fuero Jul 02 '19 at 14:57
  • 1
    I'm a ware about this post, i even link it in this post about the "yes" answer about the need to partitioning disk .As I explain it, there are some answers who contradicted himself. – Alexandre Serrano Jul 02 '19 at 15:02
  • Oops - missed that. I've added an answer, check it out ;-) – fuero Jul 02 '19 at 23:00

2 Answers2

1

As I've overlooked the link to the question I thought of this being a duplicate, let's work on an updated answer as the linked question has no accepted one and is a little dated.

To summarize the answers given: Why would we use plain block devices for LVM instead of creating partitions?

Pros:

  • Block alignment no longer requires a partition, LVM is perfectly capable of doing this on its own.
  • Flexibility when resizing disks/volumes, this would otherwise need reboots in particular cases. Particularly annoying in virtualization scenario.
  • No need for tools like parted, fdisk, kpartx to manage such volumes/disks

Cons:

  • Confusion by novices (Bleeding of LVM info into the hypervisor, potential dangers when troubleshooting)

There's no reason for adding a partition from a purely technical standpoint, and the cautious perspective can be mitigated with proper configuration (filtering LVM devices) and training of new hires.

Not adding partitions makes changes easier without service disruption, the alternative is more dangerous and error prone.

If it helps, my recommendation is to use small disks for booting, and use LVM for the rest - my usual setup for CentOS VM templates is:

512M Disk, EFI/MBR boot volume. Hosts /boot|/boot/efi respectively.
14G Disk, Template LVM PV disk
6G root (/) volume
5G /var volume
1G /var/tmp
Rest /var/log

After cloning, resize with pvresize, lvresize, resize2fs/xfs_growfs to your needs.

fuero
  • 9,413
  • 1
  • 35
  • 40
1

No, don't bother partitioning a LVM PV

Linux LVM PV on entire disk devices (aka LUNs) work just fine, and allows skipping the partitioning step. The only reason for the caution is tools or people that assume partitions and accidentally reformat it.

Yes, you need all PVs to access a VG. (Exceptions include the redundancy volume types like mirror or raid.) Simple one PV per VG works well, as online expansion of disks is usually possible.

Disk layout is a matter of personal preference. For example, one small OS disk is easily achieved by installing a distro with the root file system on LVM. The installer probably will partition the root VG's PV by default, which is fine. Later, create data VGs on separate disks, and mount points where your data and applications are stored.

John Mahowald
  • 30,009
  • 1
  • 17
  • 32