TRENDING
  • Linux
  • Shell Script
  • Cloud
  • DevOps
  • About US
SUBSCRIBE
  • CLOUD
  • DEVOPS
  • LINUX
  • SHELL SCRIPT
Reading: Linux LVM Logical Volume for AlmaLinux / Rocky Linux
Share
TechBrownTechBrown
Aa
  • CLOUD
  • DEVOPS
  • LINUX
  • SHELL SCRIPT
Search
  • CLOUD
  • DEVOPS
  • LINUX
  • SHELL SCRIPT
Follow US
© 2014 - 2022 TechBrown. All Rights Reserved.
Linux

Linux LVM Logical Volume for AlmaLinux / Rocky Linux

January 31, 2015
Share
4 Min Read
SHARE
Contents
Step-I (Make new partition)Step-II (Vgcreate vgname pvname(list))Step-III (Now create Logical Volume)Step-IV (Remove LVM partition)Step-V (For to remove VG)Step-VI (Create swap LVM)Step-VII (To remove swap)Step-VIII (Extend LV)Step-IX (Reduce LV)Step-X (resize2fs LVname targated size)Step-XI (Using Physical extent and logical extent)

In LVM we can merge many hard drives & make it as a single hard drive. In previous we cannot resize the file system. Also we have some partition limit in AlmaLinux / Rocky Linux / Amazon Linux. If you make a hard drive of 10G using simple partition technique and somehow your drive get full so here we cannot expand it or reduce it. So we use LVM to get those advantages of reducing and expanding drives.lvm2
Here we create 8 physical volume and using it we generate 1 Volume Group 1 TB. And we use 700G to create three logical volume and there is 300G remains in VG. The first LV get full so we use remaining 300G to extend that LV so such a way we can create LV and use it.
LVM
Here,
PV-> Physical volume
VG-> Volume Group
LV -> Logical Volume

Step-I (Make new partition)
# fdisk  /dev/sda

n:
e extended
p primary partition (1-4)
Make extended partition and then create partition using it.
First cylinder:
second cylinder :+5G
Create 3 more partition like this.

Then toggle it. To toggle type t

t: (x) (y) (z)  (8e)
:p:
:w
# partx   -a   /dev/sda
# pvcreate   /dev/sdax

OR

# pvcreate  /dev/sdax   /dev/sday   /dev/sdaz

Now create physical volume to create it

# pvdisplay

Or

# pvs  /dev/sdax

Now create VG.

Step-II (Vgcreate vgname pvname(list))
# vgcreate   myvol   /dev/sdax  /dev/sday  /dev/sdaz
# vgdisplay

OR

# vgs myvol

Lvm3

Step-III (Now create Logical Volume)

lvcreate -L lvsize -n Lvname vgname

# lvcreate  -L  2G  -n  lv1  myvol
# lvdisplay

Now Assign file system.

# mkfs.ext4  /dev/myvol/lv1
# mkdir /data
# vim /etc/fstab
/dev/myvol/lv1    /data    ext4   defaults   0    0
:wq
# mount    –a
# df   -hT
Step-IV (Remove LVM partition)
# umount   /data
# vim /etc/fstab

Remove entry

# lvremove   /dev/myvol/lv1
Step-V (For to remove VG)

First remove all active LVM then remove VG.

# vgremove   myvol
# pvremove  /dev/sdax   /dev/sday   /dev/sdaz
# fdisk  /dev/sda
Step-VI (Create swap LVM)
# lvcreate   -L  +2G  -n   lv2   myvol
# mkswap  /dev/myvol/lv2
# vim   /etc/fstab
/dev/myvol/lv2     swap    swap    default    0    0
:wq
#swapon    -a
# cat /proc/swaps
Step-VII (To remove swap)
# swapof  -a
Step-VIII (Extend LV)
# vgs   myvol

Spaces are remaining then extend LV.

# lvextend   -L   +5G   /dev/myvol/lv1
# resize2fs   /dev/myvol/lv1
Step-IX (Reduce LV)
-Cannot reduce LVM partition on online mode
 -Only free space can reduce
# umount   /data
# df  -hT
# fsck.ext4   -f   /dev/myvol/lv1
Step-X (resize2fs LVname targated size)
# resize2fs   /dev/myvol/lv1   7G

lvreduce -L size (targeted size) LVname

# lvreduce -L 7G  /dev/myvol/lv1
# mount   -a
#  df   -hT
Step-XI (Using Physical extent and logical extent)
# vgcreate  -s  8G  myvol   /dev/sdax
#  lvcreate   -l   20   -n   lv3  myvol.

LVM4
Congratulation the Linux LVM Logical volume for AlmaLinux / Rocky Linux / Amazon Linux has created.

You Might Also Like

How to Optimize MySQL Performance on AlmaLinux / Rocky Linux

How to Enable TLS 1.3 on Apache and Nginx

5 Security Tips to Protect your WordPress Website from Hackers

How to Enable AES-128 Bit SSL Cipher with TLS 1.3 on Nginx Web Server

How to Set Up NGINX Web Server on AlmaLinux / Rocky Linux

Sign Up For Newsletter

Be keep up! Get the latest articles delivered straight to your inbox.

TechBrown Solutions January 31, 2015
Share this Article
Facebook TwitterEmail Print
Share
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

TRENDING

Linux

How to Create User without using Useradd Command on AlmaLinux / Rocky Linux

Linux

RPM and YUM Commands Cheat Sheet for AlmaLinux / Rocky Linux

Linux

How to Sync Time with Timezone on AlmaLinux / Rocky Linux

Linux

How to Install Sophos Anti Virus on AlmaLinux / Rocky Linux

You Might Also Like

Linux

How to Optimize MySQL Performance on AlmaLinux / Rocky Linux

October 19, 2021
Linux

How to Enable TLS 1.3 on Apache and Nginx

March 14, 2021
Linux

5 Security Tips to Protect your WordPress Website from Hackers

November 8, 2020
Linux

How to Enable AES-128 Bit SSL Cipher with TLS 1.3 on Nginx Web Server

November 7, 2020

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

Follow US on Social Media

Facebook Twitter Youtube Rss

© 2014 - 2022 Techbrown. All Rights Reserved.

  • About Us
  • Terms of Service
  • Cookie Policy
  • Privacy Policy
By using this site, you agree to the Privacy Policy, Cookie Policy and Terms of Service.
Accept

Removed from reading list

Undo
AdBlock Detected
Our site is an advertising supported site. Please whitelist to support our site.
Okay, I'll Whitelist
Welcome Back!

Sign in to your account

Lost your password?