LVM – Logical Volume Manager
LVM is a device mapper that manages the block devices. LVM disk can be resized, expect boot volume (/boot) all other file system can be made into LVM partitions.
We can dynamically allocate / de-allocate the file system with out rebooting the server. For expansion of disk is an online change, while removing a disk requires a minimal downtime.
Unlike normal filesystem we can group the disk and make volumes, each volume can have one or more logical volumes.

1. Verify the disk
Suppose we have a newly added disk /dev/sdb, we need to create a lvm partition type.
[root@control ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 31.7G 0 disk
|-sda1 8:1 0 1G 0 part /boot
`-sda2 8:2 0 30.7G 0 part
|-cl-root 253:0 0 28.6G 0 lvm /
`-cl-swap 253:1 0 2.2G 0 lvm [SWAP]
sdb 8:16 0 1G 0 disk
sr0 11:0 1 1024M 0 rom
We could see sdb disk is allocated and the size of the disk is 1GB. also we could the disk is not used where as the sda disk is used for /boot,/ and swap.
also we can verify using fdisk command.
[root@control ~]# fdisk -l /dev/sdb Disk /dev/sdb: 1 GiB, 1073741824 bytes, 2097152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
2. Create a. LVM Partition
Using the fdisk command we are going to create a LVM filesystem
[root@control ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0x8d1a944e.
To create a partition enter the option ‘n’, and then press enter with the default options
Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p):
Select the default option p to continue, p is for primary disk , In a controller we can use upto 4 primary disk.
Using default response p. Partition number (1-4, default 1): First sector (2048-2097151, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-2097151, default 2097151): Created a new partition 1 of type 'Linux' and of size 1023 MiB. Press 'p' for the print the partition table
3. Print the partition table
Select the option p to print the partition table,
Command (m for help): p Disk /dev/sdb: 1 GiB, 1073741824 bytes, 2097152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x8d1a944e Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 2097151 2095104 1023M 83 Linux We could see the partation type is Linux, to change the partation type press 't' for toggle, then press 'L' to list the Hex code for partation, we are going to select 8e for the Linux LVM Command (m for help):
In the above example we could see the Id is 83, that means the current filesystem default is created as ext4 filesystem.
4. Change the filesystem type to LVM
By selecting the option ” t ” for toggle, we can change the required file system , as of now we are going to change the filesystem type to Linux LVM i.e., ” 8e “
Command (m for help): t Selected partition 1 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM'. Check the changes has been made by 'p' print option
You can list the list of filesystem that is supported by Linux using L.
5. Write the partition info changes.
Verify the partition type has been changed from Linux (83) to Linux LVM(8e)
Command (m for help): p Disk /dev/sdb: 1 GiB, 1073741824 bytes, 2097152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x8d1a944e Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 2097151 2095104 1023M 8e Linux LVM
We could see the Id as 8e and Type as Linux LVM, now we can write the changes to the disk. with “w” option you can write the changes to the disk
Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
Using udevadm settle command we need update the changes to the kernel, without rebooting the server
[root@control ~]# udevadm settle
We can use partprobe command, from RHEL 7 we can use the above command to update the partition table.
6. Conclusion
Depending upon the requirement we can format the filesystem as ext4, xfs, ntfs or any other filesystem that are supported in Linux. Hope you got an basic information on LVM filesystem creation.
You can also go through
LVM Howto – https://computercarriage.com/2020/05/12/lvm-howto/
lsblk commands – https://computercarriage.com/2020/05/18/list-block-devices-using-lsblk-command/
Storage migration using LVM – https://computercarriage.com/2020/05/25/storage-migration-using-lvm/
Refer Redhat Official docs for more information on LVM https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/4/html/cluster_logical_volume_manager/lvm_cli
2 thoughts on “LVM Filesystem creation in Linux”