The Linux OS is a powerful tool. You can manage partitions on the fly, even enlarge, add and move them between physical disks. All on the fly and without downtime. Logical Volume Management technology is designed to do all this and more. I'll describe what LVM can do and how to use this technology in this article.
In a previous article I described how to Linux software RAID. LVM can do RAID too, plus it can do a lot of other things and is suitable for servers, where storage space requirements may change and you may need to make changes to disks while the system is running without service interruption.
For example, you will encounter LVM if you are using proxmox. And a lot of automatic installers will use LVM for disk management by default. So it may be useful to at least know LVM so you won't be surprised when you come across this technology.
What is LVM
- change (increase) the size of the block device (disk) at runtime
- moving a block device to another physical disk
- merging multiple disks into one (equivalent to RAID0)
- creating block devices for Virtual Private Servers (VPS)
With options come complexities, making LVM more difficult to understand and navigate. The same is true with LVM, so you need to study and try the technology.
There is more work involved with LVM and unless you are planning major partition changes and disk purchases, it is unnecessary. Where it raises the possibility of needing to increase disk storage with minimal downtime, LVM is the ideal solution, along with a filesystem that can be expanded on the fly.
In a Linux distribution, Debian, the following command will install LVM support:
apt install lvm2
Some basic commands:
pvsview Physical Volumes
vgsview Volume Groups
lvsdisplay Logical Volumes
You can create an LVM on a disk or better a partition as follows:
- Creating Physical Volumes:
- Create Volume Groups:
vgcreate home_vg /dev/sdc1
- Creating Logical Volumes:
lvcreate -l 100%FREE -n home home_vg
Format the block device and modify filesystem parameters:
mkfs.ext4 -L server-backup /dev/mapper/home_vg-home tune2fs -c 0 -i 0 /dev/mapper/home_vg-home
Changes to LVM
Enlarge the partition so that you use all the available capacity:
pvcreate /dev/sde1 vgextend home_vg /dev/sde1 lvextend /dev/home_vg/home /dev/sde1 #OR: lvextend -l +100%FREE /dev/home_vg/home resize2fs /dev/home_vg/homeThe following command branches the logical volume /dev/myvg/homevol to 12GB
lvextend -L12G /dev/myvg/homevolThe following command adds 1GB to the existing logical volume size /dev/myvg/homevol.
lvextend -L+1G /dev/myvg/homevol
Enlarge the XFS filesystem:
Enlarge partition #1 on the xvda disk to use empty space. Typically if in VMWare or Proxmox you enlarge the disk that the VPS is using. (Not directly related to LVM) You need to enlarge a given partition and then the EXT filesystem also needs to be enlarged.
growpart /dev/xvda 1 resize2fs /dev/xvda1The
growpartprogram is included in the
growpartreports this error:
unexpected output in sfdisk --version [sfdisk from util-linux 2.36.1]It could also be that you are not using the English language on your system, and so the command in question does not understand the
sfdiskprogram it is using. The solution is to set your environment variable to English with the following command:
Deleting the LVM metadata on a given partition will also delete the RAID information or other signature of how the partition is used.
wipefs -a /dev/sdb3
For a detailed and visual demonstration of how to use LVM, see this
video tutorial on how to start using LVM:
More about LVMDebian.org LVM
Články na podobné téma
Running Microsoft SQL Server on Linux
Backup: the Proxmox Backup Server
Linux as a router and firewall
How to upload a docker image to the Docker Registry
Linux Software RAID
Running a web application behind a proxy
Docker multistage build
Importing Windows into Proxmox virtualization
Docker and PHP mail
Docker and Cron
Lenovo ThinkPad X1 Carbon: LTE modem EM7544 commissioning
Yocto Project: Build custom operating system for embedded devices
How to address poor file share performance in Docker
How to get started using Docker correctly
Installing Linux on a dedicated HPE ProLiant DL320e server
How to stress test a web application
Why use the JFS filesystem
How to boot from a 4TB drive with GTP using UEFI
Btrfs file system
WINE - running Windous programs under Linux
GNU/Linux operating system
If you are interested in receiving occasional news by email.
You can register by filling in your email news subscription.