How to create a LVM Partition/physical volume > 2TB
Solution 1
It seems that by creating a partition to use as a physical volume in LVM, we're limited to a 2TB volume size. This is due to the limitations in the legacy MSDOS partition table system managed by fdisk
and why one should use GPT.
Fortunately, LVM also understands plain devices without a partition table. This has the drawback that you'll have to use the whole device as physical volume, but that's exactly what I want to achieve.
To erase the current partition table execute the following command (Warning: this effectively erases all contents on the disk!):
sudo dd if=/dev/zero of=PhysicalVolume bs=512 count=1
replacing PhysicalVolume
with your device path, e.g. /dev/sdb
. Then run
sudo partprobe
to let the kernel re-read the new now non-existing partition table.
Now actually format it as an LVM physical volume:
sudo pvcreate PhysicalVolume
(again, replace PhysicalVolume
with your device path)
This is based on the information mentioned in the manpage of pvcreate
:
DESCRIPTION
pvcreate initializes PhysicalVolume for later use by the Logical Volume
Manager (LVM). Each PhysicalVolume can be a disk partition, whole
disk, meta device, or loopback file. For DOS disk partitions, the
partition id should be set to 0x8e using fdisk(8), cfdisk(8), or a
equivalent. For whole disk devices only the partition table must be
erased, which will effectively destroy all data on that disk. This can
be done by zeroing the first sector with:
dd if=/dev/zero of=PhysicalVolume bs=512 count=1
Solution 2
FWIW, GPT fdisk (gdisk
, sgdisk
, and cgdisk
) can convert from MBR to GPT, with certain caveats about where partitions are placed. Learning about GPT will be necessary sooner or later, so you might as well do it now. Using the whole disk as a PV also works, but it has drawbacks of its own. Most importantly, a disk utility that's unfamiliar with LVM could misbehave when it sees a "raw" PV instead of a partition table. This could have unknown consequences in the future.
Solution 3
You can use gdisk
for partitions bigger than 2TB.
Example:
# gdisk /dev/xvdk
GPT fdisk (gdisk) version 0.8.6
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-12582911966, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-12582911966, default = 12582911966) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8e00
Changed type of partition to 'Linux LVM'
That will create LVM partition that will occupy all space on given physical volume.
Credit goes to nixCraft
:
Linux Creating a Partition Size Larger Than 2TB
Related videos on Youtube
Adam Nygate
Updated on September 18, 2022Comments
-
Adam Nygate over 1 year
I was following this tutorial found here: How to set up multiple hard drives as one volume?
Which was working out great however i have a 3TB drive and every time i create the partition (whether it be via fdisk or gparted), after i start creating the volumes in LVM, my partition is re-sized to 2TB and the partition table becomes msdos which doesn't allow me to create any more partitions or to extend the current partition.
Is there a way that i can get a 3TB drive working with LVM?
Thanks, Adam
-
gertvdijk about 11 yearsI think what you mean is that the lack of 2TB+ assignments is due to the legacy msdos partition table and that you need to avoid creating a partition table and use the entire device instead. "Formatting" and "Partitioning" are two different things. And you certainly can't format a parition table with
pvcreate
. I'll change the answer. :) -
gertvdijk about 11 yearsYes, of course. But I do prefer the approach to use the whole disk as PV. 1) no alignment issues. 2) no need to create a GPT one's not familiar with. 3) less steps required.
-
Rod Smith about 11 yearsYes, such a utility is broken. Unfortunately, broken utilities do exist. Defending yourself against them shouldn't be required, but as a practical matter, it is necessary.