how to add add new disk to lvm group
Use the lsblk command to view your available disk devices and their mount points. The output of lsblk removes the /dev/
prefix from full device paths. Here xvda
is root device and -xvda1
is partitions. /
indicate the mount point. On the other hand xvdf
no partition and mount point.
[ec2-user ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 8G 0 disk
-xvda1 202:1 0 8G 0 part /
xvdf 202:80 0 10G 0 disk
Lets say we want to add disk xvdf
, So first we need to determine our file system. New volumes are raw block devices, and we must create a file system to use them. We can determine file system by following command -
[ec2-user ~]$ sudo file -s /dev/xvdf
/dev/xvdf: data
If the output shows simply data
, then there is no file system on the device
[ec2-user ~]$ sudo file -s /dev/xvda1
/dev/xvda1: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)
output shows a root device with the XFS file system.
Also we can use lsblk -f to get file information. We can get information about all of the attached devices to the instance.
[ec2-user ~]$ sudo lsblk -f
Display all available LVM block
sudo lvmdiskscan
Output
/dev/sda [ 200.00 GiB]
/dev/sdb [ 100.00 GiB]
2 disks
2 partitions
0 LVM physical volume whole disks
0 LVM physical volumes
It'll return all information. Now if you want to know specific disk which is using lvm you can use -
lvmdiskscan -l
Output
WARNING: only considering LVM devices
/dev/vda3 [ <99.00 GiB] LVM physical volume
0 LVM physical volume whole disks
1 LVM physical volume
The pvscan
command searches all available devices for LVM physical volumes -
sudo pvscan
Output
PV /dev/sda VG LVMVolGroup lvm2 [200.00 GiB / 0 free]
PV /dev/sdb VG LVMVolGroup lvm2 [100.00 GiB / 10.00 GiB free]
Total: 2 [299.99 GiB] / in use: 2 [299.99 GiB] / in no VG: 0 [0 ]
pvs
and pvdisplay
can find more additional information -
if we also want to discover logical extents that have been mapped to each volume we can use -m
option to the pvdisplay
command.
sudo pvdisplay -m
To discover available volume group we can use -
vgscan
Output
Reading all physical volumes. This may take a while...
Found volume group "LVMVolGroup" using metadata type lvm2
here LVMVolGroup
is the volume group where we can add more space and manage logical volume group.