FREE TRIAL

Deploy a Free VPS Server Worldwide. No Credit Card Required.

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

Categories

Backup
6
Business Continuity
4
Cloud Hosting
10
Colocation
4
Company Updates
1
Cryptocurrencies
1
Data Centers
12
Dedicated Servers
4
Disaster Recovery
3
Forex
25
Gaming
1
iGaming
33
Industry News
32
Interviews
10
Joomla
9
Magento
5
Managed Services
1
Operating Systems
1
Press Releases
65
Product News
6
Resellers
1
Security
25
Software & Apps
1
Streaming
1
Tech Startups
12
Tutorials
60
Uncategorized
389
Vps Hosting
11
Web Design & Development
3
Web Hosting
44
Webinars
1
Wordpress
14

Free VPS Trial

No Credit Card Required.

Recent Posts

How To Fix Error Failed to download metadata for repo in CentOS 8

How To Fix Error Failed to download metadata for repo in CentOS 8

23 March, 2023

How can Forex Brokers be Protected from DDoS Attacks

How can Forex Brokers be Protected from DDoS Attacks

20 March, 2023

NetShop ISP Bronze Sponsors for the University of Cyprus at Harvard WorldMUN 2023

NetShop ISP Bronze Sponsors for the University of Cyprus at Harvard WorldMUN 2023

15 March, 2023

Top 5 Cloud Computing Trends in 2023

Top 5 Cloud Computing Trends in 2023

13 March, 2023

MetaTrader 4 and 5 Apps are back on Apple AppStore

MetaTrader 4 and 5 Apps are back on Apple AppStore

07 March, 2023

#letushostyou

Award Winning Hosting Provider established in 2004.

Best iGaming Service ProviderISO Certified

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

© 2023 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