• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to Create, Extend, and Remove LVM on Debian 12

  • 00:48 cat /etc/os-release
  • 01:01 lsblk
  • 01:10 pvcreate /dev/sdb /dev/sdc
  • 01:31 pvs
  • 01:36 vgcreate volumegroup /dev/sdb /dev/sdc
  • 02:10 vgs
  • 02:20 lsblk
  • 02:31 pvcreate /dev/sda
  • 02:50 pvs
  • 03:01 vgextend volumegroup /dev/sda
  • 03:41 vgs
  • 03:52 lvcreate -L +1G -n logicalvolume volumegroup
  • 05:40 lvs
  • 05:51 mkfs -t ext4 /dev/volumegroup/logicalvolume
  • 06:07 mkdir lvolume
  • 06:31 mount /dev/volumegroup/logicalvolume /root/lvolume
  • 07:17 df -h
  • 07:41 vim /etc/fstab
  • 08:42 umount /root/lvolume
  • 09:04 mount -a
  • 09:12 df -h
  • 09:23 lvs
  • 09:37 lvextend -L +2G /dev/volumegroup/logicalvolume
  • 10:10 lvs
  • 10:21 df -h
  • 10:31 resize2fs /dev/volumegroup/logicalvolume
  • 11:04 df -h
  • 11:17 lvcreate -i 3 -I128k -L +2G -n stripedlv volumegroup
  • 12:12 lvs
  • 12:26 lvcreate -m1 -L +2G -n mirrorlv volumegroup
  • 13:17 lvs
  • 13:21 umount /root/lvolume
  • 13:43 lvremove /dev/volumegroup/logicalvolume
  • 13:51 lvremove /dev/volumegroup/stripedlv
  • 14:26 lvs
  • 14:44 vgreduce volumegroup /dev/sda
  • 14:55 vgreduce volumegroup /dev/sdb
  • 15:15 vgs
  • 15:47 vgremove /dev/volumegroup
  • 16:07 pvs
  • 16:10 pvremove /dev/sda
  • 16:21 pvremove /dev/sdb /dev/sdc
7852

To Create, Extend, Remove LVM On Debian 12

Introduction

Logical Volume Management (LVM) is a disk management solution used in Linux systems, offering advanced features for efficient disk storage management. It acts as a buffer between physical storage devices (e.g., hard drives, solid-state drives, or partitions) and the filesystems they contain. LVM enables system administrators to easily allocate, resize, and relocate storage capacity without interrupting data access or services, making it a valuable tool for both desktop and server environments.

Procedure Steps

Step 1: Check the OS version by using the below command.

root@linuxhelp:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL=https://bugs.debian.org/

Step 2: Check disks by using the below command

root@linuxhelp:~# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda      8:0    0   10G  0 disk 
sdb      8:16   0    5G  0 disk 
sdc      8:32   0    5G  0 disk 
sdd      8:48   0   60G  0 disk 
├─sdd1   8:49   0  1.9G  0 part /boot
├─sdd2   8:50   0  3.7G  0 part [SWAP]
└─sdd3   8:51   0 54.4G  0 part /
sr0     11:0    1 1024M  0 rom  

Step 3: Create physical volumes by using the below command

root@linuxhelp:~# pvcreate /dev/sdb /dev/sdc
  Physical volume "/dev/sdb" successfully created.
  Physical volume "/dev/sdc" successfully created.

Step 4: Check the physical volumes by using the below command

root@linuxhelp:~# pvs
  PV         VG Fmt  Attr PSize PFree
  /dev/sdb      lvm2 ---  5.00g 5.00g
  /dev/sdc      lvm2 ---  5.00g 5.00g

Step 5: Create volume group by using the below command

root@linuxhelp:~# vgcreate volumegroup /dev/sdb /dev/sdc
  Volume group "volumegroup" successfully created

Step 6: Check the volume group by using following command.

root@linuxhelp:~# vgs
  VG          #PV #LV #SN Attr   VSize VFree
  volumegroup   2   0   0 wz--n- 9.99g 9.99g

Step 7: Check disks by using following command for extend volume group size.

root@linuxhelp:~# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda      8:0    0   10G  0 disk 
sdb      8:16   0    5G  0 disk 
sdc      8:32   0    5G  0 disk 
sdd      8:48   0   60G  0 disk 
├─sdd1   8:49   0  1.9G  0 part /boot
├─sdd2   8:50   0  3.7G  0 part [SWAP]
└─sdd3   8:51   0 54.4G  0 part /
sr0     11:0    1 1024M  0 rom  

Step 8: Create a raw disk to physical volume to extend volume group size by using the below command.

root@linuxhelp:~# pvcreate /dev/sda
  Physical volume "/dev/sda" successfully created.

Step 9: Check the physical volumes by using following command.

root@linuxhelp:~# pvs
  PV         VG          Fmt  Attr PSize  PFree 
  /dev/sda               lvm2 ---  10.00g 10.00g
  /dev/sdb   volumegroup lvm2 a--  <5.00g <5.00g
  /dev/sdc   volumegroup lvm2 a--  <5.00g <5.00g

Step 10: Extend the volume group size by using the below command.

root@linuxhelp:~# vgextend volumegroup /dev/sda
  Volume group "volumegroup" successfully extended

Step 11: Check volume group size by using following command.

root@linuxhelp:~# vgs
  VG          #PV #LV #SN Attr   VSize   VFree  
  volumegroup   3   0   0 wz--n- <19.99g <19.99g

Step 12: Create linear logical volume by using the below command.

root@linuxhelp:~# lvcreate -L +1G -n logicalvolume volumegroup
  Logical volume "logicalvolume" created.

Step 13: Check the logical volume by using the below command.

root@linuxhelp:~# lvs
  LV            VG          Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  logicalvolume volumegroup -wi-a----- 1.00g   

Step 14: Make the file system for logical volume by using the below command

root@linuxhelp:~# mkfs -t ext4 /dev/volumegroup/logicalvolume
mke2fs 1.47.0 (5-Feb-2023)
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: 35382189-25bd-4c42-b61b-4655168fe29f
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

Step 15: Create a directory to mount file system by using the below command.

root@linuxhelp:~# mkdir lvolume

Step 16: Mount the file system temporarily by using the below command.

root@linuxhelp:~# mount /dev/volumegroup/logicalvolume /root/lvolume

Step 17: Check the file system size and mount point by using the below command.

root@linuxhelp:~# df -h
Filesystem                             Size  Used Avail Use% Mounted on
udev                                   1.4G     0  1.4G   0% /dev
tmpfs                                  291M  1.5M  289M   1% /run
/dev/sdd3                               54G   13G   38G  25% /
tmpfs                                  1.5G     0  1.5G   0% /dev/shm
tmpfs                                  5.0M  8.0K  5.0M   1% /run/lock
/dev/sdd1                              1.8G  140M  1.6G   9% /boot
tmpfs                                  291M   88K  291M   1% /run/user/1000
/dev/mapper/volumegroup-logicalvolume  974M   24K  907M   1% /root/lvolume

Step 18: Mount the file system permanently by using the below command.

root@linuxhelp:~# vim /etc/fstab 
/dev/mapper/volumegroup-logicalvolume /root/lvolume ext4 defaults 0 1

Step 19: Unmount the file system for checking permanently mount by using the below command.

root@linuxhelp:~# umount /root/lvolume

Step 20: Apply all permanent mount by using the below command.

root@linuxhelp:~# mount -a

Step 21: Check the file system size and mount point by using the below command

root@linuxhelp:~# df -h
Filesystem                             Size  Used Avail Use% Mounted on
udev                                   1.4G     0  1.4G   0% /dev
tmpfs                                  291M  1.5M  289M   1% /run
/dev/sdd3                               54G   13G   38G  25% /
tmpfs                                  1.5G     0  1.5G   0% /dev/shm
tmpfs                                  5.0M  8.0K  5.0M   1% /run/lock
/dev/sdd1                              1.8G  140M  1.6G   9% /boot
tmpfs                                  291M   88K  291M   1% /run/user/1000
/dev/mapper/volumegroup-logicalvolume  974M   24K  907M   1% /root/lvolume

Step 22: Check the logical volume by using the below command.

root@linuxhelp:~# lvs
  LV            VG          Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  logicalvolume volumegroup -wi-ao---- 1.00g         

Step 23: Extend the logical volume by using the below command.

root@linuxhelp:~# lvextend -L +2G /dev/volumegroup/logicalvolume
  Size of logical volume volumegroup/logicalvolume changed from 1.00 GiB (256 extents) to 3.00 GiB (768 extents).
  Logical volume volumegroup/logicalvolume successfully resized.

Step 24: Check the logical volume by using the below command.

root@linuxhelp:~# lvs
  LV            VG          Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  logicalvolume volumegroup -wi-ao---- 3.00g       

Step 25: Check the file system size by using the below command.

root@linuxhelp:~# df -h
Filesystem                             Size  Used Avail Use% Mounted on
udev                                   1.4G     0  1.4G   0% /dev
tmpfs                                  291M  1.5M  289M   1% /run
/dev/sdd3                               54G   13G   38G  25% /
tmpfs                                  1.5G     0  1.5G   0% /dev/shm
tmpfs                                  5.0M  8.0K  5.0M   1% /run/lock
/dev/sdd1                              1.8G  140M  1.6G   9% /boot
tmpfs                                  291M   88K  291M   1% /run/user/1000
/dev/mapper/volumegroup-logicalvolume  974M   24K  907M   1% /root/lvolume

Step 26: Extend the file system size by using the below command.

root@linuxhelp:~# resize2fs /dev/volumegroup/logicalvolume
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/volumegroup/logicalvolume is mounted on /root/lvolume; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/volumegroup/logicalvolume is now 786432 (4k) blocks long.

Step 27: Check the file system size by using the below command.

root@linuxhelp:~# df -h
Filesystem                             Size  Used Avail Use% Mounted on
udev                                   1.4G     0  1.4G   0% /dev
tmpfs                                  291M  1.5M  289M   1% /run
/dev/sdd3                               54G   13G   38G  25% /
tmpfs                                  1.5G     0  1.5G   0% /dev/shm
tmpfs                                  5.0M  8.0K  5.0M   1% /run/lock
/dev/sdd1                              1.8G  140M  1.6G   9% /boot
tmpfs                                  291M   88K  291M   1% /run/user/1000
/dev/mapper/volumegroup-logicalvolume  3.0G   24K  2.8G   1% /root/lvolume

Step 28: Create striped logical volume by using the below command.

root@linuxhelp:~# lvcreate -i 3 -I128k -L +2G -n stripedlv volumegroup
  Rounding size 2.00 GiB (512 extents) up to stripe boundary size 2.00 GiB (513 extents).
  Logical volume "stripedlv" created.

Step 29: Check the logical volume by using the below command.

root@linuxhelp:~# lvs
  LV            VG          Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  logicalvolume volumegroup -wi-ao---- 3.00g                                                    
  stripedlv     volumegroup -wi-a----- 2.00g      

Step 30: Create mirror logical volume by using the below command.

root@linuxhelp:~# lvcreate -m1 -L +2G -n mirrorlv volumegroup
  Logical volume "mirrorlv" created.

Step 31: Check the logical volume by using the below command.

root@linuxhelp:~# lvs
  LV            VG          Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  logicalvolume volumegroup -wi-ao---- 3.00g                                                    
  mirrorlv      volumegroup rwi-a-r--- 2.00g                                    100.00          
  stripedlv     volumegroup -wi-a----- 2.00g     

Step 32: unmount the logical volume file system by using the below command.

root@linuxhelp:~# umount /root/lvolume

Step 33: Remove the logical volumes by using the below command.

root@linuxhelp:~# lvremove /dev/volumegroup/logicalvolume
Do you really want to remove active logical volume volumegroup/logicalvolume? [y/n]: y
  Logical volume "logicalvolume" successfully removed.
root@linuxhelp:~# lvremove /dev/volumegroup/stripedlv
Do you really want to remove active logical volume volumegroup/stripedlv? [y/n]: y
  Logical volume "stripedlv" successfully removed.
root@linuxhelp:~# lvremove /dev/volumegroup/mirrorlv
Do you really want to remove active logical volume volumegroup/mirrorlv? [y/n]: y
  Logical volume "mirrorlv" successfully removed.

Step 34: Check the logical volume by using the below command.

root@linuxhelp:~# lvs

Step 35: Remove the physical volumes from volume group by using the below command.

root@linuxhelp:~# vgreduce volumegroup /dev/sda
  Removed "/dev/sda" from volume group "volumegroup"
root@linuxhelp:~# vgreduce volumegroup /dev/sdb
  Removed "/dev/sdb" from volume group "volumegroup"

Step 36: Check the volume group by using the below command.

root@linuxhelp:~# vgs
  VG          #PV #LV #SN Attr   VSize  VFree 
  volumegroup   1   0   0 wz--n- <5.00g <5.00g

Step 37: Remove the volume group by using the below command.

root@linuxhelp:~# vgremove /dev/volumegroup
  Volume group "volumegroup" successfully removed

Step 38: Check the physical volumes by using the below command.

root@linuxhelp:~# pvs
  PV         VG Fmt  Attr PSize  PFree 
  /dev/sda      lvm2 ---  10.00g 10.00g
  /dev/sdb      lvm2 ---   5.00g  5.00g
  /dev/sdc      lvm2 ---   5.00g  5.00g

Step 39: Remove the physical volumes by using the below command.

root@linuxhelp:~# pvremove /dev/sda
  Labels on physical volume "/dev/sda" successfully wiped.
root@linuxhelp:~# pvremove /dev/sdb /dev/sdc
  Labels on physical volume "/dev/sdb" successfully wiped.
  Labels on physical volume "/dev/sdc" successfully wiped.

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to Create, Extend, Remove LVM on Debian 12. Your feedback is much welcome

Tags:
caden
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What is Logical Volume Manager?

A

Logical Volume Management (LVM) allocates disk space flexibly, allowing administrators to dynamically resize volumes and filesystems as needed without disrupting services. LVM abstracts the physical storage devices (such as hard drives or SSDs) into logical volumes, which can then be managed independently of the underlying hardware.

Q

How do I create an LVM volume?

A

To create an LVM volume, you typically follow these steps:
1. Initialize physical volumes (PVs) on the desired storage devices using pvcreate.
2. Create a volume group (VG) with one or more physical volumes using vgcreate.
3. Create logical volumes (LVs) within the volume group using lvcreate.
4. Format the logical volumes with a filesystem using mkfs.
5. Mount the logical volumes to a directory in the filesystem.

Q

Can I resize LVM volumes?

A

Yes, one of the main benefits of LVM is its ability to resize logical volumes dynamically. You can resize a logical volume by using lvresize to increase or decrease its size, and then resize the filesystem within the logical volume to match the new size using filesystem-specific tools (resize2fs for ext2/3/4, xfs_growfs for XFS, etc.).

Q

How do I add more storage to an existing LVM setup?

A

To add more storage to an existing LVM setup, you can follow these general steps:
1. Add one or more new physical volumes (disks or partitions) to the system.
2. Initialize the new physical volumes using pvcreate.
3. Extend the existing volume group to include the new physical volumes using vgextend.
4. Allocate space from the extended volume group to existing or new logical volumes using lvextend.
5. Resize the filesystem within the logical volume to utilize the additional space.

Q

Is it possible to remove a physical volume from an LVM setup?

A

Yes, you can remove a physical volume from an LVM setup, but it requires careful planning and execution to avoid data loss. Generally, you would follow these steps:
1. Migrate data off the physical volume you want to remove to other volumes.
2. Remove the physical volume from the volume group using vgreduce.
3. Optionally, use pvmove to relocate data from the physical volume to other volumes in the volume group before removing it.
4. After ensuring no data remains on the physical volume, use pvremove to wipe LVM metadata from the physical volume.

Related Tutorials in How to Create, Extend, and Remove LVM on Debian 12

Related Tutorials in How to Create, Extend, and Remove LVM on Debian 12

How to install Gparted on Debian 9.0
How to install Gparted on Debian 9.0
Sep 13, 2017
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Sep 19, 2018
How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
Oct 17, 2022
How to install and update OpenSSL on Debian 11.3
How to install and update OpenSSL on Debian 11.3
Oct 21, 2022
How to install qBittorrent on Debian 9.0
How to install qBittorrent on Debian 9.0
Sep 8, 2017
How to Install FileZilla in Debian
How to Install FileZilla in Debian
Nov 29, 2016
How to Install and Configure Mega in Linux
How to Install and Configure Mega in Linux
Jul 19, 2016
How to Manage and Create LVM on CentOS 7
How to Manage and Create LVM on CentOS 7
Mar 6, 2018

Related Forums in How to Create, Extend, and Remove LVM on Debian 12

Related Forums in How to Create, Extend, and Remove LVM on Debian 12

Linux
jayce class=
shasum command not found
May 5, 2017
Linux
stephan class=
How to list all samba users
Jan 12, 2018
LVM (Logical Volume Manager)
connor class=
How to activate and deactivate Logical volumes, Volume group and Physical volume
Feb 16, 2017
pv command
muhammad class=
pvcreate command not found error
May 9, 2017
Linux
henry class=
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
Apr 25, 2017
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Linux
baseer class=
single command to apply setfacl for multiple user at a time
Jan 23, 2018
Linux
beulah class=
What does mean by 0 0 value in fstab file
Jan 2, 2018

Related News in How to Create, Extend, and Remove LVM on Debian 12

Related News in How to Create, Extend, and Remove LVM on Debian 12

Anbox, the Android-to-Linux tool the developers have been waiting for
Anbox, the Android-to-Linux tool the developers have been waiting for
Apr 17, 2017
Linus Torvalds stops signing Linux kernel RC tarballs
Linus Torvalds stops signing Linux kernel RC tarballs
May 17, 2017
Capsule8 Launches Linux-Based Container Security Platform
Capsule8 Launches Linux-Based Container Security Platform
Feb 14, 2017
Symantec updates Management console product
Symantec updates Management console product
Nov 22, 2017
Latest Linux driver release feature seven AMD Vega
Latest Linux driver release feature seven AMD Vega
Mar 23, 2017
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
Apr 9, 2019
Microsoft makes its Azure App service now available on Linux Systems
Microsoft makes its Azure App service now available on Linux Systems
Sep 7, 2017
Docker friendly Alpine Linux gets hardened Node.js
Docker friendly Alpine Linux gets hardened Node.js
Apr 19, 2017
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Luke ?
workbench for debian

I am using workbench in CentOS whereas now I need to use Debian Operating system so could you please help to install and use in Debian?

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.