redhat-lvm-disks

Main steps are:

  1. fdisk
  2. physical volume.
  3. volume group
  4. Logical Volume
  5. Format
  6. mount.

1 - Fdisk

fdisk create partition

So we check SDB new disk:

[root@soahost ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 16.2 GB, 16231284736 bytes, 31701728 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
Disk label type: dos
Identificador del disco: 0x928ba8b1

Disposit. Inicio    Comienzo      Fin      Bloques  Id  Sistema
/dev/sdb1            2048    31701727    15849840   8e  Linux LVM

2 - Physical volume.

[root@soahost ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.
[root@soahost ~]#

[root@soahost ~]# pvs
  PV         VG           Fmt  Attr PSize   PFree
  /dev/sda3  rhel_soahost lvm2 a--  <18,76g      0
  /dev/sdb1               lvm2 ---  <15,12g <15,12g
[root@soahost ~]#

3 - Volume Group

[root@soahost ~]# vgcreate rhel_oracle /dev/sdb1
  Volume group "rhel_oracle" successfully created
[root@soahost ~]# vgdisplay
  --- Volume group ---
  VG Name               rhel_soahost
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <18,76 GiB
  PE Size               4,00 MiB
  Total PE              4802
  Alloc PE / Size       4802 / <18,76 GiB
  Free  PE / Size       0 / 0
  VG UUID               eoJEc1-RKOC-axtL-q02R-LyOe-4Aag-VO2cd0

  --- Volume group ---
  VG Name               rhel_oracle
  System ID
  Format                lvm2
  Metadata Areas        1
  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                1
  Act PV                1
  VG Size               15,11 GiB
  PE Size               4,00 MiB
  Total PE              3869
  Alloc PE / Size       0 / 0
  Free  PE / Size       3869 / 15,11 GiB
  VG UUID               4rS6ua-FlUv-eDxa-tXc3-R6ej-gvLF-1cLLEv

[root@soahost ~]# pvs
  PV         VG           Fmt  Attr PSize   PFree
  /dev/sda3  rhel_soahost lvm2 a--  <18,76g     0
  /dev/sdb1  rhel_oracle  lvm2 a--   15,11g 15,11g
[root@soahost ~]#

4 - Logical Volume creation

[root@soahost ~]# pvs
  PV         VG           Fmt  Attr PSize   PFree
  /dev/sda3  rhel_soahost lvm2 a--  <18,76g     0
  /dev/sdb1  rhel_oracle  lvm2 a--   15,11g 15,11g
[root@soahost ~]#

[root@soahost ~]# lvs
  LV   VG           Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root rhel_soahost -wi-ao---- 16,78g
  swap rhel_soahost -wi-ao---- <1,98g
[root@soahost ~]#

[root@soahost ~]# lvcreate -L 15G -n oracle rhel_oracle
  Logical volume "oracle" created.
[root@soahost ~]#

We check the space is being consumed:
[root@soahost ~]# vgs
  VG           #PV #LV #SN Attr   VSize   VFree
  rhel_oracle    1   1   0 wz--n-  15,11g 116,00m
  rhel_soahost   1   2   0 wz--n- <18,76g      0
[root@soahost ~]# lvs
  LV     VG           Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  oracle rhel_oracle  -wi-a----- 15,00g
  root   rhel_soahost -wi-ao---- 16,78g
  swap   rhel_soahost -wi-ao---- <1,98g
[root@soahost ~]#

5 - Create filesystem and mount:

[root@soahost opt]# mkfs.xfs -f /dev/mapper/rhel_oracle-oracle
meta-data=/dev/mapper/rhel_oracle-oracle isize=512    agcount=4, agsize=983040 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=3932160, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@soahost opt]#

Mount:

[root@soahost opt]# vi /etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue May 22 14:27:13 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel_soahost-root /                       xfs     defaults        0 0
/dev/mapper/rhel_oracle-oracle /opt/oracle                       xfs     defaults        0 0
UUID=e6c6b59f-af90-4611-a062-6035fa5d20d9 /boot                   xfs     defaults        0 0
/dev/mapper/rhel_soahost-swap swap                    swap    defaults        0 0

[root@soahost opt]# mount -a
[root@soahost opt]# df
S.ficheros                     bloques de 1K  Usados Disponibles Uso% Montado en
/dev/mapper/rhel_soahost-root       17586176 2953804    14632372  17% /
devtmpfs                             1011744       0     1011744   0% /dev
tmpfs                                1023780       0     1023780   0% /dev/shm
tmpfs                                1023780    9000     1014780   1% /run
tmpfs                                1023780       0     1023780   0% /sys/fs/cgroup
/dev/sda2                            1038336  132312      906024  13% /boot
tmpfs                                 204756       0      204756   0% /run/user/1000
/dev/sr0                             4509696 4509696           0 100% /mnt
tmpfs                                 204756       0      204756   0% /run/user/0
/dev/mapper/rhel_oracle-oracle      15718400   32944    15685456   1% /opt/oracle

We agregate a new disk (sdb).

Disposit. Inicio    Comienzo      Fin      Bloques  Id  Sistema
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    43536383    20718592   8e  Linux LVM

We add our new disk to our Volume group rhel:

[root@maquesoa opt]# vgextend rhel /dev/sdb
  Volume group "rhel" successfully extended
[root@maquesoa opt]#