First install gdisk utility (you may use old fdisk utility if LUN/drive size is less than 2 TB)

-bash-4.1$ yum install gdisk
Loaded plugins: fastestmirror, security
You need to be root to perform this command.
-bash-4.1$ su
Password:
[root@LinuxAcademy linuxacademy]# yum install gdisk
Loaded plugins: fastestmirror, security
Setting up Install Process
Determining fastest mirrors
* base: mirror.cs.pitt.edu
* extras: mirrors.advancedhosters.com
* updates: mirror.atlanticmetro.net
base | 3.7 kB 00:00
base/primary_db | 3.7 MB 00:00
extras | 3.3 kB 00:00
extras/primary_db | 21 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 4.6 MB 00:00
Resolving Dependencies
–> Running transaction check
—> Package gdisk.i686 0:0.8.10-1.el6 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
gdisk i686 0.8.10-1.el6 base 172 k

Transaction Summary
================================================================================
Install 1 Package(s)

Total download size: 172 k
Installed size: 645 k
Is this ok [y/N]: y
Downloading Packages:
gdisk-0.8.10-1.el6.i686.rpm | 172 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : gdisk-0.8.10-1.el6.i686 1/1
Verifying : gdisk-0.8.10-1.el6.i686 1/1

Installed:
gdisk.i686 0:0.8.10-1.el6

Complete!

Please partition the new disk using gdisk

[root@LinuxAcademy linuxacademy]# gdisk /dev/xvdf

GPT fdisk (gdisk) version 0.8.10

Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present

Creating new GPT entries.

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-41943006, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-41943006, default = 41943006) or {+-}size{KMGTP}:
Current type is ‘Linux filesystem’
Hex code or GUID (L to show codes, Enter = 8300): L
0700 Microsoft basic data 0c01 Microsoft reserved 2700 Windows RE
3000 ONIE boot 3001 ONIE config 4100 PowerPC PReP boot
4200 Windows LDM data 4201 Windows LDM metadata 7501 IBM GPFS
7f00 ChromeOS kernel 7f01 ChromeOS root 7f02 ChromeOS reserved
8200 Linux swap 8300 Linux filesystem 8301 Linux reserved
8302 Linux /home 8400 Intel Rapid Start 8e00 Linux LVM
a500 FreeBSD disklabel a501 FreeBSD boot a502 FreeBSD swap
a503 FreeBSD UFS a504 FreeBSD ZFS a505 FreeBSD Vinum/RAID
a580 Midnight BSD data a581 Midnight BSD boot a582 Midnight BSD swap
a583 Midnight BSD UFS a584 Midnight BSD ZFS a585 Midnight BSD Vinum
a800 Apple UFS a901 NetBSD swap a902 NetBSD FFS
a903 NetBSD LFS a904 NetBSD concatenated a905 NetBSD encrypted
a906 NetBSD RAID ab00 Apple boot af00 Apple HFS/HFS+
af01 Apple RAID af02 Apple RAID offline af03 Apple label
af04 AppleTV recovery af05 Apple Core Storage be00 Solaris boot
bf00 Solaris root bf01 Solaris /usr & Mac Z bf02 Solaris swap
bf03 Solaris backup bf04 Solaris /var bf05 Solaris /home
bf06 Solaris alternate se bf07 Solaris Reserved 1 bf08 Solaris Reserved 2
bf09 Solaris Reserved 3 bf0a Solaris Reserved 4 bf0b Solaris Reserved 5
c001 HP-UX data c002 HP-UX service ea00 Freedesktop $BOOT
eb00 Haiku BFS ed00 Sony system partitio ed01 Lenovo system partit
Press the <Enter> key to see more codes: 8e00
ef00 EFI System ef01 MBR partition scheme ef02 BIOS boot partition
fb00 VMWare VMFS fb01 VMWare reserved fc00 VMWare kcore crash p
fd00 Linux RAID
Hex code or GUID (L to show codes, Enter = 8300): 8e00
Changed type of partition to ‘Linux LVM’

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/xvdf.
The operation has completed successfully.

Please repeat the steps for /dev/xvdj

Please create physical volume group and logical volume group

[root@LinuxAcademy linuxacademy]# pvcreate /dev/xvdf1 /dev/xvdj1
Physical volume “/dev/xvdf1” successfully created
Physical volume “/dev/xvdj1” successfully created
[root@LinuxAcademy linuxacademy]# pvdisplay
“/dev/xvdf1” is a new physical volume of “20.00 GiB”
— NEW Physical volume —
PV Name /dev/xvdf1
VG Name
PV Size 20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 5E12Tu-E1tn-8U7d-OK2g-pw3N-B8tC-9K1eeU

“/dev/xvdj1” is a new physical volume of “20.00 GiB”
— NEW Physical volume —
PV Name /dev/xvdj1
VG Name
PV Size 20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID xIc4BG-SXXf-RTYs-4xX8-Z4Ye-wT7n-z7vDJh

[root@LinuxAcademy linuxacademy]# vgcreate log_vg /dev/xvdf1 /dev/xvdj1
Volume group “log_vg” successfully created
[root@LinuxAcademy linuxacademy]# vgdisplay
— Volume group —
VG Name log_vg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 39.99 GiB
PE Size 4.00 MiB
Total PE 10238
Alloc PE / Size 0 / 0
Free PE / Size 10238 / 39.99 GiB
VG UUID ojwPwH-OhHT-vKCi-EIqc-K5g4-1Aom-7272Qn

[root@LinuxAcademy linuxacademy]# lvcreate -n log_lv -L 10GB log_vg
Logical volume “log_lv” created.
[root@LinuxAcademy linuxacademy]# lvdisplay
— Logical volume —
LV Path /dev/log_vg/log_lv
LV Name log_lv
VG Name log_vg
LV UUID ES1qhb-fIUg-Jvho-lviK-temg-ppD0-b9AEp4
LV Write Access read/write
LV Creation host, time LinuxAcademy, 2017-10-16 04:13:39 -0400
LV Status available
# open 0
LV Size 10.00 GiB
Current LE 2560
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0

Create file system

[root@LinuxAcademy linuxacademy]# mkfs -t ext4 /dev/log
mke2fs 1.41.12 (17-May-2010)
/dev/log is not a block special device.
Proceed anyway? (y,n) n
[root@LinuxAcademy linuxacademy]# mkfs -t ext4 /dev/log_vg/log_lv
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

Mount the filesystem

[root@LinuxAcademy linuxacademy]# mkdir /mnt/log_files

[root@LinuxAcademy linuxacademy]# mount /dev/log_vg/log_lv /mnt/log_files
[root@LinuxAcademy linuxacademy]# vgdisplay
— Volume group —
VG Name log_vg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 39.99 GiB
PE Size 4.00 MiB
Total PE 10238
Alloc PE / Size 2560 / 10.00 GiB
Free PE / Size 7678 / 29.99 GiB
VG UUID ojwPwH-OhHT-vKCi-EIqc-K5g4-1Aom-7272Qn

Please make following entry in /etc/fstab to auto mount

/dev/log_vg/log_lvĀ /mnt/log_files ext4 defaults 0 0

How to remove Volume group

[root@LinuxAcademy linuxacademy]# vgremove log_vg
Do you really want to remove volume group “log_vg” containing 1 logical volumes? [y/n]: y
Logical volume log_vg/log_lv contains a filesystem in use.
[root@LinuxAcademy linuxacademy]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvde1 5.8G 1.5G 4.1G 26% /
tmpfs 299M 0 299M 0% /dev/shm
/dev/mapper/log_vg-log_lv
9.9G 151M 9.2G 2% /mnt/log_files
[root@LinuxAcademy linuxacademy]# umount /mnt/log_files
[root@LinuxAcademy linuxacademy]# vgremove log_vg
Do you really want to remove volume group “log_vg” containing 1 logical volumes? [y/n]: y
Do you really want to remove active logical volume log_lv? [y/n]: y
Logical volume “log_lv” successfully removed
Volume group “log_vg” successfully removed
[root@LinuxAcademy linuxacademy]# lvdisplay
[root@LinuxAcademy linuxacademy]# vgdisplay

[root@LinuxAcademy linuxacademy]# pvremove /dev/xvdf1 /dev/xvdj1
Labels on physical volume “/dev/xvdf1” successfully wiped
Labels on physical volume “/dev/xvdj1” successfully wiped

One Reply to “Create new mount point using LVM in RHEL 7”

Leave a Reply

Your email address will not be published. Required fields are marked *