2

Most documentations about LVM have roughly these steps:

fdisk /dev/sdb
pvcreate /dev/sdb1
vgcreate fileserver /dev/sdb1
lvcreate --name share --size 40G fileserver
mkfs.ext4 /dev/fileserver/share

In some documentations I have seen as well that they did another fdisk between lvcreate and mkfs. And in another documentation I have seen that they left the first fdisk away as well. I tested now on one of my machines where I didn't do any fdisk at all and it works.

My question is now is the fdisk needed at all on secondary (non boot) hard-disks? And why? And does the fdisk between lvcreate and mkfs give any advantage?

Raffael Luthiger
  • 330
  • 1
  • 4
  • 8
  • http://unix.stackexchange.com/a/183671/30851 - but fdisk on LV is unusual unless the LV is a block device for a virtual server. – frostschutz Apr 11 '15 at 16:07

1 Answers1

8

You do not need to create a partition table on a disk (neither the traditional kind created with fdisk nor the GPT kind created with, e.g. gdisk), you could make the whole block device into an LVM PV if you wanted to. However, other tools or other operating systems might accidentally mistake that device for an unformatted hard disk and offer to format it, so it can be error-prone. Basically there is hardly any downside to creating a partition table with one big partition on it occupying the whole disk and it's a bit safer, so why not do it.

If the disk is intended to be bootable then you will definitely require a partition table.

As for creating an inner partition table on an LVM LV, that is unnecessary and very unusual. It is not expected that you would do this. The only exception would be if the LVM is expected to be presented to a virtual machine as a raw block device. In that case, the VM might expect to put a partition table on it.

Celada
  • 43,173
  • 5
  • 96
  • 105