Académique Documents
Professionnel Documents
Culture Documents
1. A physical device only needs to be prepared if it is still not existed and a new physical volume is
required to create or extend a volume group. As initials, one partition is created which is /dev/sdb1
with 10G Linux LVM (8e00) type as shown below.
2. Create the physical volume. Label multiple devices at a time by using space-delimited device names
as arguments to pvcreate. A PV only needs to be created if there are no PVs free to create or extend a
VG.
3. Create a volume group. As arguments to vgcreate, define a VG name and list one or more PVs to
allocate to the VG.
4. Create a logical volume. Use these arguments to lvcreate as a minimum: use the -n option to set the
LV name, the -L option to set the LV size in bytes or larger named values and identify the VG name
that the current LV is to be created in. Different tools will display the logical volume name using the
traditional name, /dev/vgname/lvname or the kernel device mapper name, /dev/mapper/vgname-
lvname.
5. Add the file system. Use mkfs to create an XFS file system on the new logical volume.
1|P a g e
Title: SOP for Managing Logical Volume Management (LVM) Storage
Prepared By: Mohd Nazri Bin Mazlan
5.1 To make the file system available across reboots, use mkdir to create a mount point directory.
...
...
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/mapper/vg--nazri-lv--nazri /mnt/nazri xfs defaults 0 0
5.3 Run mount -a to mount all file systems in /etc/fstab file, including the recently added entry. To
verify, use the mount or df command.
[root%iridium ~]# mount –a
[root@iridium ~]# df -h
Filesystem Size Used Avail Use% Mounted on
...
...
/dev/sda1 497M 124M 374M 25% /boot
/dev/mapper/vg--nazri-lv--nazri 5.0G 33M 5.0G 1% /mnt/nazri
EXAMPLES
Understanding xfs_info output.
Here, the data section of the output indicates "bsize=4096", meaning the data
block size for this filesystem is 4096 bytes. This
2|P a g e
Title: SOP for Managing Logical Volume Management (LVM) Storage
Prepared By: Mohd Nazri Bin Mazlan
section also shows "sunit=32 swidth=128 blks", which means the stripe unit is
32*4096 bytes = 128 kibibytes and the stripe width
is 128*4096 bytes = 512 kibibytes. A single stripe of this filesystem
therefore consists of four stripe units (128 blocks / 32
blocks per unit).
2. Remove the logical volume by using lvremove command. Use the device name as an argument. The
LV must be unmounted before running this command. It will ask for confirmation before removing the
LV.
Or
3. Remove the volume group by using vgremove command. Use the VG name as the argument.
4. Remove the physical volumes by using pvremove command. Use a space delimited list of PV
devices to remove more than one a time. The PV metadata is wiped from the partition or disk.
1. Another partition created which is /dev/sdb2 with the exact settings of /dev/sdb1. As initials, vg-
nazri is created inside partition /dev/sdb1 with size of 10G and Linux LVM (8e00) type.
3|P a g e
Title: SOP for Managing Logical Volume Management (LVM) Storage
Prepared By: Mohd Nazri Bin Mazlan
2. Create the physical volume. Use the device name as the argument to pvcreate. A PV only needs to
be created if there are not PVs free to extend the VG.
3. Extend the volume group. Use the VG name and PV device name as arguments to vgextend.
4. Verify the new VG space is available before proceed to extend the logical volume.
5. Extend the logical volume and XFS file system. One benefit of logical volumes is the ability to
increase their size without experiencing downtime.
5.1 This will increase logical volume lv-nazri by 500M. The “+” indicates add 500M to the existing
size which is 5G.
5.2 Another way to specify the size by using -l option which generally use physical extents values, use
vgdisplay command to view the available PEs size. As per below, 213 extents is added to the current
size of the logical volume.
4|P a g e
Title: SOP for Managing Logical Volume Management (LVM) Storage
Prepared By: Mohd Nazri Bin Mazlan
6. Extend the XFS file system. xfs_growfs /mountpoint command expands the file system to occupy
the extended LV. The file system needs to be mounted before running the command. You cannot grow
an XFS file system that is currently unmounted. There is currently no command to shrink an XFS file
system. Instead, you need to recreate the partition with a larger size and restore its contents from a
backup (if you deleted the original partition) or (from the contents of the original partition if you did
not delete it to free up disk space). A common mistake is to run lvextend but forgot to run xfs_growfs.
As an alternative, run the two steps consecutively to include –r as an option with the lvextend
command. This resizes the underlying file system together with the LV is extended using fsadm
command.
[root@iridium ~]# xfs_growfs /mnt/nazri
meta-data=/dev/mapper/vg--nazri-lv--nazri isize=256 agcount=4, agsize=327680 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 1310720 to 1656832
[root@iridium ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 18G 6.5G 11G 38% /
devtmpfs 880M 0 880M 0% /dev
tmpfs 889M 0 889M 0% /dev/shm
tmpfs 889M 8.8M 880M 1% /run
tmpfs 889M 0 889M 0% /sys/fs/cgroup
/dev/mapper/vg--nazri-lv--nazri 6.4G 33M 6.3G 1% /mnt/nazri
/dev/sda1 497M 124M 374M 25% /boot
1. Move the physical extents. Pvmove is used to relocate any physical extents used on the physical
volume to other PVs in the VG. This is only possible if there are enough free extents in the VG and if
all of those come from other PVs. Use the PV device name for which the PEs will be moved as the
argument of the command. As per below, this will move the PEs from /dev/sdb1 to other PVs with free
PEs in the same VG. Please note that it is recommended to backup data on all LV in the VG.
Unexpected power loss during the operation may leave the VG in an inconsistent state which could
cause loss of data on LVs in the VG.
2. Reduce the volume group by using vgreduce command. It will remove the physical volume from the
volume group. Use the VG name and PV device name as arguments to the command. As per below,
the /dev/sdc1 PV is removed from vg-nazri VG and can be added to another VG. Alternatively,
pvremove command can be used to stop using the device as a PV permanently.
5|P a g e
Title: SOP for Managing Logical Volume Management (LVM) Storage
Prepared By: Mohd Nazri Bin Mazlan
Increase the underlying block device, partition and LVM volume first. Then, expand the partition
using xfs_growfs for XFS or resize2fs for ext2/3/4.
1. Check the name of the SCSI devices. It is required to rescan the SCSI devices after changing the
disk size in VMware. But this doesn’t apply for the server that has been booted, as the SCSI devices
rescan on boot.
2. Then rescan the SCSI bus, replace with the actual SCSI bus name. It will rescan the current SCSI
bus and new disk size will show up.
1. The actions are similar with to those described above. But instead of rescanning an already existed
SCSI bus, we need to rescan the host to detect the new SCSI bus as a new disk has been added.
2. The host device is called “host0”, rescan it as such. It won’t show the output, instead running “fdisk
–l” will show the new disk.
6|P a g e