Free Trial

Free VPS Trial, no credit card required

Start Free Trial
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 · 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

Related Articles

Categories

Backup
6
Business Continuity
4
Cloud Hosting
9
Colocation
4
Company Updates
1
Cryptocurrencies
1
Data Centers
12
Dedicated Servers
4
Disaster Recovery
2
Forex
18
Gaming
1
iGaming
30
Industry News
31
Interviews
7
Joomla
9
Magento
5
Managed Services
1
Press Releases
49
Product News
6
Resellers
1
Security
22
Software & Apps
1
Streaming
1
Tech Startups
12
Tutorials
37
Uncategorized
390
Vps Hosting
10
Web Design & Development
3
Web Hosting
42
Webinars
1
Wordpress
14

Free VPS Trial

No Credit Card Required.

Recent Posts

Best 5 Open Source Web Servers in 2022

Best 5 Open Source Web Servers in 2022

05 July, 2022

NetShop ISP Completes Casino Games Audit for Slots Development Company, Fugaso

NetShop ISP Completes Casino Games Audit for Slots Development Company, Fugaso

30 June, 2022

How To Install Zimbra 9 on Ubuntu 20.04 Server using Automatic Installer

How To Install Zimbra 9 on Ubuntu 20.04 Server using Automatic Installer

29 June, 2022

NetShop ISP Announces Reinforcement of myNetShop Security with Multi-Factor Authentication

NetShop ISP Announces Reinforcement of myNetShop Security with Multi-Factor Authentication

28 June, 2022

Magento 2 Hosting: Recommended Hardware Requirements

Magento 2 Hosting: Recommended Hardware Requirements

24 June, 2022

Products

Bare Metal Dedicated Servers

Virtual Servers (VPS / VDS)

Rack Space & Colocation Hosting

Fast Web Hosting

Cloud Backup

Premium DNS Hosting

Resources

Blog

Videos

Events

APIConnect

WhitepapersNew

Company

About Us

CareersNew

Awards & Honours

Become a Partner

Contact Us

#letushostyou

Award Winning Hosting Provider with a Customer-centric approach to Business and an Open Source Mindset regarding Solutions and Products Development.

Est. 2004, Larnaca – Cyprus


About

Legal Address: 2A, Marathonos, Livadhia, 7060, Cyprus

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

Company Reg: HE 217340
EU VAT Number: CY10217340J
ISO 9001:2015: No. QS.21.038

International Phone: +357 2425 0808