NEW LOCATION

Olá Brazil Brazil NVMe-powered VPS Plans in Brazil Now Available.

Deploy Instantly
  • +357 2425 0808
  • Login
  • English

Home

Blog

How To Create Linux LVM Partition – Step...

How To Create Linux LVM Partition – Step-by-step Guide

How To Create Linux LVM Partition – Step-by-step Guide

NetShop ISP

NetShop ISP · Blog Author

Oct 27, 2021 · Technical Tutorials

In today’s article we will demonstrate how you can easily create an LVM partition on your Linux Server. Why LVM? Simply because it allows you to dynamically extend or shrink partitions in real-time!

In an era when Cloud servers and virtualization is greatly used by system admins, the LVM (Logical Volume Manager) allows you to resize Volume Groups (VG) by adding new physical volumes (PV) or deleting existing PVs attached to VGs.

In the end of this article you can find useful LVM commands. Let’s proceed with the steps to create a Linux LVM partition. For the sake of this article tutorial, we assume that you have inserted a new Hard Disk on your server.

Step-by-Step Guide to Create a Linux LVM Partition

  1. Connect on your server with root user (or other sudo privileged account)
  2. Type fdisk -l to identify your new hard disk device name. We assume that ours is named /dev/xvdb
  3. Type fdisk /dev/xvdb
  4. You are now into the fdisk command prompt, type the following commands in the order specified below:
    1. type n to create a new disk partition
    2. type p to create a primary partition
    3. type 1 to declare it as the first partition of your new Disk
    4. hit ENTER twice to accept the default start / end cylinders
    5. type t to change the default Linux partition to LVM partition type
    6. type L to list all partition types and search for the id for Linux LVM
    7. type 8e (as per list results from previous step) to change your partition into 8e, i.e. Linux LVM
    8. type w to write the partition table (basically to apply the changes from all previous steps) and exit fdisk upon completion
  5. Now it’s time to create a Physical Volume (PV) on our new hard disk: pvcreate /dev/xvdb1
  6. Create LVM Volume Group (VG) named vg0 with a physical extend size (PE) of 16MB: vgcreate -s 16M vg0 /dev/xvdb1
  7. To create a Logical Volume (LV) named lvol0 on VG vg0, type: lvcreate -L 400M -n lvol0 vg0
  8. Let’s format the Logical Volum lvol0 in a RHEL supported file system, e.g. EXT3: mkfs -t ext3 -m 1 -v /dev/mapper/vg0-lvol0
  9. Create a mount location for our new ext3 file system: mkdir /mnt/vfs
  10. Last step is to mount the new EXT3 file system to our newly created mount point: mount -t ext4 /dev/mapper/vg0-lvol0 /mnt/vfs
  11. You can confirm everything has been created correctly, by typing: df -h. An output as follows should appear:

/dev/mapper/vg0-lvol0 385M 12M 373M 3% /mnt/vfs

You are all set! Here is a list of some useful LVM commands to have in hand:

  • To display volume group settings (in our case of the VG named vg0) such as physical size (PE size), Volume group name (VG name), maximum logical volumes (Max LV), etc.
vgdisplay vg0
  • To list all physical volumes (PV) created for the volume group
pvscan
  • To add new physical volumes (PV) to an existing volume group, either through new hard disk or new disk partitions.
vgextend

Press Releases
78

Free VPS Trial

No Credit Card Required.

Recent Posts

How To Extract Certificates and Private Key from .PFX file

How To Extract Certificates and Private Key from .PFX file

19 November, 2024

NetShop ISP CEO Stefano Sordini to Moderate Key Panel on Forex AI Automation at Cyprus Fintech Summit 2024

NetShop ISP CEO Stefano Sordini to Moderate Key Panel on Forex AI Automation at Cyprus Fintech Summit 2024

15 November, 2024

Preparing for the Daylight Saving Time (DST) Change: Essential Updates for MetaTrader 4/5 Platforms

Preparing for the Daylight Saving Time (DST) Change: Essential Updates for MetaTrader 4/5 Platforms

25 October, 2024

NetShop ISP Celebrates 20 Years of Innovation and Excellence in Hosting and Data Center Solutions

NetShop ISP Celebrates 20 Years of Innovation and Excellence in Hosting and Data Center Solutions

22 October, 2024

NetShop ISP Makes Waves at Forex Expo Dubai 2024: Showcasing Cutting-Edge Hosting for the Financial Services Industry

NetShop ISP Makes Waves at Forex Expo Dubai 2024: Showcasing Cutting-Edge Hosting for the Financial Services Industry

09 October, 2024

#letushostyou

Award Winning Hosting Provider established in 2004.

120 Faneromenis Avenue, Imperial Tower, 2nd Floor, Larnaca 6031, Cyprus

Products

Bare Metal Servers

Customized Servers

Virtual / Cloud Servers

Forex VPS

Storage VPS

cPanel Web Hosting

Reseller Web Hosting

Colocation

Addons

Premium DNS

Email Hosting

Cloud Backup

DDoS Protection

Licenses

SSL Certificates

Domain Names

Premium SLAs

About Us

Data Center Locations

Looking Glass

Our Company

Contact Us

Careers in Cyprus

Become a Partner

Awards

Certifications

© 2024 S.S. NetShop Internet Services Ltd. All rights reserved.  Terms & Conditions  |  Privacy Policy
CY Reg. Number: HE 217340 | EU VAT Number: CY10217340J

Visa
Mastercard
PayPal
Bitcoin
Tether
Ethereum
Litecoin
Wise
Revolut
Wire Transfer