Create LVM Partition (Logical Volume Manager) on 4TB hard disk

Modified on Sat, 22 Mar at 7:36 PM

Task: Create LVM partition on 4 TB disk.


Step 1: Identify the Disk

First, list available disks to identify your 4TB hard disk.

bash
CopyEdit
lsblk fdisk -l

Assume the new disk is /dev/sdb (replace it with the actual disk name if different).


Step 2: Partition the Disk

  1. Use fdisk or parted to create a partition.

    Using fdisk:

    bash
    CopyEdit
    fdisk /dev/sdb
    • Press n (New partition)

    • Press p (Primary partition)

    • Press Enter (Default first sector)

    • Press Enter (Default last sector to use the full disk)

    • Press t (Change partition type)

    • Enter 8e (Linux LVM)

    • Press w (Write changes)

  2. Alternatively, using parted (for disks >2TB using GPT):

    bash
    CopyEdit
    parted /dev/sdb
    • mklabel gpt (Creates GPT partition table)

    • mkpart primary 1MiB 100% (Creates a full-disk partition)

    • set 1 lvm on (Sets the partition as LVM)

    • quit


Step 3: Create a Physical Volume (PV)

Initialize the partition for LVM:

bash
CopyEdit
pvcreate /dev/sdb1

Check:

bash
CopyEdit
pvdisplay

Step 4: Create a Volume Group (VG)

Create a volume group (e.g., vg_data):

bash
CopyEdit
vgcreate vg_data /dev/sdb1

Check:

bash
CopyEdit
vgdisplay

Step 5: Create a Logical Volume (LV)

Create a logical volume (e.g., lv_storage with full 4TB size):

bash
CopyEdit
lvcreate -l 100%FREE -n lv_storage vg_data

Check:

bash
CopyEdit
lvdisplay

Step 6: Format the Logical Volume

Format it with ext4 or xfs:

For ext4:

bash
CopyEdit
mkfs.ext4 /dev/vg_data/lv_storage

For xfs:

bash
CopyEdit
mkfs.xfs /dev/vg_data/lv_storage

Step 7: Mount the Volume

Create a mount point and mount it:

bash
CopyEdit
mkdir /mnt/storage mount /dev/vg_data/lv_storage /mnt/storage

To make it persistent, add it to /etc/fstab:

bash
CopyEdit
echo "/dev/vg_data/lv_storage /mnt/storage ext4 defaults 0 0" >> /etc/fstab

Replace ext4 with xfs if using XFS.


Step 8: Verify

Check the mount and LVM status:

bash
CopyEdit
df -h lsblk vgdisplay lvdisplay

Now, your 4TB LVM storage is ready! ? Let me know if you need any clarifications.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article