Create new mount point using LVM in RHEL 7

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

How to add raw disk first in vmware host RHEL 7 from datastore and attach to ASM diskgroup using udev rules and asmca

First Add disk from datastore to the VM server node using following steps

  • Login to vCenter console and Right Click Server -> Edit Settings.

  • Click Add and add a New Disk

  • Create a new virtual disk.

  • Provide capacity and all related setting.

  • Also specify the Datastore.

 

  • Select proper settings in Virtual Device Node

  • Check all the settings and Finish to complete.

Second,This needs to be done in Server level.

1.Login with root user to the server

 

2.Take backup of fdisk -l and lsblk output to a temp file.

 

lsblk>tt

fdisk -l>>tt

 

3.Please check lsblk output

 

lsblk

 

[root@XXX rules.d]# lsblk

NAME                    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

sda                       8:0    0   80G  0 disk

├─sda1                    8:1    0  512M  0 part /boot

├─sda2                    8:2    0   17G  0 part [SWAP]

└─sda3                    8:3    0 62.5G  0 part

├─vg00-lvusr          253:0    0 12.8G  0 lvm  /usr

├─vg00-lvroot         253:1    0  8.8G  0 lvm  /

├─vg00-lvhome         253:8    0  5.5G  0 lvm  /home

├─vg00-lvopt          253:9    0  8.8G  0 lvm  /opt

├─vg00-lvvar          253:10   0 17.6G  0 lvm  /var

└─vg00-lvtmp          253:11   0  8.8G  0 lvm  /tmp

sdb                       8:16   0   65G  0 disk

└─sdb1                    8:17   0   65G  0 part

├─vg_ora-product      253:2    0   14G  0 lvm  /u01/app/product

├─vg_ora-oraInventory 253:3    0    2G  0 lvm  /u01/app/oraInventory

├─vg_ora-oracle       253:4    0   14G  0 lvm  /u01/app/oracle

├─vg_ora-grid         253:5    0   12G  0 lvm  /u01/app/grid

├─vg_ora-oraclecd     253:6    0   20G  0 lvm  /oraclecd

└─vg_ora-lvoemcc      253:7    0    3G  0 lvm  /u01/oemcc

sdc                       8:32   0   10G  0 disk

└─sdc1                    8:33   0   10G  0 part

sdd                       8:48   0   10G  0 disk

└─sdd1                    8:49   0   10G  0 part

sde                       8:64   0   10G  0 disk

└─sde1                    8:65   0   10G  0 part

sdf                       8:80   0  100G  0 disk

└─sdf1                    8:81   0  100G  0 part

sdg                       8:96   0  300G  0 disk

└─sdg1                    8:97   0  300G  0 part /TEMPORAL

 

4.Run following command to probe the disk

echo “- – -” > /sys/class/scsi_host/host0/scan
echo “- – -” > /sys/class/scsi_host/host1/scan
echo “- – -” > /sys/class/scsi_host/host2/scan

  1. Please check lsblk output again

 

[root@XXX rules.d]# lsblk

NAME                    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

sda                       8:0    0   80G  0 disk

├─sda1                    8:1    0  512M  0 part /boot

├─sda2                    8:2    0   17G  0 part [SWAP]

└─sda3                    8:3    0 62.5G  0 part

├─vg00-lvusr          253:0    0 12.8G  0 lvm  /usr

├─vg00-lvroot         253:1    0  8.8G  0 lvm  /

├─vg00-lvhome         253:8    0  5.5G  0 lvm  /home

├─vg00-lvopt          253:9    0  8.8G  0 lvm  /opt

├─vg00-lvvar          253:10   0 17.6G  0 lvm  /var

└─vg00-lvtmp          253:11   0  8.8G  0 lvm  /tmp

sdb                       8:16   0   65G  0 disk

└─sdb1                    8:17   0   65G  0 part

├─vg_ora-product      253:2    0   14G  0 lvm  /u01/app/product

├─vg_ora-oraInventory 253:3    0    2G  0 lvm  /u01/app/oraInventory

├─vg_ora-oracle       253:4    0   14G  0 lvm  /u01/app/oracle

├─vg_ora-grid         253:5    0   12G  0 lvm  /u01/app/grid

├─vg_ora-oraclecd     253:6    0   20G  0 lvm  /oraclecd

└─vg_ora-lvoemcc      253:7    0    3G  0 lvm  /u01/oemcc

sdc                       8:32   0   10G  0 disk

└─sdc1                    8:33   0   10G  0 part

sdd                       8:48   0   10G  0 disk

└─sdd1                    8:49   0   10G  0 part

sde                       8:64   0   10G  0 disk

└─sde1                    8:65   0   10G  0 part

sdf                       8:80   0  100G  0 disk

└─sdf1                    8:81   0  100G  0 part

sdg                       8:96   0  300G  0 disk

└─sdg1                    8:97   0  300G  0 part /TEMPORAL

sdh                       8:112  0  100G  0 disk

 

 

6.Now run fdisk command to create partition on newly added raw disk

 

[root@XXX rules.d]# fdisk /dev/sdh

Welcome to fdisk (util-linux 2.23.2).

 

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

Building a new DOS disklabel with disk identifier 0x30ea7a70.

 

Command (m for help): n

Partition type:

p   primary (0 primary, 0 extended, 4 free)

e   extended

Select (default p): p

Partition number (1-4, default 1):

First sector (2048-209715199, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):

Using default value 209715199

Partition 1 of type Linux and of size 100 GiB is set

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

7.Run the lsblk again to check new partition

 

[root@XXX rules.d]# lsblk

NAME                    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

sda                       8:0    0   80G  0 disk

├─sda1                    8:1    0  512M  0 part /boot

├─sda2                    8:2    0   17G  0 part [SWAP]

└─sda3                    8:3    0 62.5G  0 part

├─vg00-lvusr          253:0    0 12.8G  0 lvm  /usr

├─vg00-lvroot         253:1    0  8.8G  0 lvm  /

├─vg00-lvhome         253:8    0  5.5G  0 lvm  /home

├─vg00-lvopt          253:9    0  8.8G  0 lvm  /opt

├─vg00-lvvar          253:10   0 17.6G  0 lvm  /var

└─vg00-lvtmp          253:11   0  8.8G  0 lvm  /tmp

sdb                       8:16   0   65G  0 disk

└─sdb1                    8:17   0   65G  0 part

├─vg_ora-product      253:2    0   14G  0 lvm  /u01/app/product

├─vg_ora-oraInventory 253:3    0    2G  0 lvm  /u01/app/oraInventory

├─vg_ora-oracle       253:4    0   14G  0 lvm  /u01/app/oracle

├─vg_ora-grid         253:5    0   12G  0 lvm  /u01/app/grid

├─vg_ora-oraclecd     253:6    0   20G  0 lvm  /oraclecd

└─vg_ora-lvoemcc      253:7    0    3G  0 lvm  /u01/oemcc

sdc                       8:32   0   10G  0 disk

└─sdc1                    8:33   0   10G  0 part

sdd                       8:48   0   10G  0 disk

└─sdd1                    8:49   0   10G  0 part

sde                       8:64   0   10G  0 disk

└─sde1                    8:65   0   10G  0 part

sdf                       8:80   0  100G  0 disk

└─sdf1                    8:81   0  100G  0 part

sdg                       8:96   0  300G  0 disk

└─sdg1                    8:97   0  300G  0 part /TEMPORAL

sdh                       8:112  0  100G  0 disk

└─sdh1                    8:113  0  100G  0 part

 

8.Please note the scsi_id as following:-

 

[root@XXX rules.d]# /usr/lib/udev/scsi_id -g -u -d /dev/sdh1

36000c292e30b8d54846d5de1787d8f27

 

9.Take backup of udev rules

cd /etc/udev/rules.d

[root@XXX rules.d]# cp 99-oracle-asmdevices.rules 99-oracle-asmdevices.rules_old

 

10.Please add last time changing RESULT and SYMLINK+ (increment it by one)

 

[root@XXX rules.d]# cat 99-oracle-asmdevices.rules

#sdc1

KERNEL==”sd?1″, SUBSYSTEM==”block”, PROGRAM==”/usr/lib/udev/scsi_id -g -u -d /dev/$parent”, RESULT==”36000c29034fea4393fa82565c3b06de0″, SYMLINK+=”asm-disk01″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″

 

#sdd1

KERNEL==”sd?1″, SUBSYSTEM==”block”, PROGRAM==”/usr/lib/udev/scsi_id -g -u -d /dev/$parent”, RESULT==”36000c293e4ad06adc3e7b4c1b8ca456c”, SYMLINK+=”asm-disk02″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″

 

#sde1

KERNEL==”sd?1″, SUBSYSTEM==”block”, PROGRAM==”/usr/lib/udev/scsi_id -g -u -d /dev/$parent”, RESULT==”36000c2993f2aa2059211cad7b5930f91″, SYMLINK+=”asm-disk03″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″

 

#sdf1

KERNEL==”sd?1″, SUBSYSTEM==”block”, PROGRAM==”/usr/lib/udev/scsi_id -g -u -d /dev/$parent”, RESULT==”36000c29ea8626431ac553e9ec82d4d58″, SYMLINK+=”asm-disk04″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″

 

#sdh1

KERNEL==”sd?1″, SUBSYSTEM==”block”, PROGRAM==”/usr/lib/udev/scsi_id -g -u -d /dev/$parent”, RESULT==”36000c292e30b8d54846d5de1787d8f27″, SYMLINK+=”asm-disk05″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″

 

11.Refresh the udev rules

 

udevadm trigger

udevadm control –reload-rules

 

12.Now the asm-disk05 will be visible.

 

[root@XXX rules.d]# ls -l /dev/ | grep asm-disk

lrwxrwxrwx 1 root root            4 Nov 16 04:49 asm-disk01 -> sdc1

lrwxrwxrwx 1 root root            4 Nov 16 04:49 asm-disk02 -> sdd1

lrwxrwxrwx 1 root root            4 Nov 16 04:49 asm-disk03 -> sde1

lrwxrwxrwx 1 root root            4 Nov 16 04:50 asm-disk04 -> sdf1

lrwxrwxrwx 1 root root            4 Nov 16 04:49 asm-disk05 -> sdh1

 

13.Now open asmca after login to grid user .

 

14.Add disk to diskgroup by right click on particular diskgroup

15.Now disk is added successfully on +DATA